prevent keyerrors when accessing optional keys

You used to have these in the token, why were they removed and then
subsequently grabbed at? The change that added these doesn't work against
keystone, btw, so I'm surprised it got in, these dict keys are not
required to be in the return from service_catalog.get_token() and
adding them as properties is only going to make matters worse as people
rarely think about having None attributes.

Change-Id: I695bbd6730d25d8db3a25cea81e3ffb0ef289bbb
This commit is contained in:
termie
2012-03-07 11:55:35 -08:00
parent 5c5918baac
commit 6ce6ebbc96

View File

@@ -116,8 +116,10 @@ class Client(client.HTTPClient):
sc = self.service_catalog.get_token() sc = self.service_catalog.get_token()
self.auth_token = sc['id'] self.auth_token = sc['id']
# Save these since we have them and they'll be useful later # Save these since we have them and they'll be useful later
self.auth_tenant_id = sc['tenant_id'] # NOTE(termie): these used to be in the token and then were removed
self.auth_user_id = sc['user_id'] # ... why?
self.auth_tenant_id = sc.get('tenant_id')
self.auth_user_id = sc.get('user_id')
except KeyError: except KeyError:
raise exceptions.AuthorizationFailure() raise exceptions.AuthorizationFailure()