本文整理汇总了Python中pyvcloud.vcd.vapp.VApp.reload方法的典型用法代码示例。如果您正苦于以下问题:Python VApp.reload方法的具体用法?Python VApp.reload怎么用?Python VApp.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vapp.VApp
的用法示例。
在下文中一共展示了VApp.reload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: info
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import reload [as 别名]
def info(ctx, catalog_name, item_name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
if item_name is None:
catalog = org.get_catalog(catalog_name)
result = to_dict(catalog)
# We don't have a way to know in advance if a user has access to a
# catalog's ACL or not. So we try to retrieve it always. If the
# call fails due to permission issues, we silently eat the
# exception and exclude ACL settings from the output of the current
# command. Users who have access to ACL of the catalog will remain
# unaffected. Also any other errors/exceptions will bubble up as
# usual.
try:
access_control_settings = access_settings_to_dict(
org.get_catalog_access_settings(catalog_name))
result.update(access_control_settings)
except AccessForbiddenException as e:
pass
else:
catalog_item = org.get_catalog_item(catalog_name, item_name)
result = to_dict(catalog_item)
vapp = VApp(client, href=catalog_item.Entity.get('href'))
vapp.reload()
template = vapp_to_dict(vapp.resource)
for k, v in template.items():
result['template-%s' % k] = v
stdout(result, ctx)
except Exception as e:
stderr(e, ctx)
示例2: copy_to
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import reload [as 别名]
def copy_to(self, source_vapp_name, target_vapp_name, target_vm_name):
"""Copy VM from one vApp to another.
:param: str source vApp name
:param: str target vApp name
:param: str target VM name
:return: an object containing EntityType.TASK XML data which represents
the asynchronous task that is copying VM
:rtype: lxml.objectify.ObjectifiedElement
"""
from pyvcloud.vcd.vapp import VApp
vm_resource = self.get_resource()
resource_type = ResourceType.VAPP.value
if self.is_powered_off(vm_resource):
records1 = self.___validate_vapp_records(
vapp_name=source_vapp_name, resource_type=resource_type)
source_vapp_href = records1[0].get('href')
records2 = self.___validate_vapp_records(
vapp_name=target_vapp_name, resource_type=resource_type)
target_vapp_href = records2[0].get('href')
source_vapp = VApp(self.client, href=source_vapp_href)
target_vapp = VApp(self.client, href=target_vapp_href)
target_vapp.reload()
spec = {
'vapp': source_vapp.get_resource(),
'source_vm_name': self.get_resource().get('name'),
'target_vm_name': target_vm_name
}
return target_vapp.add_vms([spec],
deploy=False,
power_on=False,
all_eulas_accepted=True
)
else:
raise InvalidStateException("VM Must be powered off.")