使用开源项目开发vcenter客户端

参考设计文档
目前发现两个python sdk:oslo.vmware和pyvmimo

VMware SDK/API(6.0):  link

oslo.vmware安装方法(liberty)

1,git clone https://github.com/openstack/oslo.vmware --branch stable/liberty
2,安装oslo.vmware(开发者模式)
   cd oslo.vmware
   pip install -r requirements.txt -e .

安装完毕后,新建一个文件去测试调用接口(期间会报出证书的警告,忽略)

from oslo_vmware import api 
from oslo_vmware import vim_util

# Get a handle to a vSphere API session
session = api.VMwareAPISession(
            '200.21.101.12',
            '[email protected]',
            'Root123.',
             1,  
             0.1)

# Get MO of type "HostSystem"
result1 = session.invoke_api(
    vim_util,                    
    'get_objects',    
    session.vim, 'HostSystem', 100) 
print result1
print "="*50

# Get information by properties of MO object
rep2 = session.invoke_api(vim_util,'get_object_properties_dict',session.vim,
result1.objects[0].obj,'vm')
print "*"*50
print rep2


你可能感兴趣的:(openstack)