Openstack Python API Learning Documentation
Reprint Please specify http://www.cnblogs.com/juandx/p/4953191.html
Because of the need to learn to call OpenStack using the API interface, the previous article wrote some methods of using OpenStack's pure API calls.
But OpenStack also provides a better Python API that just needs Python's package and feels better to use.
For compute API, the package is placed in the/usr/lib/python2.7/site-packages/novaclient/directory, so it is fine to look directly at the code.
The following demo uses API to fetch information:
Import novaclient.v2.client as Nvclient #导入包 # here is the username, password, tenant name, URL. Basically deployed over OpenStack can understand what it is, the user's username and password, and the name of the project you created Nova = nvclient. Client (' username ', ' password ', ' project_name ', ' http://controller_ip:5000/v2.0 ') # not 2 or 3,just 2.0,and port was not 35357 print nova.servers.list () #得到所有虚机的信息print nova.flavors.list () #得到虚拟机模板的信息print nova.images.list () # Get information on all mirrors
Reference Documentation:
OpenStack python api:http://developer.openstack.org/api-ref.html http://docs.openstack.org/developer/ python-novaclient/
https://albertomolina.wordpress.com/2013/11/20/how-to-launch-an-instance-on-openstack-iii-python-novaclient-library/
Openstack Python API Learning Documentation