【发布时间】:2012-05-25 16:50:08
【问题描述】:
特别是,我正在使用 python 和 vmware vsphere 来实现虚拟机的创建/开机以及类似的自动化操作。我知道如何打印虚拟机的属性,但是我仍然无法调用任何方法,因为我不知道如何。
这是我遇到问题的代码 sn-p:
for vm in virtual_machines:
print "VM: "+vm['name']+" ("+vm['runtime.powerState']+") ",
if hasattr(vm['guest'],'ipAddress'):
print vm['guest'].ipAddress,
if vm['runtime.powerState'] == 'poweredOn':
print 'RAM: '+str(vm['summary.quickStats'].distributedMemoryEntitlement)+'MB, CPU: '+str(vm['summary.quickStats'].distributedCpuEntitlement)+'MHz',
if vm['name'] == 'VIRT_VZ_114':
# This is the trouble maker, it says types mismatch "suds.TypeNotFound: Type not found: 'guest'"
client.service.PowerOnVM_Task(mo_VirtualMachine,vm)
print
如何正确调用方法?
【问题讨论】:
-
mo_VirtualMachine是什么类型的对象?PowerOnMVM_Task的 WSDL 签名是什么? -
哦,mo_VirtualMachine 忘记删了,应该是托管对象引用
标签: python api vmware suds vsphere