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.
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
pip install -r requirements.txt
python setup.py install
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, user_domain_id=userDomainId, project_id=projectId, username=username, password=password) # 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: print(server) # visit API list_servers()