本文整理汇总了Python中host.hypervisor.esx.vim_client.VimClient.get_vim_ticket方法的典型用法代码示例。如果您正苦于以下问题:Python VimClient.get_vim_ticket方法的具体用法?Python VimClient.get_vim_ticket怎么用?Python VimClient.get_vim_ticket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.hypervisor.esx.vim_client.VimClient
的用法示例。
在下文中一共展示了VimClient.get_vim_ticket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestVimClient
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import get_vim_ticket [as 别名]
#.........这里部分代码省略.........
assert_that(listener._ds_update_count, is_(1))
mock_apply = MagicMock(wraps=self.vim_client._vim_cache._update_ds_cache)
self.vim_client._vim_cache._update_ds_cache = mock_apply
_, vm, _, _ = self._create_test_vm("ds-update-test")
task = vm.Destroy()
self.vim_client.wait_for_task(task)
# expect to get a datastore property update (unfortunately) ...
for _ in xrange(50):
if mock_apply.call_count > 0:
break
time.sleep(0.1)
# ... but that additional datastore updated notifications are sent out
# as a result
assert_that(listener._ds_update_count, is_(1))
def get_create_spec(self, datastore, vm_id, disk_path):
create_spec = EsxVmConfigSpec(None)
create_spec.init_for_create(vm_id, datastore, 64, 2)
create_spec._cfg_spec.files = vim.vm.FileInfo(vmPathName="[%s] /" % datastore)
controller = vim.vm.device.VirtualLsiLogicController(
key=1,
sharedBus=vim.vm.device.VirtualSCSIController.Sharing.noSharing,
busNumber=2,
unitNumber=-1)
create_spec._add_device(controller)
backing = vim.vm.device.VirtualDisk.FlatVer2BackingInfo(
fileName=disk_path,
diskMode=vim.vm.device.VirtualDiskOption.DiskMode.persistent
)
disk = vim.vm.device.VirtualDisk(
controllerKey=1,
key=-1,
unitNumber=-1,
backing=backing,
capacityInKB=1024,
)
create_spec._create_device(disk)
return create_spec
def get_update_spec(self, vm_info, disk_path):
update_spec = EsxVmConfigSpec(None)
update_spec.init_for_update()
backing = vim.vm.device.VirtualDisk.FlatVer2BackingInfo(
fileName=disk_path,
diskMode=vim.vm.device.VirtualDiskOption.DiskMode.persistent
)
controller = update_spec._find_scsi_controller(vm_info.config)
disk = vim.vm.device.VirtualDisk(
controllerKey=controller.key,
key=-1,
unitNumber=-1,
backing=backing,
capacityInKB=1024,
)
update_spec._create_device(disk)
return update_spec
def get_remove_spec(self, vm_info, disk_path):
remove_spec = EsxVmConfigSpec(None)
remove_spec.init_for_update()
devices = remove_spec._get_devices_by_type(vm_info.config, vim.vm.device.VirtualDisk)
found_device = None
for device in devices:
if device.backing.fileName.endswith(disk_path):
found_device = device
remove_spec._remove_device(found_device)
return remove_spec
def test_clone_ticket(self):
ticket = self.vim_client.get_vim_ticket()
vim_client2 = VimClient()
vim_client2.connect_ticket(self.host, ticket)
vim_client2.host_system()
def _wait_vm_has_disk(self, vm_id, disk_num):
"""Wait until the vm has disk number of the vm becomes disk_num
"""
now = time.time()
for _ in xrange(50):
vm_in_cache = self.vim_client.get_vm_in_cache(vm_id)
if len(vm_in_cache.disks) == disk_num:
self._logger.info("VmCache disk number synced in %.2f second" %
(time.time() - now))
break
time.sleep(0.1)
def _wait_vm_power_status(self, vm_id, power_state):
"""Wait until the vm has power_state
"""
now = time.time()
for _ in xrange(50):
vm_in_cache = self.vim_client.get_vm_in_cache(vm_id)
if vm_in_cache.power_state == power_state:
self._logger.info("VmCache power_state synced in %.2f second" %
(time.time() - now))
break
time.sleep(0.1)