标签:vsphere imp war spec size com tom 大小 hot
通过集群过滤虚机>>> from com.vmware.vcenter_client import Cluster
>>> cluster_id = client.vcenter.Cluster.list(Cluster.FilterSpec(names={‘SHVSAN-Cluster01‘}))[0].cluster
>>> cluster_id
‘domain-c647‘
>>> client.vcenter.VM.list(client.vcenter.VM.FilterSpec(clusters={cluster_id}))
[Summary(vm=‘vm-1937‘, name=‘rdshiot02‘, power_state=State(string=‘POWERED_ON‘), cpu_count=12, memory_size_mib=32768), Summary(vm=‘vm-1939‘, name=‘rdshiot03‘, power_state=State(string=‘POWERED_ON‘), cpu_count=12, memory_size_mib=32768)]
通过文件夹过滤虚机
>>> from com.vmware.vcenter_client import Folder
>>> filter_spec = Folder.FilterSpec(type=Folder.Type.VIRTUAL_MACHINE, names={‘Workspace of External Subnet‘})
>>> filter_spec
FilterSpec(folders=None, names={‘Workspace of External Subnet‘}, type=Type(string=‘VIRTUAL_MACHINE‘), parent_folders=None, datacenters=None)
>>> folder_id = client.vcenter.Folder.list(filter_spec)[0].folder
>>> folder_id
‘group-v368‘
>>> client.vcenter.VM.list(client.vcenter.VM.FilterSpec(folders={folder_id}))
[Summary(vm=‘vm-1285‘, name=‘shnode02‘, power_state=State(string=‘POWERED_ON‘), cpu_count=8, memory_size_mib=12288), Summary(vm=‘vm-16136‘, name=‘shoth02‘, power_state=State(string=‘POWERED_ON‘), cpu_count=8, memory_size_mib=32768)]
vsphere-automation-Python-sdk实践:过滤虚机
标签:vsphere imp war spec size com tom 大小 hot
原文地址:https://blog.51cto.com/sampsondotqiu/2460185