Openstack Python API Learning Documentation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.