Revision 3170076a snf-cyclades-app/synnefo/management/common.py
b/snf-cyclades-app/synnefo/management/common.py | ||
---|---|---|
44 | 44 |
from django.core.exceptions import FieldError |
45 | 45 |
|
46 | 46 |
from synnefo.api.util import validate_network_size |
47 |
from synnefo.settings import MAX_CIDR_BLOCK |
|
47 |
from synnefo.settings import (MAX_CIDR_BLOCK, CYCLADES_ASTAKOS_SERVICE_TOKEN, |
|
48 |
ASTAKOS_URL) |
|
48 | 49 |
from synnefo.logic.rapi import GanetiApiError, GanetiRapiClient |
50 |
from synnefo.lib import astakos |
|
49 | 51 |
|
50 | 52 |
|
51 | 53 |
def format_bool(b): |
... | ... | |
61 | 63 |
raise Exception("Can not parse string %s to bool" % string) |
62 | 64 |
|
63 | 65 |
|
64 |
|
|
65 | 66 |
def format_date(d): |
66 | 67 |
if not d: |
67 | 68 |
return '' |
... | ... | |
259 | 260 |
for row in table: |
260 | 261 |
print >> out, sep.join((val.rjust(width).encode('utf8') \ |
261 | 262 |
for val, width in zip(row, widths))) |
263 |
|
|
264 |
|
|
265 |
class UUIDCache(object): |
|
266 |
def __init__(self): |
|
267 |
self.users = {} |
|
268 |
|
|
269 |
def get_user(self, uuid): |
|
270 |
if not uuid in self.users: |
|
271 |
astakos_url = ASTAKOS_URL.replace("im/authenticate", |
|
272 |
"service/api/user_catalogs") |
|
273 |
self.users[uuid] = \ |
|
274 |
astakos.get_displayname(token=CYCLADES_ASTAKOS_SERVICE_TOKEN, |
|
275 |
url=astakos_url, uuid=uuid) |
|
276 |
|
|
277 |
return self.users[uuid] |
Also available in: Unified diff