1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. Python
  6. Getting Started

Getting Started


  1. You have obtained required API documents.

    Log in to the following website to obtain the API documents:


    With these documents, you can obtain the OpenStack APIs and related parameters supported by the cloud platform.

  2. You have obtained a cloud platform account and provisioned all required services.
  3. You have installed Python, pip, and git. Python SDK is applicable to Python 2.7.x.

SDK Acquisition and Installation

You can download the source code from the GitHub website to install the SDK.

Download the code to a proper position of your project. Use pythonsdk as an example. Run the following commands to download the source code and install the SDK:

git clone https://github.com/huaweicloudsdk/sdk-python pythonsdk

cd pythonsdk

pip install -r requirements.txt

python setup.py install

How to Use

Set parameters, create connections, and invoke the SDK to access the service API.

from openstack import connection

# create connection
username = "replace-with-your-username"
password = "replace-with-your-password"
projectId = "replace-with-your-projectId"    # tenant ID
userDomainId = "replace-with-your-domainId"    # user account ID
auth_url = " https://iam.example.com/v3"    # endpoint url
conn = connection.Connection(auth_url=auth_url,

# set parameters
limit = 5

# define function for listing servers
def list_servers():
    # get server list with params
    servers = conn.compute.servers(limit=limit)
    # iterate servers list
    for server in servers:

# visit API
  • example in the preceding code is in the Region.Cloud platform domain name format. For details about the parameters, see here.