Commit 625bd291 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

snf-cyclades-app: Use the new AstakosClient

Change AstakosClient to use ASTAKOS_AUTH_URL as entry point to the
Astakos service, instead of ASTAKOS_BASE_URL it was using until now.

Remove ASTAKOS_BASE_URL from Cyclades settings, replace it with
ASTAKOS_AUTH_URL. Modify Cyclades to determine ASTAKOS_ACCOUNT_URL and
ASTAKOS_UI_URL with calls to astakosclient.
parent f041ab50
...@@ -1858,9 +1858,6 @@ Edit ``/etc/synnefo/20-snf-cyclades-app-api.conf``: ...@@ -1858,9 +1858,6 @@ Edit ``/etc/synnefo/20-snf-cyclades-app-api.conf``:
CYCLADES_BASE_URL = 'https://node1.example.com/cyclades' CYCLADES_BASE_URL = 'https://node1.example.com/cyclades'
ASTAKOS_BASE_URL = 'https://node1.example.com/astakos' ASTAKOS_BASE_URL = 'https://node1.example.com/astakos'
# Set to False if astakos & cyclades are on the same host
CYCLADES_PROXY_USER_SERVICES = False
CYCLADES_SERVICE_TOKEN = 'cyclades_service_token22w' CYCLADES_SERVICE_TOKEN = 'cyclades_service_token22w'
The ``ASTAKOS_BASE_URL`` denotes the Astakos endpoint for Cyclades, The ``ASTAKOS_BASE_URL`` denotes the Astakos endpoint for Cyclades,
......
...@@ -56,10 +56,10 @@ else: ...@@ -56,10 +56,10 @@ else:
ASTAKOS_IM_MODULES = ['local', 'shibboleth'] ASTAKOS_IM_MODULES = ['local', 'shibboleth']
CYCLADES_PROXY_USER_SERVICES = False
PITHOS_PROXY_USER_SERVICES = False PITHOS_PROXY_USER_SERVICES = False
ASTAKOS_BASE_URL = 'http://accounts.example.synnefo.org/astakos/' ASTAKOS_BASE_URL = 'http://accounts.example.synnefo.org/astakos/'
ASTAKOS_AUTH_URL = 'http://accounts.example.synnefo.org/astakos/identity/v2.0/'
COMPUTE_BASE_URL = 'http://compute.example.synnefo.org/cyclades/' COMPUTE_BASE_URL = 'http://compute.example.synnefo.org/cyclades/'
PITHOS_BASE_URL = 'http://storage.example.synnefo.org/pithos/' PITHOS_BASE_URL = 'http://storage.example.synnefo.org/pithos/'
......
...@@ -82,8 +82,8 @@ ...@@ -82,8 +82,8 @@
#MAX_PERSONALITY_SIZE = 10240 #MAX_PERSONALITY_SIZE = 10240
# #
# #
## Top-level URL of the astakos instance to be used for user management ## Authentication URL of the astakos instance to be used for user management
#ASTAKOS_BASE_URL = 'https://accounts.example.synnefo.org/' #ASTAKOS_AUTH_URL = 'https://accounts.example.synnefo.org/identity/v2.0/'
# #
## Key for password encryption-decryption. After changing this setting, synnefo ## Key for password encryption-decryption. After changing this setting, synnefo
## will be unable to decrypt all existing Backend passwords. You will need to ## will be unable to decrypt all existing Backend passwords. You will need to
...@@ -97,10 +97,8 @@ ...@@ -97,10 +97,8 @@
## using a user uuid) ## using a user uuid)
#CYCLADES_SERVICE_TOKEN = '' #CYCLADES_SERVICE_TOKEN = ''
# Let cyclades proxy user specific api calls to astakos, via self served ## PROXY Astakos services under the following path
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the #CYCLADES_PROXY_PREFIX = '_astakos'
# same machine.
#CYCLADES_PROXY_USER_SERVICES = True
# Tune the size of the http connection pool to astakos. # Tune the size of the http connection pool to astakos.
#CYCLADES_ASTAKOSCLIENT_POOLSIZE = 50 #CYCLADES_ASTAKOSCLIENT_POOLSIZE = 50
......
...@@ -36,7 +36,7 @@ from optparse import make_option ...@@ -36,7 +36,7 @@ from optparse import make_option
from snf_django.management.commands import ListCommand from snf_django.management.commands import ListCommand
from synnefo.db.models import Network from synnefo.db.models import Network
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN,
ASTAKOS_BASE_URL) ASTAKOS_AUTH_URL)
from logging import getLogger from logging import getLogger
log = getLogger(__name__) log = getLogger(__name__)
...@@ -63,7 +63,7 @@ class Command(ListCommand): ...@@ -63,7 +63,7 @@ class Command(ListCommand):
object_class = Network object_class = Network
deleted_field = "deleted" deleted_field = "deleted"
user_uuid_field = "userid" user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL astakos_auth_url = ASTAKOS_AUTH_URL
astakos_token = ASTAKOS_TOKEN astakos_token = ASTAKOS_TOKEN
def get_machines(network): def get_machines(network):
......
...@@ -41,7 +41,7 @@ from synnefo.logic.rapi import GanetiApiError ...@@ -41,7 +41,7 @@ from synnefo.logic.rapi import GanetiApiError
from synnefo.management.common import Omit from synnefo.management.common import Omit
from synnefo.management import common from synnefo.management import common
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN,
ASTAKOS_BASE_URL) ASTAKOS_AUTH_URL)
# Fields to print from a gnt-instance info # Fields to print from a gnt-instance info
...@@ -82,7 +82,7 @@ class Command(BaseCommand): ...@@ -82,7 +82,7 @@ class Command(BaseCommand):
displayname = options['displayname'] displayname = options['displayname']
ucache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN) ucache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
try: try:
image = common.get_image(vm.imageid, vm.userid)['name'] image = common.get_image(vm.imageid, vm.userid)['name']
......
...@@ -38,7 +38,7 @@ from synnefo.db.models import VirtualMachine ...@@ -38,7 +38,7 @@ from synnefo.db.models import VirtualMachine
from synnefo.management.common import get_backend from synnefo.management.common import get_backend
from synnefo.api.util import get_image from synnefo.api.util import get_image
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN,
ASTAKOS_BASE_URL) ASTAKOS_AUTH_URL)
from logging import getLogger from logging import getLogger
log = getLogger(__name__) log = getLogger(__name__)
...@@ -74,7 +74,7 @@ class Command(ListCommand): ...@@ -74,7 +74,7 @@ class Command(ListCommand):
object_class = VirtualMachine object_class = VirtualMachine
deleted_field = "deleted" deleted_field = "deleted"
user_uuid_field = "userid" user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL astakos_auth_url = ASTAKOS_AUTH_URL
astakos_token = ASTAKOS_TOKEN astakos_token = ASTAKOS_TOKEN
def get_public_ip(vm): def get_public_ip(vm):
......
...@@ -37,7 +37,7 @@ from synnefo.management.common import (format_vm_state, get_vm, ...@@ -37,7 +37,7 @@ from synnefo.management.common import (format_vm_state, get_vm,
get_image) get_image)
from snf_django.lib.astakos import UserCache from snf_django.lib.astakos import UserCache
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN,
ASTAKOS_BASE_URL) ASTAKOS_AUTH_URL)
from snf_django.management import utils from snf_django.management import utils
...@@ -61,7 +61,7 @@ class Command(SynnefoCommand): ...@@ -61,7 +61,7 @@ class Command(SynnefoCommand):
image_name = "None" image_name = "None"
image = '%s (%s)' % (imageid, image_name) image = '%s (%s)' % (imageid, image_name)
usercache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN) usercache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
kv = { kv = {
'id': server.id, 'id': server.id,
'name': server.name, 'name': server.name,
......
...@@ -81,8 +81,8 @@ MAX_PERSONALITY = 5 ...@@ -81,8 +81,8 @@ MAX_PERSONALITY = 5
MAX_PERSONALITY_SIZE = 10240 MAX_PERSONALITY_SIZE = 10240
# Top-level URL of the astakos instance to be used for user management # Authentication URL of the astakos instance to be used for user management
ASTAKOS_BASE_URL = 'https://accounts.example.synnefo.org/' ASTAKOS_AUTH_URL = 'https://accounts.example.synnefo.org/identity/v2.0'
# Tune the size of the Astakos http client connection pool # Tune the size of the Astakos http client connection pool
# This limit the number of concurrent requests to Astakos. # This limit the number of concurrent requests to Astakos.
...@@ -100,11 +100,6 @@ SECRET_ENCRYPTION_KEY = "Password Encryption Key" ...@@ -100,11 +100,6 @@ SECRET_ENCRYPTION_KEY = "Password Encryption Key"
# using a user uuid) # using a user uuid)
CYCLADES_SERVICE_TOKEN = '' CYCLADES_SERVICE_TOKEN = ''
# Let cyclades proxy user specific api calls to astakos, via self served
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the
# same machine.
CYCLADES_PROXY_USER_SERVICES = True
# Template to use to build the FQDN of VMs. The setting will be formated with # Template to use to build the FQDN of VMs. The setting will be formated with
# the id of the VM. If set to 'None' the first public IPv4 or IPv6 address # the id of the VM. If set to 'None' the first public IPv4 or IPv6 address
# of the VM will be used. # of the VM will be used.
......
...@@ -40,9 +40,11 @@ from snf_django.utils.urls import \ ...@@ -40,9 +40,11 @@ from snf_django.utils.urls import \
from snf_django.lib.api.urls import api_patterns from snf_django.lib.api.urls import api_patterns
from synnefo.cyclades_settings import ( from synnefo.cyclades_settings import (
BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX, BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX,
PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, ASTAKOS_BASE_URL, PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX,
USERDATA_PREFIX, ADMIN_PREFIX, BASE_ASTAKOS_PROXY_PATH, USERDATA_PREFIX, ADMIN_PREFIX,
ASTAKOS_ACCOUNTS_PREFIX, ASTAKOS_VIEWS_PREFIX, PROXY_USER_SERVICES, ASTAKOS_AUTH_PROXY_PATH, ASTAKOS_AUTH_URL,
ASTAKOS_ACCOUNT_PROXY_PATH, ASTAKOS_ACCOUNT_URL,
ASTAKOS_UI_PROXY_PATH, ASTAKOS_UI_URL,
cyclades_services) cyclades_services)
from functools import partial from functools import partial
...@@ -56,9 +58,6 @@ extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_helpdesk') ...@@ -56,9 +58,6 @@ extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_helpdesk')
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'admin') extend_endpoint_with_slash(urlpatterns, cyclades_services, 'admin')
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_userdata') extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_userdata')
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH,
target_base=ASTAKOS_BASE_URL)
cyclades_patterns = api_patterns( cyclades_patterns = api_patterns(
'', '',
(prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')), (prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')),
...@@ -79,27 +78,30 @@ urlpatterns += patterns( ...@@ -79,27 +78,30 @@ urlpatterns += patterns(
(prefix_pattern(BASE_PATH), include(cyclades_patterns)), (prefix_pattern(BASE_PATH), include(cyclades_patterns)),
) )
if PROXY_USER_SERVICES:
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH,
target_base=ASTAKOS_BASE_URL)
proxy_patterns = patterns( # --------------------------------------
'', # PROXY settings
(prefix_pattern(ASTAKOS_VIEWS_PREFIX), astakos_proxy), astakos_auth_proxy = \
) partial(proxy, proxy_base=ASTAKOS_AUTH_PROXY_PATH,
proxy_patterns += api_patterns( target_base=ASTAKOS_AUTH_URL)
'', astakos_account_proxy = \
(r'^login/?$', astakos_proxy), partial(proxy, proxy_base=ASTAKOS_ACCOUNT_PROXY_PATH,
(r'^feedback/?$', astakos_proxy), target_base=ASTAKOS_ACCOUNT_URL)
(r'^user_catalogs/?$', astakos_proxy), astakos_ui_proxy = \
(prefix_pattern(ASTAKOS_ACCOUNTS_PREFIX), astakos_proxy), partial(proxy, proxy_base=ASTAKOS_UI_PROXY_PATH,
) target_base=ASTAKOS_UI_URL)
urlpatterns += patterns( urlpatterns += api_patterns(
'', '',
(prefix_pattern(BASE_ASTAKOS_PROXY_PATH), include(proxy_patterns)), (prefix_pattern(ASTAKOS_AUTH_PROXY_PATH), astakos_auth_proxy),
) (prefix_pattern(ASTAKOS_ACCOUNT_PROXY_PATH), astakos_account_proxy),
)
urlpatterns += patterns(
'',
(prefix_pattern(ASTAKOS_UI_PROXY_PATH), astakos_ui_proxy),
)
# --------------------------------------
# set utility redirects # set utility redirects
extend_with_root_redirects(urlpatterns, cyclades_services, 'cyclades_ui', extend_with_root_redirects(urlpatterns, cyclades_services, 'cyclades_ui',
BASE_PATH) BASE_PATH)
...@@ -36,16 +36,18 @@ from synnefo.lib import join_urls, parse_base_url ...@@ -36,16 +36,18 @@ from synnefo.lib import join_urls, parse_base_url
from synnefo.util.keypath import get_path, set_path from synnefo.util.keypath import get_path, set_path
from synnefo.api.services import cyclades_services as vanilla_cyclades_services from synnefo.api.services import cyclades_services as vanilla_cyclades_services
from synnefo.lib.services import fill_endpoints from synnefo.lib.services import fill_endpoints
from astakosclient import astakos_services as vanilla_astakos_services from astakosclient import AstakosClient
from copy import deepcopy from copy import deepcopy
# --------------------------------------------------------------------
# Process Cyclades settings # Process Cyclades settings
BASE_URL = getattr(settings, 'CYCLADES_BASE_URL', BASE_URL = getattr(settings, 'CYCLADES_BASE_URL',
'https://compute.example.synnefo.org/compute/') 'https://compute.example.synnefo.org/compute/')
BASE_HOST, BASE_PATH = parse_base_url(BASE_URL) BASE_HOST, BASE_PATH = parse_base_url(BASE_URL)
SERVICE_TOKEN = getattr(settings, 'CYCLADES_SERVICE_TOKEN', "")
CUSTOMIZE_SERVICES = getattr(settings, 'CYCLADES_CUSTOMIZE_SERVICES', ()) CUSTOMIZE_SERVICES = getattr(settings, 'CYCLADES_CUSTOMIZE_SERVICES', ())
cyclades_services = deepcopy(vanilla_cyclades_services) cyclades_services = deepcopy(vanilla_cyclades_services)
...@@ -64,33 +66,44 @@ ADMIN_PREFIX = get_path(cyclades_services, 'cyclades_admin.prefix') ...@@ -64,33 +66,44 @@ ADMIN_PREFIX = get_path(cyclades_services, 'cyclades_admin.prefix')
COMPUTE_ROOT_URL = join_urls(BASE_URL, COMPUTE_PREFIX) COMPUTE_ROOT_URL = join_urls(BASE_URL, COMPUTE_PREFIX)
# --------------------------------------------------------------------
# Process Astakos settings # Process Astakos settings
ASTAKOS_BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL', ASTAKOS_AUTH_URL = getattr(
'https://accounts.example.synnefo.org/astakos/') settings, 'ASTAKOS_AUTH_URL',
ASTAKOS_BASE_HOST, ASTAKOS_BASE_PATH = parse_base_url(ASTAKOS_BASE_URL) 'https://accounts.example.synnefo.org/astakos/identity/v2.0/')
# Patch astakosclient directly, otherwise it will not see any customization
#astakos_services = deepcopy(vanilla_astakos_services) # --------------------------------------
CUSTOMIZE_ASTAKOS_SERVICES = \ # Define a LazyAstakosUrl
getattr(settings, 'CYCLADES_CUSTOMIZE_ASTAKOS_SERVICES', ()) class LazyAstakosUrl(object):
def __init__(self, endpoints_name):
astakos_services = deepcopy(vanilla_astakos_services) self.endpoints_name = endpoints_name
fill_endpoints(astakos_services, ASTAKOS_BASE_URL)
for path, value in CUSTOMIZE_ASTAKOS_SERVICES: def __str__(self):
set_path(astakos_services, path, value, createpath=True) if not hasattr(self, 'str'):
try:
ASTAKOS_ACCOUNTS_PREFIX = get_path(astakos_services, 'astakos_account.prefix') astakos_client = \
ASTAKOS_VIEWS_PREFIX = get_path(astakos_services, 'astakos_ui.prefix') AstakosClient(SERVICE_TOKEN, ASTAKOS_AUTH_URL)
ASTAKOS_KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_identity.prefix') self.str = getattr(astakos_client, self.endpoints_name)
except:
return None
# Proxy Astakos settings return self.str
BASE_ASTAKOS_PROXY_PATH = getattr(settings, # --------------------------------------
'CYCLADES_BASE_ASTAKOS_PROXY_PATH', # Define ASTAKOS_UI_URL and ASTAKOS_ACCOUNT_URL as LazyAstakosUrl
ASTAKOS_BASE_PATH) ASTAKOS_ACCOUNT_URL = LazyAstakosUrl('account_url')
BASE_ASTAKOS_PROXY_PATH = join_urls(BASE_PATH, BASE_ASTAKOS_PROXY_PATH) ASTAKOS_UI_URL = LazyAstakosUrl('ui_url')
BASE_ASTAKOS_PROXY_PATH = BASE_ASTAKOS_PROXY_PATH.strip('/')
# --------------------------------------
PROXY_USER_SERVICES = getattr(settings, 'CYCLADES_PROXY_USER_SERVICES', True) # Define Astakos prefixes
ASTAKOS_PROXY_PREFIX = getattr(settings, 'CYCLADES_PROXY_PREFIX', '_astakos')
ASTAKOS_AUTH_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'identity')
ASTAKOS_ACCOUNT_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'account')
ASTAKOS_UI_PREFIX = join_urls('/', ASTAKOS_PROXY_PREFIX, 'ui')
# --------------------------------------
# Define Astakos proxy paths
ASTAKOS_AUTH_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_AUTH_PREFIX)
ASTAKOS_ACCOUNT_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_ACCOUNT_PREFIX)
ASTAKOS_UI_PROXY_PATH = join_urls(BASE_PATH, ASTAKOS_UI_PREFIX)
...@@ -56,13 +56,13 @@ class AstakosClientMock(): ...@@ -56,13 +56,13 @@ class AstakosClientMock():
def __init__(*args, **kwargs): def __init__(*args, **kwargs):
pass pass
def get_username(self, token, uuid): def get_username(self, uuid):
try: try:
return USERS_UUIDS.get(uuid)['displayname'] return USERS_UUIDS.get(uuid)['displayname']
except TypeError: except TypeError:
return None return None
def get_uuid(self, token, display_name): def get_uuid(self, display_name):
try: try:
return USERS_DISPLAYNAMES.get(display_name)['uuid'] return USERS_DISPLAYNAMES.get(display_name)['uuid']
except TypeError: except TypeError:
......
...@@ -114,7 +114,7 @@ def helpdesk_user_required(func, permitted_groups=PERMITTED_GROUPS): ...@@ -114,7 +114,7 @@ def helpdesk_user_required(func, permitted_groups=PERMITTED_GROUPS):
raise Http404 raise Http404
token = get_token_from_cookie(request, AUTH_COOKIE_NAME) token = get_token_from_cookie(request, AUTH_COOKIE_NAME)
astakos.get_user(request, settings.ASTAKOS_BASE_URL, astakos.get_user(request, settings.ASTAKOS_AUTH_URL,
fallback_token=token, logger=logger) fallback_token=token, logger=logger)
if hasattr(request, 'user') and request.user: if hasattr(request, 'user') and request.user:
groups = request.user.get('groups', []) groups = request.user.get('groups', [])
...@@ -204,22 +204,22 @@ def account(request, search_query): ...@@ -204,22 +204,22 @@ def account(request, search_query):
account = None account = None
search_query = vmid search_query = vmid
astakos_client = astakosclient.AstakosClient(settings.ASTAKOS_BASE_URL, astakos_client = astakosclient.AstakosClient(
retry=2, use_pool=True, auth_token, settings.ASTAKOS_AUTH_URL,
logger=logger) retry=2, use_pool=True, logger=logger)
account = None account = None
if is_uuid: if is_uuid:
account = search_query account = search_query
try: try:
account_name = astakos_client.get_username(auth_token, account) account_name = astakos_client.get_username(account)
except: except:
logger.info("Failed to resolve '%s' into account" % account) logger.info("Failed to resolve '%s' into account" % account)
if account_exists and not is_uuid: if account_exists and not is_uuid:
account_name = search_query account_name = search_query
try: try:
account = astakos_client.get_uuid(auth_token, account_name) account = astakos_client.get_uuid(account_name)
except: except:
logger.info("Failed to resolve '%s' into account" % account_name) logger.info("Failed to resolve '%s' into account" % account_name)
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
from synnefo.db.models import FloatingIP from synnefo.db.models import FloatingIP
from snf_django.management.commands import ListCommand from snf_django.management.commands import ListCommand
from synnefo.settings import CYCLADES_SERVICE_TOKEN, ASTAKOS_BASE_URL from synnefo.settings import CYCLADES_SERVICE_TOKEN, ASTAKOS_AUTH_URL
from logging import getLogger from logging import getLogger
log = getLogger(__name__) log = getLogger(__name__)
...@@ -43,7 +43,7 @@ class Command(ListCommand): ...@@ -43,7 +43,7 @@ class Command(ListCommand):
object_class = FloatingIP object_class = FloatingIP
deleted_field = "deleted" deleted_field = "deleted"
user_uuid_field = "userid" user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL astakos_auth_url = ASTAKOS_AUTH_URL
astakos_token = CYCLADES_SERVICE_TOKEN astakos_token = CYCLADES_SERVICE_TOKEN
FIELDS = { FIELDS = {
......
...@@ -43,7 +43,7 @@ from synnefo.db.models import (Backend, BackendNetwork, ...@@ -43,7 +43,7 @@ from synnefo.db.models import (Backend, BackendNetwork,
from synnefo.logic.rapi import GanetiApiError from synnefo.logic.rapi import GanetiApiError
from snf_django.lib.astakos import UserCache from snf_django.lib.astakos import UserCache
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN,
ASTAKOS_BASE_URL) ASTAKOS_AUTH_URL)
from util import pool_map_chunks from util import pool_map_chunks
...@@ -66,7 +66,7 @@ class Command(BaseCommand): ...@@ -66,7 +66,7 @@ class Command(BaseCommand):
net = get_network(args[0]) net = get_network(args[0])
ucache = UserCache(ASTAKOS_BASE_URL, ASTAKOS_TOKEN) ucache = UserCache(ASTAKOS_AUTH_URL, ASTAKOS_TOKEN)
displayname = options['displayname'] displayname = options['displayname']
......
...@@ -220,7 +220,7 @@ class ServerCommandTest(TransactionTestCase): ...@@ -220,7 +220,7 @@ class ServerCommandTest(TransactionTestCase):
mrapi().StartupInstance.return_value = 1 mrapi().StartupInstance.return_value = 1
with mocked_quotaholder() as m: with mocked_quotaholder() as m:
servers.start(vm) servers.start(vm)
m.resolve_commissions.assert_called_once_with('', [], m.resolve_commissions.assert_called_once_with([],
[serial.serial]) [serial.serial])
self.assertTrue(m.issue_one_commission.called) self.assertTrue(m.issue_one_commission.called)
# Not pending, rejct # Not pending, rejct
...@@ -233,7 +233,7 @@ class ServerCommandTest(TransactionTestCase): ...@@ -233,7 +233,7 @@ class ServerCommandTest(TransactionTestCase):
mrapi().StartupInstance.return_value = 1 mrapi().StartupInstance.return_value = 1
with mocked_quotaholder() as m: with mocked_quotaholder() as m:
servers.start(vm) servers.start(vm)
m.resolve_commissions.assert_called_once_with('', [], m.resolve_commissions.assert_called_once_with([],
[serial.serial]) [serial.serial])
self.assertTrue(m.issue_one_commission.called) self.assertTrue(m.issue_one_commission.called)
# Not pending, accept # Not pending, accept
...@@ -246,7 +246,7 @@ class ServerCommandTest(TransactionTestCase): ...@@ -246,7 +246,7 @@ class ServerCommandTest(TransactionTestCase):
mrapi().StartupInstance.return_value = 1 mrapi().StartupInstance.return_value = 1
with mocked_quotaholder() as m: with mocked_quotaholder() as m:
servers.start(vm) servers.start(vm)
m.resolve_commissions.assert_called_once_with('', [serial.serial], m.resolve_commissions.assert_called_once_with([serial.serial],
[]) [])
self.assertTrue(m.issue_one_commission.called) self.assertTrue(m.issue_one_commission.called)
...@@ -259,7 +259,7 @@ class ServerCommandTest(TransactionTestCase): ...@@ -259,7 +259,7 @@ class ServerCommandTest(TransactionTestCase):
servers.start(vm) servers.start(vm)
except: except:
m.resolve_commissions\ m.resolve_commissions\
.assert_called_once_with('', [], [vm.serial.serial]) .assert_called_once_with([], [vm.serial.serial])
def test_task_after(self, mrapi):