Commit 9b0953d5 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

common: Export only services specified as public

Employ helper function `filter_public' in service-export-* commands.
Also set `pithos_ui' service to non-public and clear version of
`astakos_ui'.
parent b99b4167
...@@ -59,7 +59,7 @@ astakos_services = { ...@@ -59,7 +59,7 @@ astakos_services = {
'prefix': 'ui', 'prefix': 'ui',
'public': False, 'public': False,
'endpoints': [ 'endpoints': [
{'versionId': 'v1.0', {'versionId': '',
'publicURL': None}, 'publicURL': None},
]}, ]},
} }
...@@ -35,11 +35,12 @@ from django.utils import simplejson as json ...@@ -35,11 +35,12 @@ from django.utils import simplejson as json
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
# import from settings, after any post-processing # import from settings, after any post-processing
from astakos.im.settings import astakos_services from astakos.im.settings import astakos_services
from synnefo.lib.services import filter_public
class Command(NoArgsCommand): class Command(NoArgsCommand):
help = "Export Astakos services in JSON format." help = "Export Astakos services in JSON format."
def handle(self, *args, **options): def handle(self, *args, **options):
output = json.dumps(astakos_services, indent=4) output = json.dumps(filter_public(astakos_services), indent=4)
self.stdout.write(output + "\n") self.stdout.write(output + "\n")
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
# interpreted as representing official policies, either expressed # interpreted as representing official policies, either expressed
# or implied, of GRNET S.A. # or implied, of GRNET S.A.
from copy import deepcopy
from synnefo.lib import join_urls from synnefo.lib import join_urls
from synnefo.util.keypath import get_path, set_path from synnefo.util.keypath import get_path, set_path
...@@ -47,3 +48,11 @@ def fill_endpoints(services, base_url): ...@@ -47,3 +48,11 @@ def fill_endpoints(services, base_url):
publicURL = join_urls(base_url, prefix, version) publicURL = join_urls(base_url, prefix, version)
set_path(endpoint, 'publicURL', publicURL) set_path(endpoint, 'publicURL', publicURL)
def filter_public(services):
public_services = {}
for name, service in services.iteritems():
if service.get('public', False):
public_services[name] = deepcopy(service)
return public_services
...@@ -34,11 +34,12 @@ ...@@ -34,11 +34,12 @@
from django.utils import simplejson as json from django.utils import simplejson as json
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from synnefo.cyclades_settings import cyclades_services from synnefo.cyclades_settings import cyclades_services
from synnefo.lib.services import filter_public
class Command(NoArgsCommand): class Command(NoArgsCommand):
help = "Export Cyclades services in JSON format." help = "Export Cyclades services in JSON format."
def handle(self, *args, **options): def handle(self, *args, **options):
output = json.dumps(cyclades_services, indent=4) output = json.dumps(filter_public(cyclades_services), indent=4)
self.stdout.write(output + "\n") self.stdout.write(output + "\n")
...@@ -34,11 +34,12 @@ ...@@ -34,11 +34,12 @@
from django.utils import simplejson as json from django.utils import simplejson as json
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from pithos.api.settings import pithos_services from pithos.api.settings import pithos_services
from synnefo.lib.services import filter_public
class Command(NoArgsCommand): class Command(NoArgsCommand):
help = "Export Pithos services in JSON format." help = "Export Pithos services in JSON format."
def handle(self, *args, **options): def handle(self, *args, **options):
output = json.dumps(pithos_services, indent=4) output = json.dumps(filter_public(pithos_services), indent=4)
self.stdout.write(output + "\n") self.stdout.write(output + "\n")
...@@ -57,7 +57,7 @@ pithos_services = { ...@@ -57,7 +57,7 @@ pithos_services = {
'type': 'pithos_ui', 'type': 'pithos_ui',
'component': 'pithos', 'component': 'pithos',
'prefix': 'ui', 'prefix': 'ui',
'public': True, 'public': False,
'endpoints': [ 'endpoints': [
{'versionId': '', {'versionId': '',
'publicURL': None}, 'publicURL': None},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment