本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.list_vapp_details方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.list_vapp_details方法的具体用法?Python VDC.list_vapp_details怎么用?Python VDC.list_vapp_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.list_vapp_details方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_vapps
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import list_vapp_details [as 别名]
def list_vapps(ctx, name, filter):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
result = []
records = []
if name is None:
if is_sysadmin(ctx):
resource_type = ResourceType.ADMIN_VAPP.value
else:
resource_type = ResourceType.VAPP.value
name = None
attributes = None
else:
if name is not None:
if is_sysadmin(ctx):
resource_type = ResourceType.ADMIN_VM.value
else:
resource_type = ResourceType.VM.value
if filter is None:
filter = 'containerName==' + name
attributes = [
'name', 'containerName', 'ipAddress', 'status', 'memoryMB',
'numberOfCpus'
]
else:
filter = 'name==' + name + ';' + filter
resource_type = ResourceType.ADMIN_VAPP.value
attributes = [
'isDeployed', 'isEnabled', 'memoryAllocationMB', 'name', 'numberOfCpus', 'numberOfVMs', 'ownerName',
'status', 'storageKB', 'vdcName'
]
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
records = vdc.list_vapp_details(resource_type, filter)
if len(records) == 0:
if name is None:
result = 'No vApps were found.'
else:
result = 'No vms were found.'
else:
for r in records:
result.append(
to_dict(
r, resource_type=resource_type, attributes=attributes))
stdout(result, ctx, show_id=False)
except Exception as e:
stderr(e, ctx)