def export(server, vm_obj): # Request an export request = VI.ExportVmRequestMsg() _this = request.new__this(vm_obj._mor) _this.set_attribute_type(vm_obj._mor.get_attribute_type()) request.set_element__this(_this) ret = server._proxy.ExportVm(request) # List of urls to download mor = ret._returnval http = VIProperty(connection, ret._returnval) url = http.info.deviceUrl[0].url # TODO: actually download them. # Set to 100% request = VI.HttpNfcLeaseProgressRequestMsg() _this = request.new__this(mor) _this.set_attribute_type(MORTypes.HttpNfcLease) request.set_element__this(_this) request.set_element_percent(100) server._proxy.HttpNfcLeaseProgress(request) # Completes the request request = VI.HttpNfcLeaseCompleteRequestMsg() _this = request.new__this(mor) _this.set_attribute_type(MORTypes.HttpNfcLease) request.set_element__this(_this) server._proxy.HttpNfcLeaseComplete(request)
def __poll_task_info(self, retries=3, interval=2): for i in range(retries): try: self.info = VIProperty(self._server, self._mor).info return True except Exception as e: if i == retries - 1: raise e time.sleep(interval)
def __init__(self, server, mor): self._server = server self._mor = mor self._properties = VIProperty(server, mor) try: self._supported_intervals = dict([ (i.key, i.samplingPeriod) for i in self._properties.historicalInterval if i.enabled ]) except: #not historical intervals supported self._supported_intervals = {}