从代码角度来看看
class RequestContext(object):
def __init__(self, user_id, project_id, is_admin=None, read_deleted="no",
roles=None, remote_address=None, timestamp=None,
request_id=None, auth_token=None, overwrite=True,
quota_class=None, user_name=None, project_name=None,
service_catalog=None, instance_lock_checked=False, **kwargs):
if kwargs:
LOG.warn(_('Arguments dropped when creating context: %s') %
str(kwargs))
self.user_id = user_id
self.project_id = project_id
self.roles = roles or []
self.read_deleted = read_deleted
self.remote_address = remote_address
if not timestamp:
timestamp = timeutils.utcnow()
if isinstance(timestamp, basestring):
timestamp = timeutils.parse_strtime(timestamp)
self.timestamp = timestamp
if not request_id:
request_id = generate_request_id()
self.request_id = request_id
self.auth_token = auth_token
if service_catalog:
self.service_catalog = [s for s in service_catalog
if s.get('type') in ('volume')]
else:
self.service_catalog = []
self.instance_lock_checked = instance_lock_checked
self.quota_class = quota_class
self.user_name = user_name
self.project_name = project_name
self.is_admin = is_admin
if self.is_admin is None:
self.is_admin = policy.check_is_admin(self)
if overwrite or not hasattr(local.store, 'context'):
self.update_store()
我们在看看在这里context中的信息具体值都是什么,会更加有助我们理解context,调试运行一下:
如下面参数:
user_id、project_id、roles。。。。。等等下面缺少哪个参数都会报上面错误。所以楼主根据自己的实际操作检查下。
user_id = afc380206e2549ad930396d9050d20cf
project_id = 0e492e86f22e4d19bd523f1e7ca64566
roles = [u'admin', u'KeystoneAdmin', u'KeystoneServiceAdmin']
read_deleted = no
remote_address = 172.21.6.145
timestamp = 2013-06-23 16:36:37.399405
request_id = req-f0255b14-833d-4fff-b973-23c35f70ddda
auth_token = 7e7bb3cf84ab43269010bb55410064b3
service_catalog = [{u'endpoints': [{u'adminURL': u'http://172.21.5.161:8776/v1/0e492e86f22e4d19bd523f1e7ca64566', u'region': u'RegionOne', u'id': u'753a1ad55e91469794e2eb7ac4c3df92', u'internalURL': u'http://172.21.5.161:8776/v1/0e492e86f22e4d19bd523f1e7ca64566', u'publicURL': u'http://172.21.6.145:8776/v1/0e492e86f22e4d19bd523f1e7ca64566'}], u'endpoints_links': [], u'type': u'volume', u'name': u'cinder'}]
instance_lock_checked = False
quota_class = None
user_name = admin
project_name = admin
is_admin = True
|