本文整理汇总了Python中pyvcloud.vcd.vapp.VApp.get_all_vms方法的典型用法代码示例。如果您正苦于以下问题:Python VApp.get_all_vms方法的具体用法?Python VApp.get_all_vms怎么用?Python VApp.get_all_vms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vapp.VApp
的用法示例。
在下文中一共展示了VApp.get_all_vms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_vms
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_all_vms [as 别名]
def list_vms(self):
vapp_name = self.params.get('vapp_name')
vapp_resource = self.vdc.get_vapp(vapp_name)
vapp = VApp(self.client, name=vapp_name, resource=vapp_resource)
response = dict()
response['msg'] = []
for vm in vapp.get_all_vms():
vm_details = dict()
vm_details['name'] = vm.get('name')
vm_details['status'] = VM_STATUSES[vm.get('status')]
vm_details['deployed'] = vm.get('deployed')=='true'
try:
vm_details['ip_address'] = vapp.get_primary_ip(vm.get('name'))
except:
vm_details['ip_address'] = None
response['msg'].append(vm_details)
return response
示例2: list_vms
# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import get_all_vms [as 别名]
def list_vms(self):
params = self.params
catalog_name = params.get('catalog_name')
item_name = params.get('item_name')
response = dict()
result = list()
response['changed'] = False
catalog_item = self.org.get_catalog_item(catalog_name, item_name)
vapp_template_resource = self.client.get_resource(
catalog_item.Entity.get('href'))
vapp_template = VApp(self.client, name=item_name, resource=vapp_template_resource)
for vm in vapp_template.get_all_vms():
result.append(vm.get('name'))
response['msg'] = result
response['changed'] = False
return response