華為雲 獲取 彈性雲服務器 信息 python版本
阿新 • • 發佈:2019-02-12
pri python版本 port nts () xxxxxxxx hub con ant 華為雲 獲取 彈性雲服務器 信息
安裝SDK
SDK 下載地址 https://github.com/huaweicloud/huaweicloud-sdk-python
cd
pip install -r requirements.txt
python3.6 setup.py install
代碼
from openstack import connection # create connection username = "hequan" password = "hequan" projectId = "xxxxxxxxxxxxxxxxxxxxxxxxx" # tenant ID userDomainId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # user account ID auth_url = "https://iam.cn-north-1.myhuaweicloud.com" # endpoint url https://ecs.cn-north-1.myhuaweicloud.com conn = connection.Connection(auth_url=auth_url, user_domain_id=userDomainId, project_id=projectId, username=username, password=password) # get list of server def list_servers(): servers = conn.compute.servers(limit=1) for server in servers: print(server) if __name__ == "__main__": list_servers()
華為雲 獲取 彈性雲服務器 信息 python版本