代码

#Author Kang

import ssl
import pysphere
from pysphere import VIServer,MORTypes,VIProperty
from pysphere.resources import VimService_services as VI

ssl._create_default_https_context = ssl._create_unverified_context
host_ip = '10.3.151.2'
username = 'root'
passwd = 'password'

s = VIServer()
s.connect(host_ip,username,passwd)

vm1 = s.get_vm_by_name("BPM-SVN(150.35)")
vm_info = vm1.get_properties()

ip_address = vm_info.get('ip_address')
network = vm_info.get('net')
mac_address = network[0]['mac_address']
name = vm_info.get('name')
memory = vm_info.get('memory_mb')
cpu_core = vm_info.get('num_cpu')
data_store_name =  vm_info['files'][0]['name'].split()[0]

print "V_PC_IP:%s" %(str(ip_address))
print "V_PC_MAC:%s" %(str(mac_address))
print "V_PC_NAME:%s" %(str(name))
print "V_PC_NAME:%s MB" %(str(memory))
print "V_PC_CPU_Core:%s " %(str(cpu_core))
print "v_PC_StoreName:%s" %(data_store_name)

结果:
V_PC_IP:10.3.150.35
V_PC_MAC:00:50:56:80:4a:b1
V_PC_NAME:BPM-SVN(150.35)
V_PC_NAME:8192 MB
V_PC_CPU_Core:8 
v_PC_StoreName:[Datastore]