Commit 71faf4ec authored by Lukas Burgey's avatar Lukas Burgey

Rework client config view

parent 68673d49
......@@ -78,19 +78,8 @@ class ResponseView(views.APIView):
class ConfigurationView(views.APIView):
authentication_classes = AUTHENTICATION_CLASSES
def put(self, request):
# the site where client is located
client_site = None
try:
client_site = request.user.site
except models.Site.DoesNotExist:
raise ImproperlyConfigured("client has no site")
# services = request.data.get('services', None)
group_to_services = request.data.get('group_to_services', {})
entitlement_to_services = request.data.get('entitlement_to_services', {})
@staticmethod
def handle_group_to_services(site, group_to_services):
for group_name, group_service_list in group_to_services.items():
group = Group.get_group(
name=group_name,
......@@ -117,16 +106,18 @@ class ConfigurationView(views.APIView):
service.vos.add(group)
except models.Service.DoesNotExist:
LOGGER.info("Site %s pushed new service %s", client_site, name)
LOGGER.info("Site %s pushed new service %s", site, name)
service = models.Service(
name=name,
description=description,
)
service.save()
service.vos.add(group)
service.site.add(client_site)
service.site.add(site)
service.handle_vo_deployments()
@staticmethod
def handle_entitlement_to_services(site, entitlement_to_services):
for entitlement_name, entitlement_service_list in entitlement_to_services.items():
entitlement = Entitlement.get_entitlement(
name=entitlement_name,
......@@ -153,19 +144,36 @@ class ConfigurationView(views.APIView):
service.vos.add(entitlement)
except models.Service.DoesNotExist:
LOGGER.info("Site %s pushed new service %s", client_site, name)
LOGGER.info("Site %s pushed new service %s", site, name)
service = models.Service(
name=name,
description=description,
)
service.save()
service.vos.add(entitlement)
service.site.add(client_site)
service.site.add(site)
service.handle_vo_deployments()
def put(self, request):
# the site where client is located
client_site = None
try:
client_site = request.user.site
except models.Site.DoesNotExist:
raise ImproperlyConfigured("client has no site")
group_to_services = request.data.get('group_to_services', None)
if group_to_services is not None:
self.handle_group_to_services(client_site, group_to_services)
entitlement_to_services = request.data.get('entitlement_to_services', {})
if entitlement_to_services is not None:
self.handle_entitlement_to_services(client_site, entitlement_to_services)
# TODO deactivate vanished services
# init the broker, just in case
# initialize the broker, just in case
broker = models.RabbitMQInstance.load()
broker.initialize()
......
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