Python Example of Uploading an OVA Package to a Library Item

This example is based on the
signed_ova_import.py
sample file.
This example uses the steps that are described in the Upload an OVA Package to a Library Item procedure.
For a complete and up-to-date version of the sample code, see the vSphere Automation SDK Python samples at GitHub.
... # 1 - Specify the OVA filename and location. SIGNED_OVA_FILENAME = 'nostalgia-signed.ova' SIGNED_OVA_RELATIVE_DIR = '../resources/signedOvaWithCertWarning' # 2 - Create a new library item in the content library for uploading the files. self.lib_item_id = self.helper.create_library_item(library_id=self.local_lib_id, item_name=self.lib_item_name, item_description='Sample template from ova file', item_type='ovf') # 3 - Set a pointer to the OVA file you want to upload. ova_file_map = self.helper.get_ova_file_map(self.SIGNED_OVA_RELATIVE_DIR, local_filename=self.SIGNED_OVA_FILENAME) # 4 - Create a new update session for uploading the files. session_id = self.client.upload_service.create( create_spec=UpdateSessionModel(library_item_id=self.lib_item_id), client_token=generate_random_uuid()) self.helper.upload_files_in_session(ova_file_map, session_id) # 5 - Wait for terminal preview state and obtain preview warnings. self.wait_for_terminal_preview_state(session_id, AVAILABLE) session = self.client.upload_service.get(session_id) preview_info = session.preview_info # 6 - Ignore preview warnings on session, if any. ignore_warning_behaviors = [] for warning_type in preview_warning_types: warning_behavior = WarningBehavior(type=warning_type, ignored=True) ignore_warning_behaviors.append(warning_behavior) self.client.upload_service.update(session_id, update_spec=UpdateSessionModel( warning_behavior=ignore_warning_behaviors)) # 7 - Complete the update session. self.client.upload_service.complete(session_id) # 8 - Delete the session. self.client.upload_service.delete(session_id)