Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
c2bada67
Commit
c2bada67
authored
May 30, 2013
by
Georgios D. Tsoukalas
Browse files
cyclades: initialize settings from service catalog
parent
8f13e12e
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-common/synnefo/lib/services.py
0 → 100644
View file @
c2bada67
# Copyright 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
synnefo.lib
import
join_urls
from
synnefo.util.keypath
import
get_path
,
set_path
def
fill_in_endpoints
(
services
,
base_url
):
for
name
,
service
in
services
.
iteritems
():
prefix
=
get_path
(
service
,
'prefix'
)
endpoints
=
get_path
(
service
,
'endpoints'
)
for
name
,
endpoint
in
endpoints
.
iteritems
():
version
=
get_path
(
'versionId'
)
publicURL
=
get_path
(
'publicURL'
)
if
publicURL
is
not
None
:
continue
publicURL
=
join_urls
(
base_url
,
prefix
,
version
)
set_path
(
'publicURL'
,
publicURL
)
snf-cyclades-app/synnefo/api/services.py
View file @
c2bada67
...
...
@@ -88,7 +88,7 @@ cyclades_services = {
'cyclades_ui'
:
{
'type'
:
'cyclades_ui'
,
'component'
:
'cyclades'
,
'prefix'
:
'u
serdata
'
,
'prefix'
:
'u
i
'
,
'public'
:
False
,
'endpoints'
:
[
{
'version'
:
''
,
...
...
snf-cyclades-app/synnefo/cyclades_settings.py
View file @
c2bada67
...
...
@@ -33,6 +33,11 @@
from
django.conf
import
settings
from
synnefo.lib
import
join_urls
,
parse_base_url
from
synnefo.util.keypath
import
get_path
from
synnefo.api.services
import
cyclades_services
as
vanilla_cyclades_services
from
astakosclient
import
astakos_services
as
vanilla_astakos_services
from
copy
import
deepcopy
BASE_URL
=
getattr
(
settings
,
'CYCLADES_BASE_URL'
,
'https://compute.example.synnefo.org/compute/'
)
...
...
@@ -42,12 +47,27 @@ ASTAKOS_BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL',
'https://accounts.example.synnefo.org/astakos/'
)
ASTAKOS_BASE_HOST
,
ASTAKOS_BASE_PATH
=
parse_base_url
(
ASTAKOS_BASE_URL
)
COMPUTE_PREFIX
=
getattr
(
settings
,
'CYCLADES_COMPUTE_PREFIX'
,
'compute'
)
VMAPI_PREFIX
=
getattr
(
settings
,
'CYCLADES_VMAPI_PREFIX'
,
'vmapi'
)
PLANKTON_PREFIX
=
getattr
(
settings
,
'CYCLADES_PLANKTON_PREFIX'
,
'plankton'
)
HELPDESK_PREFIX
=
getattr
(
settings
,
'CYCLADES_HELPDESK_PREFIX'
,
'helpdesk'
)
UI_PREFIX
=
getattr
(
settings
,
'CYCLADES_UI_PREFIX'
,
'ui'
)
USERDATA_PREFIX
=
getattr
(
settings
,
'CYCLADES_USERDATA_PREFIX'
,
'userdata'
)
CUSTOMIZE_SERVICES
=
getattr
(
settings
,
'CYCLADES_CUSTOMIZE_SERVICES'
,
())
cyclades_services
=
deepcopy
(
vanilla_cyclades_services
)
for
path
,
value
in
CUSTOMIZE_SERVICES
:
set_path
(
cyclades_services
,
path
,
value
,
createpath
=
True
)
astakos_services
=
deepcopy
(
vanilla_astakos_services
)
CUSTOMIZE_ASTAKOS_SERVICES
=
\
getattr
(
settings
,
'CYCLADES_CUSTOMIZE_ASTAKOS_SERVICES'
,
())
for
path
,
value
in
CUSTOMIZE_ASTAKOS_SERVICES
:
set_path
(
astakos_services
,
path
,
value
,
createpath
=
True
)
COMPUTE_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_compute.prefix'
)
VMAPI_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_vmapi.prefix'
)
PLANKTON_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_plankton.prefix'
)
HELPDESK_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_helpdesk.prefix'
)
UI_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_ui.prefix'
)
USERDATA_PREFIX
=
get_path
(
cyclades_services
,
'cyclades_userdata.prefix'
)
ASTAKOS_ACCOUNTS_PREFIX
=
get_path
(
astakos_services
,
'astakos_account.prefix'
)
ASTAKOS_VIEWS_PREFIX
=
get_path
(
astakos_services
,
'astakos_ui.prefix'
)
ASTAKOS_KEYSTONE_PREFIX
=
get_path
(
astakos_services
,
'astakos_keystone.prefix'
)
# The API implementation needs to accept and return absolute references
# to its resources. Thus, it needs to know its public URL.
...
...
@@ -59,14 +79,4 @@ BASE_ASTAKOS_PROXY_PATH = getattr(settings,
BASE_ASTAKOS_PROXY_PATH
=
join_urls
(
BASE_PATH
,
BASE_ASTAKOS_PROXY_PATH
)
BASE_ASTAKOS_PROXY_PATH
=
BASE_ASTAKOS_PROXY_PATH
.
strip
(
'/'
)
ASTAKOS_ACCOUNTS_PREFIX
=
getattr
(
settings
,
'ASTAKOS_ACCOUNTS_PREFIX'
,
'accounts'
).
strip
(
'/'
)
ASTAKOS_VIEWS_PREFIX
=
getattr
(
settings
,
'ASTAKOS_VIEWS_PREFIX'
,
'im'
).
strip
(
'/'
)
ASTAKOS_KEYSTONE_PREFIX
=
getattr
(
settings
,
'ASTAKOS_KEYSTONE_PREFIX'
,
'keystone'
).
strip
(
'/'
)
PROXY_USER_SERVICES
=
getattr
(
settings
,
'CYCLADES_PROXY_USER_SERVICES'
,
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment