本文整理汇总了Python中host.hypervisor.esx.vim_client.VimClient.connect_ticket方法的典型用法代码示例。如果您正苦于以下问题:Python VimClient.connect_ticket方法的具体用法?Python VimClient.connect_ticket怎么用?Python VimClient.connect_ticket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.hypervisor.esx.vim_client.VimClient
的用法示例。
在下文中一共展示了VimClient.connect_ticket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: vim_delete_vm
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import connect_ticket [as 别名]
def vim_delete_vm(self, vm_id):
""" Delete a VM using the vim client """
try:
vim_client = VimClient()
vim_client.connect_ticket(self.server, self._get_vim_ticket())
vim_vm = vim_client.get_vm(vm_id)
if vim_vm.runtime.powerState != 'poweredOff':
try:
vim_task = vim_vm.PowerOff()
vim_client.wait_for_task(vim_task)
except:
logger.info("Cannot power off vm", exc_info=True)
vim_task = vim_vm.Destroy()
vim_client.wait_for_task(vim_task)
finally:
if vim_client:
vim_client.disconnect()
示例2: TestRemoteAgent
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import connect_ticket [as 别名]
#.........这里部分代码省略.........
def setUp(self):
from testconfig import config
if "agent_remote_test" not in config:
raise SkipTest()
# Set the default datastore name
self._datastores = None
if "datastores" in config["agent_remote_test"]:
datastores = config["agent_remote_test"]["datastores"]
self._datastores = [d.strip() for d in datastores.split(",")]
else:
self.fail("datastores not provided for test setUp")
# Optionally update the specification of a remote iso file. The file
# needs to exist on the remote esx server for this test to succeed.
self._remote_iso_file = None
self._second_remote_iso_file = None
if ("iso_file" in config["agent_remote_test"]):
self._remote_iso_file = config["agent_remote_test"]["iso_file"]
if ("second_iso_file" in config["agent_remote_test"]):
self._second_remote_iso_file = config["agent_remote_test"]["second_iso_file"]
server = config["agent_remote_test"]["server"]
self.server = server
self.generation = int(time.time())
# Connect to server and configure vim_client
self.client_connections()
self.vim_client = VimClient()
self.vim_client.connect_ticket(self.server, self._get_vim_ticket())
connect.SetSi(self.vim_client._si)
# Set host mode to normal
self.set_host_mode(HostMode.NORMAL)
# The first time setup is called the agent will restart.
self.provision_hosts()
# Reconnect to account for the restart
self.client_connections()
self.clear()
@classmethod
def setUpClass(cls):
cls.host_id = str(uuid.uuid4())
cls.deployment_id = "test-deployment"
def _close_agent_connections(self):
self.host_client.close()
self.control_client.close()
def tearDown(self):
self._close_agent_connections()
self.vim_client.disconnect()
def vim_delete_vm(self, vm_id):
""" Delete a VM using the vim client """
try:
vim_client = VimClient()
vim_client.connect_ticket(self.server, self._get_vim_ticket())
vim_vm = vim_client.get_vm(vm_id)
if vim_vm.runtime.powerState != 'poweredOff':
try:
示例3: test_clone_ticket
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import connect_ticket [as 别名]
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()