1,openstack python sdk 获取token 获取租户tenants projects
#!/bin/bash export OS_PROJECT_DOMAIN_ID=default export OS_USER_DOMAIN_ID=default export OS_PROJECT_NAME=admin export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=yidesk321 export OS_AUTH_URL=http://controller-test:35357/v2.0 export OS_IMAGE_API_VERSION=2 #!/usr/bin/python from os import environ as env import keystoneclient.v2_0.client as ksclient keystone = ksclient.Client(auth_url=env[‘OS_AUTH_URL‘], username=env[‘OS_USERNAME‘], password=env[‘OS_PASSWORD‘], tenant_name=env[‘OS_TENANT_NAME‘]) print keystone.auth_token print keystone.tenants.list()
2.获取指定project 下的servers
#!/usr/bin/env python #import os from credentials import get_nova_credentials_v2 from novaclient.client import Client credentials = get_nova_credentials_v2() nova_client = Client(**credentials) print(nova_client.servers.list())
openstack python sdk list tenants get token get servers
原文:http://www.cnblogs.com/ruiy/p/5106585.html