This example is based on the contentlibrary_workflow.py sample file. This file is located in the vCloud Suite SDK for Python directory: client/samples/src/com/vmware/vcloud/suite/sample/workflow.
This example uses the steps that are described in the Upload an OVF Package from a URL to a Library Item procedure.
from com.vmware.content import library_client from com.vmware.content.library import item_client from com.vmware.content.library.item import update_session_client import uuid # 1 - Create a empty library item to describe the virtual machine. item_model = library_client.ItemModel() item_model.name = “ubuntu-vm” item_model.description = “ubuntu 7.0” item_model.library_id = my_library_id item_model.type = “ovf” client_token = str(uuid.uuid4()) item_stub = library_client.Item(my_stub_config) item_id = item_stub.create(create_spec=item_model, client_token=client_token) # 2 - Create an update session. update_session_model = item_client.UpdateSessionModel() update_session_model.library_item_id = item_id client_token = str(uuid.uuid4()) update_session_stub = update_session_client.UpdateSession(my_stub_config) session_id = update_session_stub.create(create_spec=update_session_model, client_token=client_token) # 3 - Create a file specification for the OVF envelope file. file_spec = update_session_client.AddSpec() file_spec.name = “ubuntu.ovf” file_spec.source_type = File.SourceType.PULL endpoint = item_client.TransferEndpoint() endpoint.uri = “http://www.example.com/images/ubuntu.ovf” file_spec.source_endpoint = endpoint # 4 - Link the file specification to the update session. update_file_stub = update_session_client.File(my_stub_config) update_file_stub.File.add(update_session_id=session_id, file_spec=file_spec) # 5 - Initiate the asynchronous transfer. update_session_stub.complete(session_id)