Example #1
0
 def spin_wait_for_task(self, vim_task):
     """Use pysdk's WaitForTask, which basically polling task status in a
     loop.
     """
     self._task_counter_add()
     self._logger.debug(
         "spin_wait_for_task: {0} Number of current tasks: {1}".
         format(str(vim_task), self._task_counter_read()))
     try:
         task.WaitForTask(vim_task, si=self._si)
     finally:
         self._task_counter_sub()
Example #2
0
    def nfc_copy(self, src_file_path, dst_host, dst_file_path, ssl_thumbprint, ticket):
        from pyVmomi import nfc

        (local_user, local_pwd) = VimClient()._acquire_local_credentials()
        si = connect.Connect(host="localhost", user=local_user, pwd=local_pwd, version=NFC_VERSION)
        nfc_manager = nfc.NfcManager('ha-nfc-manager', si._stub)

        copy_spec = nfc.CopySpec()
        copy_spec.source = nfc.CopySpec.Location()
        copy_spec.source.filePath = src_file_path

        copy_spec.destination = nfc.CopySpec.Location()
        copy_spec.destination.filePath = dst_file_path
        copy_spec.destination.cnxSpec = nfc.CopySpec.CnxSpec()
        copy_spec.destination.cnxSpec.useSSL = False
        copy_spec.destination.cnxSpec.host = dst_host
        copy_spec.destination.cnxSpec.port = NFC_PORT
        copy_spec.destination.cnxSpec.authData = nfc.CopySpec.TicketAuthData()
        copy_spec.destination.cnxSpec.authData.ticket = ticket
        copy_spec.destination.cnxSpec.authData.sslThumbprint = ssl_thumbprint

        copy_spec.opType = "copy"
        copy_spec.fileSpec = nfc.VmfsFlatDiskSpec()
        copy_spec.fileSpec.adapterType = "lsiLogic"
        copy_spec.fileSpec.preserveIdentity = True
        copy_spec.fileSpec.allocateType = "thick"
        copy_spec.option = nfc.CopySpec.CopyOptions()
        copy_spec.option.failOnError = True
        copy_spec.option.overwriteDestination = True
        copy_spec.option.useRawModeForChildDisk = False

        self._logger.info("transfer_image: copy_spec %s", str(copy_spec))
        nfc_task = nfc_manager.Copy([copy_spec, ])
        task.WaitForTask(nfc_task, raiseOnError=True, si=si,
                         pc=None,  # use default si prop collector
                         onProgressUpdate=None)
Example #3
0
 def run(self):
     """Wait for a task to finish.."""
     task.WaitForTask(self.task, si=self._si)
 def _make_new_iso_copy(self, file_manager, new_iso_path):
     copy_task = file_manager.CopyFile(self._remote_iso_file, None,
                                       new_iso_path, None)
     task.WaitForTask(copy_task)