Commit 001dd869 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Adapt clientapi to the service model change

parent 9a8cc0cb
...@@ -38,14 +38,20 @@ class PubSubConnection: ...@@ -38,14 +38,20 @@ class PubSubConnection:
return False return False
def publish_by_service(self, service, message): def publish_by_service(self, service, message):
if not RabbitMQInstance().is_client_connected(service.site): for site in service.site.all():
print('Client for service {} is not online'.format(service)) self.publish_by_service_and_site(service, site, message)
def publish_by_service_and_site(self, service, site, message):
if not RabbitMQInstance().is_client_connected(site):
print('Client for site {} is not online'.format(site))
return False return False
print('Client for service {} is online'.format(service)) print('Client for site {} is online'.format(site))
self.connect() self.connect()
print('Sent deployment update for service {}'.format(service)) print('Sent deployment update for service {} sent to client of site {}'
.format(service, site)
)
# True if the client acked the message # True if the client acked the message
delivery_confirmed = self.channel.basic_publish( delivery_confirmed = self.channel.basic_publish(
......
...@@ -16,7 +16,7 @@ class SiteSerializer(serializers.ModelSerializer): ...@@ -16,7 +16,7 @@ class SiteSerializer(serializers.ModelSerializer):
class ServiceSerializer(serializers.ModelSerializer): class ServiceSerializer(serializers.ModelSerializer):
site = SiteSerializer() site = SiteSerializer(many=True)
groups = GroupSerializer(many=True) groups = GroupSerializer(many=True)
class Meta: class Meta:
......
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