Commit b5f436e8 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-user-commands' into develop

parents c3e01785 41d22b0e
......@@ -28,5 +28,6 @@ Features:
server ip attach/detach
- Implement --wait for server_create/delete/start/reboot/shutdown [#3867]
- Implement network_wait [#3862]
- Implement user_list/set/get to switch between session users [#3632, #3660]
......@@ -41,6 +41,7 @@ class AstakosClient(Client):
def __init__(self, base_url, token=None):
super(AstakosClient, self).__init__(base_url, token)
self._cache = {}
self._uuids = {}
self.log = getLogger('__name__')
def authenticate(self, token=None):
......@@ -54,8 +55,14 @@ class AstakosClient(Client):
"""
self.token = token or self.token
body = dict(auth=dict(token=dict(id=self.token)))
self._cache[self.token] = self.post('/tokens', json=body).json
return self._cache[self.token]
r = self.post('/tokens', json=body).json
uuid = r['access']['user']['id']
self._uuids[self.token] = uuid
self._cache[uuid] = r
return self._cache[uuid]
def get_token(self, uuid):
return self._cache[uuid]['access']['token']['id']
def get_services(self, token=None):
"""
......@@ -64,7 +71,7 @@ class AstakosClient(Client):
token_bu = self.token or token
token = token or self.token
try:
r = self._cache[token]
r = self._cache[self._uuids[token]]
except KeyError:
r = self.authenticate(token)
finally:
......@@ -122,7 +129,7 @@ class AstakosClient(Client):
r = []
for k, v in self._cache.items():
r.append(dict(v['access']['user']))
r[-1].update(dict(auth_token=k))
r[-1].update(dict(auth_token=self.get_token(k)))
return r
def user_info(self, token=None):
......@@ -130,7 +137,7 @@ class AstakosClient(Client):
token_bu = self.token or token
token = token or self.token
try:
r = self._cache[token]
r = self._cache[self._uuids[token]]
except KeyError:
r = self.authenticate(token)
finally:
......
......@@ -60,6 +60,13 @@ example = dict(
example0 = dict(
access=dict(
token=dict(
expires="2013-07-14T10:07:42.481134+00:00",
id="ast@k0sT0k3n==",
tenant=dict(
id="42",
name="Simple Name 0")
),
serviceCatalog=[
dict(name='service name 1', type='compute', endpoints=[
dict(versionId='v1', publicUrl='http://1.1.1.1/v1'),
......@@ -168,7 +175,7 @@ class AstakosClient(TestCase):
def test_list_users(self):
if not self.cached:
self._authenticate
self._authenticate()
FR.json = example0
self._authenticate()
r = self.client.list_users()
......
......@@ -151,7 +151,7 @@ class Image(livetest.Generic):
'size'):
self.assertTrue(term in img)
if len(img['properties']):
for interm in ('osfamily', 'users', 'root_partition'):
for interm in ('osfamily', 'root_partition'):
self.assertTrue(interm in img['properties'])
size_max = 1000000000000
r2 = self.client.list_public(filters=dict(size_max=size_max))
......@@ -181,11 +181,8 @@ class Image(livetest.Generic):
'container-format'):
self.assertTrue(term in r)
for interm in (
'KERNEL',
'OSFAMILY',
'USERS',
'GUI',
'SORTORDER',
'ROOT_PARTITION',
'OS',
'DESCRIPTION'):
......
......@@ -210,7 +210,7 @@ class Pithos(livetest.Generic):
r = self.client.account_get(show_only_shared=True)
self.assertTrue(self.c1 in [c['name'] for c in r.json])
r = self.client.account_get(until=1342609206)
r = self.client.account_get(until=1342609206.0)
self.assertTrue(len(r.json) <= fullLen)
"""Check if(un)modified_since"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment