本文整理汇总了Python中pyvcloud.vcd.vapp.VApp.get_vm方法的典型用法代码示例。如果您正苦于以下问题:Python VApp.get_vm方法的具体用法?Python VApp.get_vm怎么用?Python VApp.get_vm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vapp.VApp
的用法示例。
在下文中一共展示了VApp.get_vm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0030_get_non_existent_vm
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0030_get_non_existent_vm(self):
"""Test the method VApp.get_vm().
This test passes if the non-existent vm can't be successfully retrieved
by name.
"""
vapp = VApp(TestVM._client, href=TestVM._test_vapp_href)
try:
vapp.get_vm(TestVM._non_existent_vm_name)
self.fail('Should not be able to fetch vm ' +
TestVM._non_existent_vm_name)
except EntityNotFoundException:
return
示例2: test_1002_deploy_vm
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_1002_deploy_vm(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
v = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, href=v.get('href'))
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
result = vm.deploy()
# result = vm.shutdown()
task = self.client.get_task_monitor().wait_for_status(
task=result,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
示例3: test_1006_snapshot_create
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_1006_snapshot_create(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
assert vm_resource.get('name') == self.config['vcd']['vm']
vm = VM(self.client, resource=vm_resource)
task = vm.snapshot_create(memory=False, quiesce=False)
task = self.client.get_task_monitor().wait_for_status(
task=task,
timeout=120,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
示例4: test_0002_modify_memory
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0002_modify_memory(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
task = vm.modify_memory(self.config['vcd']['memory'])
task = self.client.get_task_monitor().wait_for_status(
task=task,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS,
TaskStatus.ABORTED,
TaskStatus.ERROR,
TaskStatus.CANCELED],
callback=None)
assert task.get('status') == TaskStatus.SUCCESS.value
vm.reload()
assert vm.get_memory() == self.config['vcd']['memory']
示例5: read
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def read(self, request):
logging.info("__INIT__read[VappVm]")
res = vapp_vm_pb2.ReadVappVmResult()
res.present = False
org_resource = self.client.get_org()
org = Org(self.client, resource=org_resource)
try:
vdc_resource = org.get_vdc(request.target_vdc)
vdc = VDC(
self.client, name=request.target_vdc, resource=vdc_resource)
vapp_resource = vdc.get_vapp(request.target_vapp)
vapp = VApp(
self.client, name=request.target_vapp, resource=vapp_resource)
read_vapp_vm_resp = vapp.get_vm(request.target_vm_name)
vm = VM(client=self.client, href=None, resource=read_vapp_vm_resp)
res.present = True
except Exception as e:
errmsg = '__ERROR_read[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
logging.warn(errmsg.format(request.target_vm_name, str(e)))
return res
logging.info("__DONE__read[VappVm]")
return res
示例6: test_0010_vm_setup
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0010_vm_setup(self):
"""Setup the vms required for the other tests in this module.
Create a vApp with just one vm as per the configuration stated above.
This test passes if the vApp and vm hrefs are not None.
"""
logger = Environment.get_default_logger()
TestPVDC._org_client = Environment.get_client_in_default_org(
TestPVDC._test_runner_role)
vdc = Environment.get_test_vdc(TestPVDC._org_client)
logger.debug('Creating vApp ' + TestPVDC._test_vapp_name + '.')
TestPVDC._test_vapp_href = create_customized_vapp_from_template(
client=TestPVDC._org_client,
vdc=vdc,
name=TestPVDC._test_vapp_name,
catalog_name=Environment.get_default_catalog_name(),
template_name=Environment.get_default_template_name(),
memory_size=TestPVDC._test_vapp_first_vm_memory_size,
num_cpu=TestPVDC._test_vapp_first_vm_num_cpu,
disk_size=TestPVDC._test_vapp_first_vm_first_disk_size,
vm_name=TestPVDC._test_vapp_first_vm_name,
nw_adapter_type=TestPVDC._test_vapp_first_vm_network_adapter_type)
self.assertIsNotNone(TestPVDC._test_vapp_href)
vapp = VApp(TestPVDC._org_client, href=TestPVDC._test_vapp_href)
vm_resource = vapp.get_vm(TestPVDC._test_vapp_first_vm_name)
TestPVDC._test_vapp_first_vm_href = vm_resource.get('href')
self.assertIsNotNone(TestPVDC._test_vapp_first_vm_href)
示例7: modify_cpu
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def modify_cpu(self, request):
logging.info("__INIT__modify_cpu[VappVm]")
res = vapp_vm_pb2.ModifyVappVmCPUResult()
res.modified = False
org_resource = self.client.get_org()
org = Org(self.client, resource=org_resource)
try:
vdc_resource = org.get_vdc(request.target_vdc)
vdc = VDC(
self.client, name=request.target_vdc, resource=vdc_resource)
vapp_resource = vdc.get_vapp(request.target_vapp)
vapp = VApp(
self.client, name=request.target_vapp, resource=vapp_resource)
vapp_vm_resource = vapp.get_vm(request.target_vm_name)
vm = VM(self.client, resource=vapp_vm_resource)
self.undeploy(request)
modify_cpu_response = vm.modify_cpu(request.virtual_cpus,
request.cores_per_socket)
task = self.client.get_task_monitor().wait_for_status(
task=modify_cpu_response,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
TaskStatus.CANCELED
],
callback=None)
st = task.get('status')
if st != TaskStatus.SUCCESS.value:
raise errors.VappVmModifyCPUError(
etree.tostring(task, pretty_print=True))
message = 'status : {0} '.format(st)
logging.info(message)
self.power_on(request)
res.modified = True
except Exception as e:
errmsg = '__ERROR_modify_cpu[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
logging.warn(errmsg.format(request.target_vm_name, str(e)))
self.context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
self.context.set_details(errmsg)
logging.info("__DONE__modify_cpu[VappVm]")
return res
示例8: test_0006_undeploy
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0006_undeploy(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
task = vm.undeploy()
task = self.client.get_task_monitor().wait_for_status(task)
assert task.get('status') == TaskStatus.SUCCESS.value
示例9: test_0020_get_vm
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0020_get_vm(self):
"""Test the method VApp.get_vm().
This test passes if the retrieved vm's name and href matches with the
expected values.
"""
vapp = VApp(TestVM._client, href=TestVM._test_vapp_href)
vm_resource = vapp.get_vm(TestVM._test_vapp_first_vm_name)
self.assertEqual(TestVM._test_vapp_first_vm_name,
vm_resource.get('name'))
self.assertEqual(TestVM._test_vapp_first_vm_href,
vm_resource.get('href'))
示例10: test_0010_list_vms
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def test_0010_list_vms(self):
"""Test the method VApp.get_all_vms().
This test passes if the retrieved vms contain the vm created during
setup.
"""
vapp = VApp(TestVM._client, href=TestVM._test_vapp_href)
vm_resources = vapp.get_vm(TestVM._test_vapp_first_vm_name)
for vm_resource in vm_resources:
if vm_resource.get('name') == TestVM._test_vapp_first_vm_name and\
vm_resource.get('href') == TestVM._test_vapp_first_vm_href:
return
self.fail('Retrieved vm list doesn\'t contain vm ' +
TestVM._test_vapp_first_vm_name)
示例11: power_off
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def power_off(self, request):
logging.info("__INIT__power_off[VappVm]")
res = vapp_vm_pb2.PowerOffVappVmResult()
res.powered_off = False
org_resource = self.client.get_org()
org = Org(self.client, resource=org_resource)
try:
vdc_resource = org.get_vdc(request.target_vdc)
vdc = VDC(
self.client, name=request.target_vdc, resource=vdc_resource)
vapp_resource = vdc.get_vapp(request.target_vapp)
vapp = VApp(
self.client, name=request.target_vapp, resource=vapp_resource)
vapp_vm_resource = vapp.get_vm(request.target_vm_name)
vm = VM(self.client, resource=vapp_vm_resource)
power_off_response = vm.undeploy()
task = self.client.get_task_monitor().wait_for_status(
task=power_off_response,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
TaskStatus.CANCELED
],
callback=None)
st = task.get('status')
if st != TaskStatus.SUCCESS.value:
raise errors.VappVmCreateError(
etree.tostring(task, pretty_print=True))
message = 'status : {0} '.format(st)
logging.info(message)
powered_off = True
except Exception as e:
errmsg = '__ERROR_power_off[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
logging.warn(errmsg.format(request.target_vm_name, str(e)))
logging.info("__DONE__power_off[VappVm]")
return powered_off
示例12: reset
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def reset(ctx, name, vm_names):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
vapp_resource = vdc.get_vapp(name)
vapp = VApp(client, resource=vapp_resource)
if len(vm_names) == 0:
task = vapp.power_reset()
stdout(task, ctx)
else:
for vm_name in vm_names:
vm = VM(client, resource=vapp.get_vm(vm_name))
task = vm.power_reset()
stdout(task, ctx)
except Exception as e:
stderr(e, ctx)
示例13: power_off
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def power_off(client, target_vdc, target_vapp, target_vm_name):
logging.info("__INIT__delete[VappVm]")
powered_off = False
org_resource = client.get_org()
org = Org(client, resource=org_resource)
try:
vdc_resource = org.get_vdc(target_vdc)
vdc = VDC(slef.client, name=target_vdc, resource=vdc_resource)
vapp_resource = vdc.get_vapp(target_vapp)
vapp = VApp(client, name=target_vapp, resource=vapp_resource)
vapp_vm_resource = vapp.get_vm(target_vm_name)
vm = VM(client, resource=vapp_vm_resource)
vm.power_off()
powered_off = True
except Exception as e:
error_message = '__ERROR_power_off[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'.format(
target_vm_name, str(e))
logging.warn(error_message)
return powered_off
示例14: deploy
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
def deploy(ctx, name, vm_names, power_on, force_customization):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
vapp_resource = vdc.get_vapp(name)
vapp = VApp(client, resource=vapp_resource)
if power_on is not None:
power_on = False
if force_customization is not None:
force_customization = True
if len(vm_names) == 0:
task = vapp.deploy(power_on=power_on)
stdout(task, ctx)
else:
for vm_name in vm_names:
vm = VM(client, href=vapp.get_vm(vm_name).get('href'))
vm.reload()
task = vm.deploy(
power_on=power_on, force_customization=force_customization)
stdout(task, ctx)
except Exception as e:
stderr(e, ctx)
示例15: print
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_vm [as 别名]
task_monitor = client.get_task_monitor()
print("Fetching Org...")
org_resource = client.get_org()
org = Org(client, resource=org_resource)
print("Fetching VDC...")
vdc_resource = org.get_vdc(vdc)
vdc = VDC(client, resource=vdc_resource)
print("Fetching vApp...")
vapp_resource = vdc.get_vapp(vapp)
vapp = VApp(client, resource=vapp_resource)
print("Fetching VM...")
vm_resource = vapp.get_vm(vm)
vm = VM(client, resource=vm_resource)
print("Creating Snapshot...")
snaphot_resource = vm.snapshot_create(memory=False, quiesce=False)
print("Waiting for Snapshot finish...")
task_monitor.wait_for_success(snaphot_resource)
print("Revert Back To Current Snapshot...")
vm.reload()
snaphot_resource = vm.snapshot_revert_to_current()
print("Waiting for Revert finish...")
task_monitor.wait_for_success(snaphot_resource)
print("Remove All Snapshot...")
snaphot_resource = vm.snapshot_remove_all()