Revision 5ba38e8a snf-cyclades-app/synnefo/ui/settings.py
b/snf-cyclades-app/synnefo/ui/settings.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
# |
34 | 34 |
|
35 |
import logging |
|
35 | 36 |
import synnefo.cyclades_settings as cyclades |
36 |
from synnefo.cyclades_settings import cyclades_services |
|
37 |
|
|
38 |
from django.conf import settings |
|
39 |
from astakosclient import AstakosClient |
|
40 |
|
|
41 |
from synnefo import cyclades_settings |
|
37 | 42 |
|
38 | 43 |
from synnefo.lib import join_urls |
39 | 44 |
from synnefo.lib.services import get_public_endpoint as endpoint |
40 | 45 |
|
41 | 46 |
|
47 |
logger = logging.getLogger(__name__) |
|
48 |
|
|
42 | 49 |
BASE_PATH = cyclades.BASE_PATH |
43 | 50 |
if not BASE_PATH.startswith("/"): |
44 | 51 |
BASE_PATH = "/" + BASE_PATH |
45 | 52 |
|
53 |
cyclades_services = cyclades_settings.cyclades_services |
|
54 |
|
|
46 | 55 |
GLANCE_URL = endpoint(cyclades_services, 'image', 'v1.0').rstrip('/') |
47 | 56 |
COMPUTE_URL = endpoint(cyclades_services, 'compute', 'v2.0').rstrip('/') |
48 | 57 |
NETWORK_URL = endpoint(cyclades_services, 'network', 'v2.0').rstrip('/') |
... | ... | |
53 | 62 |
USER_CATALOG_URL = join_urls(ACCOUNT_URL, 'user_catalogs') |
54 | 63 |
FEEDBACK_URL = join_urls(ACCOUNT_URL, 'feedback') |
55 | 64 |
|
56 |
LOGIN_URL = join_urls('/', cyclades.ASTAKOS_UI_PROXY_PATH, 'login') |
|
65 |
|
|
66 |
class LazyAstakosUrl(object): |
|
67 |
def __init__(self, endpoints_name): |
|
68 |
self.endpoints_name = endpoints_name |
|
69 |
|
|
70 |
def __str__(self): |
|
71 |
if not hasattr(self, 'str'): |
|
72 |
try: |
|
73 |
astakos_client = \ |
|
74 |
AstakosClient(cyclades_settings.SERVICE_TOKEN, |
|
75 |
settings.ASTAKOS_AUTH_URL) |
|
76 |
self.str = getattr(astakos_client, self.endpoints_name) |
|
77 |
except Exception, e: |
|
78 |
logger.exception(e) |
|
79 |
return '' |
|
80 |
return self.str |
|
81 |
|
|
82 |
LOGIN_URL = join_urls(str(LazyAstakosUrl('ui_url')), 'login') |
|
57 | 83 |
LOGOUT_REDIRECT = LOGIN_URL |
Also available in: Unified diff