本文整理汇总了Python中host.hypervisor.esx.vim_client.VimClient.initialize_host_counters方法的典型用法代码示例。如果您正苦于以下问题:Python VimClient.initialize_host_counters方法的具体用法?Python VimClient.initialize_host_counters怎么用?Python VimClient.initialize_host_counters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.hypervisor.esx.vim_client.VimClient
的用法示例。
在下文中一共展示了VimClient.initialize_host_counters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestVimClient
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import initialize_host_counters [as 别名]
#.........这里部分代码省略.........
self.vm_config.add_device(create_spec, 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,
)
self.vm_config.create_device(create_spec, disk)
return create_spec
def get_update_spec(self, vm_info, disk_path):
update_spec = vim.vm.ConfigSpec()
backing = vim.vm.device.VirtualDisk.FlatVer2BackingInfo(
fileName=disk_path,
diskMode=vim.vm.device.VirtualDiskOption.DiskMode.persistent
)
controller = \
self.vm_config._find_scsi_controller(update_spec,
vm_info.config)
disk = vim.vm.device.VirtualDisk(
controllerKey=controller.key,
key=-1,
unitNumber=-1,
backing=backing,
capacityInKB=1024,
)
self.vm_config.create_device(update_spec, disk)
return update_spec
def get_remove_spec(self, vm_info, disk_path):
remove_spec = vim.vm.ConfigSpec()
devices = self.vm_config.get_devices_from_config(vm_info.config)
found_device = None
for device in devices:
if isinstance(device, vim.vm.device.VirtualDisk) and \
device.backing.fileName.endswith(disk_path):
found_device = device
self.vm_config.remove_device(remove_spec, found_device)
return remove_spec
def test_clone_ticket(self):
ticket = self.vim_client.acquire_clone_ticket()
vim_client2 = VimClient(host=self.host, ticket=ticket)
vim_client2.host_system
def test_http_ticket(self):
datastore = self.vim_client.get_datastore().name
filename = "%s.bin" % str(uuid.uuid4())
quoted_dc_name = 'ha%252ddatacenter'
url = 'https://%s/folder/%s?dcPath=%s&dsName=%s' % (
self.host, filename, quoted_dc_name, datastore)
ticket = self.vim_client.acquire_cgi_ticket(url, HttpOp.PUT)
assert_that(ticket, is_not(equal_to(None)))
def test_host_stats(self):
""" Skip host stats test.
This test does not agree with the contract exposed from
the implementation.
Until the vim_client code be refactor/cleanup, disable this test for
now.
"""
raise SkipTest()
self.vim_client.initialize_host_counters()
self.vim_client.update_hosts_stats()
stats = self.vim_client.get_host_stats()
assert_that(has_key('mem.consumed'))
assert_that(stats['mem.consumed'], greater_than(0))
assert_that(has_key('rescpu.actav1'))
assert_that(stats['rescpu.actav1'], greater_than(0))
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)