概览

概览

OpenStack提供了四种通过Python与API交互的选项,分别针对不同的用户。

  • OpenStack SDK
  • shade
  • 每个工程的客户端库
  • 通过keystoneauth直接发送的REST调用

你应该熟悉:

  • REST服务
  • HTTP/1.1
  • JSON及数据序列化格式

OpenStack SDK

你可以使用`OpenStack Python Software Development Kit (SDK) <https://pypi.python.org/pypi/openstacksdk>`_编写自动化Python脚本,用于创建和管理你的Openstack云环境中的资源。SDK实现了Python绑定OpenStack API,这能够让你使用Python实现自动化任务通过调用Python对象,而不用直接调用REST接口。

新用户应默认采用OpenStack SDK进行编码。

shade

shade is an abstraction library focused on hiding implementation differences between OpenStack clouds. While the OpenStack SDK presents a clean object interface to the underlying REST APIs, shade hides them if doing so is advantageous. If you plan on running the same Python program against many OpenStack clouds, you may want to use shade - but if you need to access any features of a cloud that do not have a cloud-neutral abstraction mapping, you will be unable to do so with shade.

每个工程的客户端库

每个OpenStack项目都提供了REST API的客户端。除非由于某些原因没有其他选择,应避免使用每个项目的库。

通过keystoneauth直接发送的REST调用

All of OpenStack’s APIs are actually REST APIs. The keystoneauth library provides an object that looks very much like a Session object from the Python requests library that handles all of the authentication for you. If you are more comfortable just dealing with REST or if there is a feature implemented in your cloud that has not seen support in any of the libraries yet, this option is for you.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.