Revision e407f159
b/docs/quick-install-admin-guide.rst | ||
---|---|---|
1858 | 1858 |
CYCLADES_BASE_URL = 'https://node1.example.com/cyclades' |
1859 | 1859 |
ASTAKOS_BASE_URL = 'https://node1.example.com/astakos' |
1860 | 1860 |
|
1861 |
# Set to False if astakos & cyclades are on the same host |
|
1862 |
CYCLADES_PROXY_USER_SERVICES = False |
|
1863 |
|
|
1864 | 1861 |
CYCLADES_SERVICE_TOKEN = 'cyclades_service_token22w' |
1865 | 1862 |
|
1866 | 1863 |
The ``ASTAKOS_BASE_URL`` denotes the Astakos endpoint for Cyclades, |
b/snf-common/synnefo/settings/test.py | ||
---|---|---|
56 | 56 |
|
57 | 57 |
ASTAKOS_IM_MODULES = ['local', 'shibboleth'] |
58 | 58 |
|
59 |
CYCLADES_PROXY_USER_SERVICES = False |
|
60 | 59 |
PITHOS_PROXY_USER_SERVICES = False |
61 | 60 |
|
62 | 61 |
ASTAKOS_BASE_URL = 'http://accounts.example.synnefo.org/astakos/' |
62 |
ASTAKOS_AUTH_URL = 'http://accounts.example.synnefo.org/astakos/identity/v2.0/' |
|
63 | 63 |
COMPUTE_BASE_URL = 'http://compute.example.synnefo.org/cyclades/' |
64 | 64 |
PITHOS_BASE_URL = 'http://storage.example.synnefo.org/pithos/' |
65 | 65 |
|
b/snf-cyclades-app/conf/20-snf-cyclades-app-api.conf | ||
---|---|---|
82 | 82 |
#MAX_PERSONALITY_SIZE = 10240 |
83 | 83 |
# |
84 | 84 |
# |
85 |
## Top-level URL of the astakos instance to be used for user management
|
|
86 |
#ASTAKOS_BASE_URL = 'https://accounts.example.synnefo.org/'
|
|
85 |
## Authentication URL of the astakos instance to be used for user management
|
|
86 |
#ASTAKOS_AUTH_URL = 'https://accounts.example.synnefo.org/identity/v2.0/'
|
|
87 | 87 |
# |
88 | 88 |
## Key for password encryption-decryption. After changing this setting, synnefo |
89 | 89 |
## will be unable to decrypt all existing Backend passwords. You will need to |
... | ... | |
97 | 97 |
## using a user uuid) |
98 | 98 |
#CYCLADES_SERVICE_TOKEN = '' |
99 | 99 |
|
100 |
# Let cyclades proxy user specific api calls to astakos, via self served |
|
101 |
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the |
|
102 |
# same machine. |
|
103 |
#CYCLADES_PROXY_USER_SERVICES = True |
|
100 |
## PROXY Astakos services under the following path |
|
101 |
#CYCLADES_PROXY_PREFIX = '_astakos' |
|
104 | 102 |
|
105 | 103 |
# Tune the size of the http connection pool to astakos. |
106 | 104 |
#CYCLADES_ASTAKOSCLIENT_POOLSIZE = 50 |
b/snf-cyclades-app/synnefo/api/management/commands/network-list.py | ||
---|---|---|
36 | 36 |
from snf_django.management.commands import ListCommand |
37 | 37 |
from synnefo.db.models import Network |
38 | 38 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
39 |
ASTAKOS_BASE_URL)
|
|
39 |
ASTAKOS_AUTH_URL)
|
|
40 | 40 |
|
41 | 41 |
from logging import getLogger |
42 | 42 |
log = getLogger(__name__) |
... | ... | |
63 | 63 |
object_class = Network |
64 | 64 |
deleted_field = "deleted" |
65 | 65 |
user_uuid_field = "userid" |
66 |
astakos_url = ASTAKOS_BASE_URL
|
|
66 |
astakos_auth_url = ASTAKOS_AUTH_URL
|
|
67 | 67 |
astakos_token = ASTAKOS_TOKEN |
68 | 68 |
|
69 | 69 |
def get_machines(network): |
b/snf-cyclades-app/synnefo/api/management/commands/server-inspect.py | ||
---|---|---|
41 | 41 |
from synnefo.management.common import Omit |
42 | 42 |
from synnefo.management import common |
43 | 43 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
44 |
ASTAKOS_BASE_URL)
|
|
44 |
ASTAKOS_AUTH_URL)
|
|
45 | 45 |
|
46 | 46 |
|
47 | 47 |
# Fields to print from a gnt-instance info |
... | ... | |
82 | 82 |
|
83 | 83 |
displayname = options['displayname'] |
84 | 84 |
|
85 |
ucache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN)
|
|
85 |
ucache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
|
|
86 | 86 |
|
87 | 87 |
try: |
88 | 88 |
image = common.get_image(vm.imageid, vm.userid)['name'] |
b/snf-cyclades-app/synnefo/api/management/commands/server-list.py | ||
---|---|---|
38 | 38 |
from synnefo.management.common import get_backend |
39 | 39 |
from synnefo.api.util import get_image |
40 | 40 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
41 |
ASTAKOS_BASE_URL)
|
|
41 |
ASTAKOS_AUTH_URL)
|
|
42 | 42 |
from logging import getLogger |
43 | 43 |
log = getLogger(__name__) |
44 | 44 |
|
... | ... | |
74 | 74 |
object_class = VirtualMachine |
75 | 75 |
deleted_field = "deleted" |
76 | 76 |
user_uuid_field = "userid" |
77 |
astakos_url = ASTAKOS_BASE_URL
|
|
77 |
astakos_auth_url = ASTAKOS_AUTH_URL
|
|
78 | 78 |
astakos_token = ASTAKOS_TOKEN |
79 | 79 |
|
80 | 80 |
def get_public_ip(vm): |
b/snf-cyclades-app/synnefo/api/management/commands/server-show.py | ||
---|---|---|
37 | 37 |
get_image) |
38 | 38 |
from snf_django.lib.astakos import UserCache |
39 | 39 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
40 |
ASTAKOS_BASE_URL)
|
|
40 |
ASTAKOS_AUTH_URL)
|
|
41 | 41 |
from snf_django.management import utils |
42 | 42 |
|
43 | 43 |
|
... | ... | |
61 | 61 |
image_name = "None" |
62 | 62 |
image = '%s (%s)' % (imageid, image_name) |
63 | 63 |
|
64 |
usercache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN)
|
|
64 |
usercache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
|
|
65 | 65 |
kv = { |
66 | 66 |
'id': server.id, |
67 | 67 |
'name': server.name, |
b/snf-cyclades-app/synnefo/app_settings/default/api.py | ||
---|---|---|
81 | 81 |
MAX_PERSONALITY_SIZE = 10240 |
82 | 82 |
|
83 | 83 |
|
84 |
# Top-level URL of the astakos instance to be used for user management
|
|
85 |
ASTAKOS_BASE_URL = 'https://accounts.example.synnefo.org/'
|
|
84 |
# Authentication URL of the astakos instance to be used for user management
|
|
85 |
ASTAKOS_AUTH_URL = 'https://accounts.example.synnefo.org/identity/v2.0'
|
|
86 | 86 |
|
87 | 87 |
# Tune the size of the Astakos http client connection pool |
88 | 88 |
# This limit the number of concurrent requests to Astakos. |
... | ... | |
100 | 100 |
# using a user uuid) |
101 | 101 |
CYCLADES_SERVICE_TOKEN = '' |
102 | 102 |
|
103 |
# Let cyclades proxy user specific api calls to astakos, via self served |
|
104 |
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the |
|
105 |
# same machine. |
|
106 |
CYCLADES_PROXY_USER_SERVICES = True |
|
107 |
|
|
108 | 103 |
# Template to use to build the FQDN of VMs. The setting will be formated with |
109 | 104 |
# the id of the VM. If set to 'None' the first public IPv4 or IPv6 address |
110 | 105 |
# of the VM will be used. |
b/snf-cyclades-app/synnefo/app_settings/urls.py | ||
---|---|---|
40 | 40 |
from snf_django.lib.api.urls import api_patterns |
41 | 41 |
from synnefo.cyclades_settings import ( |
42 | 42 |
BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX, |
43 |
PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, ASTAKOS_BASE_URL, |
|
44 |
USERDATA_PREFIX, ADMIN_PREFIX, BASE_ASTAKOS_PROXY_PATH, |
|
45 |
ASTAKOS_ACCOUNTS_PREFIX, ASTAKOS_VIEWS_PREFIX, PROXY_USER_SERVICES, |
|
43 |
PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, |
|
44 |
USERDATA_PREFIX, ADMIN_PREFIX, |
|
45 |
ASTAKOS_AUTH_PROXY_PATH, ASTAKOS_AUTH_URL, |
|
46 |
ASTAKOS_ACCOUNT_PROXY_PATH, ASTAKOS_ACCOUNT_URL, |
|
47 |
ASTAKOS_UI_PROXY_PATH, ASTAKOS_UI_URL, |
|
46 | 48 |
cyclades_services) |
47 | 49 |
|
48 | 50 |
from functools import partial |
... | ... | |
56 | 58 |
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'admin') |
57 | 59 |
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_userdata') |
58 | 60 |
|
59 |
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH, |
|
60 |
target_base=ASTAKOS_BASE_URL) |
|
61 |
|
|
62 | 61 |
cyclades_patterns = api_patterns( |
63 | 62 |
'', |
64 | 63 |
(prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')), |
... | ... | |
79 | 78 |
(prefix_pattern(BASE_PATH), include(cyclades_patterns)), |
80 | 79 |
) |
81 | 80 |
|
82 |
if PROXY_USER_SERVICES: |
|
83 |
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH, |
|
84 |
target_base=ASTAKOS_BASE_URL) |
|
85 | 81 |
|
86 |
proxy_patterns = patterns(
|
|
87 |
'',
|
|
88 |
(prefix_pattern(ASTAKOS_VIEWS_PREFIX), astakos_proxy),
|
|
89 |
)
|
|
90 |
proxy_patterns += api_patterns(
|
|
91 |
'',
|
|
92 |
(r'^login/?$', astakos_proxy),
|
|
93 |
(r'^feedback/?$', astakos_proxy),
|
|
94 |
(r'^user_catalogs/?$', astakos_proxy),
|
|
95 |
(prefix_pattern(ASTAKOS_ACCOUNTS_PREFIX), astakos_proxy),
|
|
96 |
) |
|
82 |
# --------------------------------------
|
|
83 |
# PROXY settings
|
|
84 |
astakos_auth_proxy = \
|
|
85 |
partial(proxy, proxy_base=ASTAKOS_AUTH_PROXY_PATH,
|
|
86 |
target_base=ASTAKOS_AUTH_URL)
|
|
87 |
astakos_account_proxy = \
|
|
88 |
partial(proxy, proxy_base=ASTAKOS_ACCOUNT_PROXY_PATH,
|
|
89 |
target_base=ASTAKOS_ACCOUNT_URL)
|
|
90 |
astakos_ui_proxy = \
|
|
91 |
partial(proxy, proxy_base=ASTAKOS_UI_PROXY_PATH,
|
|
92 |
target_base=ASTAKOS_UI_URL)
|
|
97 | 93 |
|
98 |
urlpatterns += patterns( |
|
99 |
'', |
|
100 |
(prefix_pattern(BASE_ASTAKOS_PROXY_PATH), include(proxy_patterns)), |
|
101 |
) |
|
94 |
urlpatterns += api_patterns( |
|
95 |
'', |
|
96 |
(prefix_pattern(ASTAKOS_AUTH_PROXY_PATH), astakos_auth_proxy), |
|
97 |
(prefix_pattern(ASTAKOS_ACCOUNT_PROXY_PATH), astakos_account_proxy), |
|
98 |
) |
|
99 |
urlpatterns += patterns( |
|
100 |
'', |
|
101 |
(prefix_pattern(ASTAKOS_UI_PROXY_PATH), astakos_ui_proxy), |
|
102 |
) |
|
102 | 103 |
|
104 |
# -------------------------------------- |
|
103 | 105 |
# set utility redirects |
104 | 106 |
extend_with_root_redirects(urlpatterns, cyclades_services, 'cyclades_ui', |
105 | 107 |
BASE_PATH) |
b/snf-cyclades-app/synnefo/cyclades_settings.py | ||
---|---|---|
36 | 36 |
from synnefo.util.keypath import get_path, set_path |
37 | 37 |
from synnefo.api.services import cyclades_services as vanilla_cyclades_services |
38 | 38 |
from synnefo.lib.services import fill_endpoints |
39 |
from astakosclient import astakos_services as vanilla_astakos_services
|
|
39 |
from astakosclient import AstakosClient
|
|
40 | 40 |
|
41 | 41 |
from copy import deepcopy |
42 | 42 |
|
43 | 43 |
|
44 |
# -------------------------------------------------------------------- |
|
44 | 45 |
# Process Cyclades settings |
45 | 46 |
|
46 | 47 |
BASE_URL = getattr(settings, 'CYCLADES_BASE_URL', |
47 | 48 |
'https://compute.example.synnefo.org/compute/') |
48 | 49 |
BASE_HOST, BASE_PATH = parse_base_url(BASE_URL) |
50 |
SERVICE_TOKEN = getattr(settings, 'CYCLADES_SERVICE_TOKEN', "") |
|
49 | 51 |
|
50 | 52 |
CUSTOMIZE_SERVICES = getattr(settings, 'CYCLADES_CUSTOMIZE_SERVICES', ()) |
51 | 53 |
cyclades_services = deepcopy(vanilla_cyclades_services) |
... | ... | |
64 | 66 |
COMPUTE_ROOT_URL = join_urls(BASE_URL, COMPUTE_PREFIX) |
65 | 67 |
|
66 | 68 |
|
69 |
# -------------------------------------------------------------------- |
|
67 | 70 |
# Process Astakos settings |
68 | 71 |
|
69 |
ASTAKOS_BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL', |
|
70 |
'https://accounts.example.synnefo.org/astakos/') |
|
71 |
ASTAKOS_BASE_HOST, ASTAKOS_BASE_PATH = parse_base_url(ASTAKOS_BASE_URL) |
|
72 |
|
|
73 |
# Patch astakosclient directly, otherwise it will not see any customization |
|
74 |
#astakos_services = deepcopy(vanilla_astakos_services) |
|
75 |
CUSTOMIZE_ASTAKOS_SERVICES = \ |
|
76 |
getattr(settings, 'CYCLADES_CUSTOMIZE_ASTAKOS_SERVICES', ()) |
|
77 |
|
|
78 |
astakos_services = deepcopy(vanilla_astakos_services) |
|
79 |
fill_endpoints(astakos_services, ASTAKOS_BASE_URL) |
|
80 |
for path, value in CUSTOMIZE_ASTAKOS_SERVICES: |
|
81 |
set_path(astakos_services, path, value, createpath=True) |
|
82 |
|
|
83 |
ASTAKOS_ACCOUNTS_PREFIX = get_path(astakos_services, 'astakos_account.prefix') |
|
84 |
ASTAKOS_VIEWS_PREFIX = get_path(astakos_services, 'astakos_ui.prefix') |
|
85 |
ASTAKOS_KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_identity.prefix') |
|
86 |
|
|
87 |
|
|
88 |
# Proxy Astakos settings |
|
89 |
|
|
90 |
BASE_ASTAKOS_PROXY_PATH = getattr(settings, |
|
91 |
'CYCLADES_BASE_ASTAKOS_PROXY_PATH', |
|
92 |
ASTAKOS_BASE_PATH) |
|
93 |
BASE_ASTAKOS_PROXY_PATH = join_urls(BASE_PATH, BASE_ASTAKOS_PROXY_PATH) |
|
94 |
BASE_ASTAKOS_PROXY_PATH = BASE_ASTAKOS_PROXY_PATH.strip('/') |
|
95 |
|
|
96 |
PROXY_USER_SERVICES = getattr(settings, 'CYCLADES_PROXY_USER_SERVICES', True) |
|
72 |
ASTAKOS_AUTH_URL = getattr( |
|
73 |
settings, 'ASTAKOS_AUTH_URL', |
|
74 |
'https://accounts.example.synnefo.org/astakos/identity/v2.0/') |
|
75 |
|
|
76 |
|
|
77 |
# -------------------------------------- |
|
78 |
# Define a LazyAstakosUrl |
|
79 |
class LazyAstakosUrl(object): |
|
80 |
def __init__(self, endpoints_name): |
|
81 |
self.endpoints_name = endpoints_name |
|
82 |
|
|
83 |
def __str__(self): |
|
84 |
if not hasattr(self, 'str'): |
|
85 |
try: |
|
86 |
astakos_client = \ |
|
87 |
AstakosClient(SERVICE_TOKEN, ASTAKOS_AUTH_URL) |
|
88 |
self.str = getattr(astakos_client, self.endpoints_name) |
|
89 |
except: |
|
90 |
return None |
|
91 |
return self.str |
|
92 |
|
|
93 |
# -------------------------------------- |
|
94 |
# Define ASTAKOS_UI_URL and ASTAKOS_ACCOUNT_URL as LazyAstakosUrl |
|
95 |
ASTAKOS_ACCOUNT_URL = LazyAstakosUrl('account_url') |
|
96 |
ASTAKOS_UI_URL = LazyAstakosUrl('ui_url') |
|
97 |
|
|
98 |
# -------------------------------------- |
|
99 |
# Define Astakos prefixes |
|
100 |
ASTAKOS_PROXY_PREFIX = getattr(settings, 'CYCLADES_PROXY_PREFIX', '_astakos') |
|
101 |
ASTAKOS_AUTH_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'identity') |
|
102 |
ASTAKOS_ACCOUNT_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'account') |
|
103 |
ASTAKOS_UI_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'ui') |
|
104 |
|
|
105 |
# -------------------------------------- |
|
106 |
# Define Astakos proxy paths |
|
107 |
ASTAKOS_AUTH_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_AUTH_PREFIX) |
|
108 |
ASTAKOS_ACCOUNT_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_ACCOUNT_PREFIX) |
|
109 |
ASTAKOS_UI_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_UI_PREFIX) |
b/snf-cyclades-app/synnefo/helpdesk/tests.py | ||
---|---|---|
56 | 56 |
def __init__(*args, **kwargs): |
57 | 57 |
pass |
58 | 58 |
|
59 |
def get_username(self, token, uuid):
|
|
59 |
def get_username(self, uuid): |
|
60 | 60 |
try: |
61 | 61 |
return USERS_UUIDS.get(uuid)['displayname'] |
62 | 62 |
except TypeError: |
63 | 63 |
return None |
64 | 64 |
|
65 |
def get_uuid(self, token, display_name):
|
|
65 |
def get_uuid(self, display_name): |
|
66 | 66 |
try: |
67 | 67 |
return USERS_DISPLAYNAMES.get(display_name)['uuid'] |
68 | 68 |
except TypeError: |
b/snf-cyclades-app/synnefo/helpdesk/views.py | ||
---|---|---|
114 | 114 |
raise Http404 |
115 | 115 |
|
116 | 116 |
token = get_token_from_cookie(request, AUTH_COOKIE_NAME) |
117 |
astakos.get_user(request, settings.ASTAKOS_BASE_URL,
|
|
117 |
astakos.get_user(request, settings.ASTAKOS_AUTH_URL,
|
|
118 | 118 |
fallback_token=token, logger=logger) |
119 | 119 |
if hasattr(request, 'user') and request.user: |
120 | 120 |
groups = request.user.get('groups', []) |
... | ... | |
204 | 204 |
account = None |
205 | 205 |
search_query = vmid |
206 | 206 |
|
207 |
astakos_client = astakosclient.AstakosClient(settings.ASTAKOS_BASE_URL,
|
|
208 |
retry=2, use_pool=True,
|
|
209 |
logger=logger)
|
|
207 |
astakos_client = astakosclient.AstakosClient( |
|
208 |
auth_token, settings.ASTAKOS_AUTH_URL,
|
|
209 |
retry=2, use_pool=True, logger=logger)
|
|
210 | 210 |
|
211 | 211 |
account = None |
212 | 212 |
if is_uuid: |
213 | 213 |
account = search_query |
214 | 214 |
try: |
215 |
account_name = astakos_client.get_username(auth_token, account)
|
|
215 |
account_name = astakos_client.get_username(account) |
|
216 | 216 |
except: |
217 | 217 |
logger.info("Failed to resolve '%s' into account" % account) |
218 | 218 |
|
219 | 219 |
if account_exists and not is_uuid: |
220 | 220 |
account_name = search_query |
221 | 221 |
try: |
222 |
account = astakos_client.get_uuid(auth_token, account_name)
|
|
222 |
account = astakos_client.get_uuid(account_name) |
|
223 | 223 |
except: |
224 | 224 |
logger.info("Failed to resolve '%s' into account" % account_name) |
225 | 225 |
|
b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-list.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from synnefo.db.models import FloatingIP |
35 | 35 |
from snf_django.management.commands import ListCommand |
36 |
from synnefo.settings import CYCLADES_SERVICE_TOKEN, ASTAKOS_BASE_URL
|
|
36 |
from synnefo.settings import CYCLADES_SERVICE_TOKEN, ASTAKOS_AUTH_URL
|
|
37 | 37 |
from logging import getLogger |
38 | 38 |
log = getLogger(__name__) |
39 | 39 |
|
... | ... | |
43 | 43 |
object_class = FloatingIP |
44 | 44 |
deleted_field = "deleted" |
45 | 45 |
user_uuid_field = "userid" |
46 |
astakos_url = ASTAKOS_BASE_URL
|
|
46 |
astakos_auth_url = ASTAKOS_AUTH_URL
|
|
47 | 47 |
astakos_token = CYCLADES_SERVICE_TOKEN |
48 | 48 |
|
49 | 49 |
FIELDS = { |
b/snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py | ||
---|---|---|
43 | 43 |
from synnefo.logic.rapi import GanetiApiError |
44 | 44 |
from snf_django.lib.astakos import UserCache |
45 | 45 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
46 |
ASTAKOS_BASE_URL)
|
|
46 |
ASTAKOS_AUTH_URL)
|
|
47 | 47 |
from util import pool_map_chunks |
48 | 48 |
|
49 | 49 |
|
... | ... | |
66 | 66 |
|
67 | 67 |
net = get_network(args[0]) |
68 | 68 |
|
69 |
ucache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN)
|
|
69 |
ucache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
|
|
70 | 70 |
|
71 | 71 |
displayname = options['displayname'] |
72 | 72 |
|
b/snf-cyclades-app/synnefo/logic/tests/servers.py | ||
---|---|---|
220 | 220 |
mrapi().StartupInstance.return_value = 1 |
221 | 221 |
with mocked_quotaholder() as m: |
222 | 222 |
servers.start(vm) |
223 |
m.resolve_commissions.assert_called_once_with('', [],
|
|
223 |
m.resolve_commissions.assert_called_once_with([], |
|
224 | 224 |
[serial.serial]) |
225 | 225 |
self.assertTrue(m.issue_one_commission.called) |
226 | 226 |
# Not pending, rejct |
... | ... | |
233 | 233 |
mrapi().StartupInstance.return_value = 1 |
234 | 234 |
with mocked_quotaholder() as m: |
235 | 235 |
servers.start(vm) |
236 |
m.resolve_commissions.assert_called_once_with('', [],
|
|
236 |
m.resolve_commissions.assert_called_once_with([], |
|
237 | 237 |
[serial.serial]) |
238 | 238 |
self.assertTrue(m.issue_one_commission.called) |
239 | 239 |
# Not pending, accept |
... | ... | |
246 | 246 |
mrapi().StartupInstance.return_value = 1 |
247 | 247 |
with mocked_quotaholder() as m: |
248 | 248 |
servers.start(vm) |
249 |
m.resolve_commissions.assert_called_once_with('', [serial.serial],
|
|
249 |
m.resolve_commissions.assert_called_once_with([serial.serial], |
|
250 | 250 |
[]) |
251 | 251 |
self.assertTrue(m.issue_one_commission.called) |
252 | 252 |
|
... | ... | |
259 | 259 |
servers.start(vm) |
260 | 260 |
except: |
261 | 261 |
m.resolve_commissions\ |
262 |
.assert_called_once_with('', [], [vm.serial.serial])
|
|
262 |
.assert_called_once_with([], [vm.serial.serial]) |
|
263 | 263 |
|
264 | 264 |
def test_task_after(self, mrapi): |
265 | 265 |
return |
b/snf-cyclades-app/synnefo/plankton/backend.py | ||
---|---|---|
78 | 78 |
_pithos_backend_pool = \ |
79 | 79 |
PithosBackendPool( |
80 | 80 |
settings.PITHOS_BACKEND_POOL_SIZE, |
81 |
astakos_url=settings.ASTAKOS_BASE_URL,
|
|
81 |
astakos_auth_url=settings.ASTAKOS_AUTH_URL,
|
|
82 | 82 |
service_token=settings.CYCLADES_SERVICE_TOKEN, |
83 | 83 |
astakosclient_poolsize=settings.CYCLADES_ASTAKOSCLIENT_POOLSIZE, |
84 | 84 |
db_connection=settings.BACKEND_DB_CONNECTION, |
b/snf-cyclades-app/synnefo/quotas/__init__.py | ||
---|---|---|
35 | 35 |
FloatingIP) |
36 | 36 |
|
37 | 37 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
38 |
ASTAKOS_BASE_URL)
|
|
38 |
ASTAKOS_AUTH_URL)
|
|
39 | 39 |
from astakosclient import AstakosClient |
40 | 40 |
from astakosclient.errors import AstakosClientException, QuotaLimit |
41 | 41 |
from functools import wraps |
... | ... | |
43 | 43 |
import logging |
44 | 44 |
log = logging.getLogger(__name__) |
45 | 45 |
|
46 |
|
|
46 | 47 |
DEFAULT_SOURCE = 'system' |
47 | 48 |
RESOURCES = [ |
48 | 49 |
"cyclades.vm", |
... | ... | |
63 | 64 |
def get(cls): |
64 | 65 |
if cls._object is None: |
65 | 66 |
cls._object = AstakosClient( |
66 |
ASTAKOS_BASE_URL, |
|
67 |
ASTAKOS_TOKEN, |
|
68 |
ASTAKOS_AUTH_URL, |
|
67 | 69 |
use_pool=True, |
68 | 70 |
retry=3, |
69 | 71 |
logger=log) |
... | ... | |
94 | 96 |
|
95 | 97 |
qh = Quotaholder.get() |
96 | 98 |
try: |
97 |
serial = qh.issue_one_commission(ASTAKOS_TOKEN,
|
|
98 |
user, source, provisions, name=name,
|
|
99 |
force=force, auto_accept=auto_accept)
|
|
99 |
serial = qh.issue_one_commission( |
|
100 |
user, source, provisions, name=name, |
|
101 |
force=force, auto_accept=auto_accept) |
|
100 | 102 |
except QuotaLimit as e: |
101 | 103 |
msg, details = render_overlimit_exception(e) |
102 | 104 |
raise faults.OverLimit(msg, details=details) |
... | ... | |
143 | 145 |
reject = [] |
144 | 146 |
|
145 | 147 |
qh = Quotaholder.get() |
146 |
response = qh.resolve_commissions(ASTAKOS_TOKEN, accept, reject)
|
|
148 |
response = qh.resolve_commissions(accept, reject) |
|
147 | 149 |
|
148 | 150 |
if strict: |
149 | 151 |
failed = response["failed"] |
... | ... | |
188 | 190 |
|
189 | 191 |
def get_quotaholder_pending(): |
190 | 192 |
qh = Quotaholder.get() |
191 |
pending_serials = qh.get_pending_commissions(ASTAKOS_TOKEN)
|
|
193 |
pending_serials = qh.get_pending_commissions() |
|
192 | 194 |
return pending_serials |
193 | 195 |
|
194 | 196 |
|
b/snf-cyclades-app/synnefo/quotas/management/commands/reconcile-resources-cyclades.py | ||
---|---|---|
40 | 40 |
from synnefo.quotas.util import (get_db_holdings, get_quotaholder_holdings, |
41 | 41 |
transform_quotas) |
42 | 42 |
from snf_django.management.utils import pprint_table |
43 |
from synnefo.settings import CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN |
|
44 | 43 |
|
45 | 44 |
|
46 | 45 |
class Command(BaseCommand): |
... | ... | |
129 | 128 |
% datetime.now()) |
130 | 129 |
request["provisions"] = map(create_provision, unsynced) |
131 | 130 |
try: |
132 |
qh.issue_commission(ASTAKOS_TOKEN, request)
|
|
131 |
qh.issue_commission(request) |
|
133 | 132 |
except quotas.QuotaLimit: |
134 | 133 |
write("Reconciling failed because a limit has been " |
135 | 134 |
"reached. Use --force to ignore the check.\n") |
b/snf-cyclades-app/synnefo/quotas/util.py | ||
---|---|---|
34 | 34 |
from django.db.models import Sum, Count, Q |
35 | 35 |
|
36 | 36 |
from synnefo.db.models import VirtualMachine, Network, FloatingIP |
37 |
from synnefo.quotas import Quotaholder, ASTAKOS_TOKEN
|
|
37 |
from synnefo.quotas import Quotaholder |
|
38 | 38 |
|
39 | 39 |
|
40 | 40 |
def get_db_holdings(user=None): |
... | ... | |
99 | 99 |
Returns quotas for all users, unless a single user is specified. |
100 | 100 |
""" |
101 | 101 |
qh = Quotaholder.get() |
102 |
return qh.service_get_quotas(ASTAKOS_TOKEN, user)
|
|
102 |
return qh.service_get_quotas(user) |
|
103 | 103 |
|
104 | 104 |
|
105 | 105 |
def transform_quotas(quotas): |
b/snf-cyclades-app/synnefo/ui/settings.py | ||
---|---|---|
33 | 33 |
# |
34 | 34 |
|
35 | 35 |
import synnefo.cyclades_settings as cyclades |
36 |
from synnefo.cyclades_settings import cyclades_services, astakos_services
|
|
36 |
from synnefo.cyclades_settings import cyclades_services |
|
37 | 37 |
|
38 | 38 |
from synnefo.lib import join_urls |
39 | 39 |
from synnefo.lib.services import get_public_endpoint as endpoint |
40 | 40 |
|
41 |
from django.conf import settings |
|
42 | 41 |
|
43 | 42 |
BASE_PATH = cyclades.BASE_PATH |
44 | 43 |
if not BASE_PATH.startswith("/"): |
... | ... | |
47 | 46 |
GLANCE_URL = endpoint(cyclades_services, 'image', 'v1.0').rstrip('/') |
48 | 47 |
COMPUTE_URL = endpoint(cyclades_services, 'compute', 'v2.0').rstrip('/') |
49 | 48 |
USERDATA_URL = endpoint(cyclades_services, 'cyclades_userdata', '').rstrip('/') |
50 |
ASTAKOS_UI_URL = endpoint(astakos_services, 'astakos_ui', '').rstrip('/') |
|
51 |
|
|
52 |
|
|
53 |
if cyclades.PROXY_USER_SERVICES: |
|
54 |
ACCOUNT_URL = join_urls('/', cyclades.BASE_ASTAKOS_PROXY_PATH, |
|
55 |
cyclades.ASTAKOS_ACCOUNTS_PREFIX, 'v1.0') |
|
56 |
else: |
|
57 |
ACCOUNT_URL = endpoint(astakos_services, 'account', 'v1.0') |
|
58 | 49 |
|
50 |
ACCOUNT_URL = join_urls('/', cyclades.ASTAKOS_ACCOUNT_PROXY_PATH) |
|
59 | 51 |
|
60 | 52 |
USER_CATALOG_URL = join_urls(ACCOUNT_URL, 'user_catalogs') |
61 | 53 |
FEEDBACK_URL = join_urls(ACCOUNT_URL, 'feedback') |
62 | 54 |
|
63 |
LOGIN_URL = join_urls(ASTAKOS_UI_URL, 'login')
|
|
55 |
LOGIN_URL = join_urls('/', cyclades.ASTAKOS_UI_PROXY_PATH, 'login')
|
|
64 | 56 |
LOGOUT_REDIRECT = LOGIN_URL |
b/snf-cyclades-app/synnefo/userdata/rest.py | ||
---|---|---|
77 | 77 |
Main entry point for a request-response process. |
78 | 78 |
""" |
79 | 79 |
def view(request, *args, **kwargs): |
80 |
get_user(request, settings.ASTAKOS_BASE_URL)
|
|
80 |
get_user(request, settings.ASTAKOS_AUTH_URL)
|
|
81 | 81 |
if not request.user_uniq: |
82 | 82 |
return HttpResponse(status=401) |
83 | 83 |
self = cls(*initargs, **initkwargs) |
b/snf-cyclades-app/synnefo/userdata/views.py | ||
---|---|---|
69 | 69 |
Response to generate private/public RSA key pair |
70 | 70 |
""" |
71 | 71 |
|
72 |
get_user(request, settings.ASTAKOS_BASE_URL)
|
|
72 |
get_user(request, settings.ASTAKOS_AUTH_URL)
|
|
73 | 73 |
|
74 | 74 |
if request.method != "POST": |
75 | 75 |
return http.HttpResponseNotAllowed(["POST"]) |
Also available in: Unified diff