网络下载的代码,因我的是pike版本,与代码的版本有区别,运行出现诸多版本问题,经调试修改代码,测试通过,记录如下:
#!/usr/bin/python
from keystoneclient.auth.identity import v3
from keystoneclient import session
from keystoneclient.v3 import client as keystoneapi
from novaclient import client as novapi
auth_url = 'http://192.168.0.100/identity/v3'
username = 'admin'
user_domain_name = 'Default'
project_name = 'admin'
project_domain_name = 'Default'
password = '****'
auth = v3.Password(auth_url=auth_url,
username=username,
password=password,
project_name=project_name,
project_domain_name=project_domain_name,
user_domain_name=user_domain_name)
sess = session.Session(auth=auth)
keystone = keystoneapi.Client(session=sess)
#print keystone.projects.list() 列出所有