Add flag to the topology file to auto-deploy an uploaded service.
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 14 Apr 2017 14:09:21 +0000 (16:09 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 14 Apr 2017 14:09:21 +0000 (16:09 +0200)
src/emuvim/api/sonata/__init__.py
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/examples/sonata_simple_topology.py

index 613191c..af891d3 100755 (executable)
@@ -46,12 +46,13 @@ class SonataDummyGatekeeperEndpoint(object):
     topology.
     """
 
-    def __init__(self, listenip, port, deploy_sap=False, docker_management=True):
+    def __init__(self, listenip, port, deploy_sap=False, docker_management=False, auto_deploy=False):
         self.dcs = {}
         self.ip = listenip
         self.port = port
         dgk.DEPLOY_SAP = deploy_sap
         dgk.USE_DOCKER_MGMT = docker_management
+        dgk.AUTODEPLOY = auto_deploy
         logging.debug("Created API endpoint %s" % self)
 
     def __repr__(self):
index ff217f0..5d54d33 100755 (executable)
@@ -74,7 +74,10 @@ DEPLOY_SAP = False
 BIDIRECTIONAL_CHAIN = False
 
 # override the management interfaces in the descriptors with default docker0 interfaces in the containers
-USE_DOCKER_MGMT = True
+USE_DOCKER_MGMT = False
+
+# automatically deploy uploaded packages (no need to execute son-access deploy --latest separately)
+AUTO_DEPLOY = True
 
 def generate_subnets(prefix, base, subnet_size=50, mask=24):
     # Generate a list of ipaddress in subnets
@@ -938,6 +941,12 @@ class Packages(fr.Resource):
             # create a service object and register it
             s = Service(service_uuid, file_hash, upload_path)
             GK.register_service_package(service_uuid, s)
+
+            # automatically deploy the service
+            if AUTO_DEPLOY:
+                # ok, we have a service uuid, lets start the service
+                service_instance_uuid = GK.services.get(service_uuid).start_service()
+
             # generate the JSON result
             return {"service_uuid": service_uuid, "size": size, "sha1": file_hash, "error": None}, 201
         except Exception as ex:
index 0627247..1339ec7 100755 (executable)
@@ -58,7 +58,7 @@ def create_topology1():
     rapi1.start()
 
     # add the SONATA dummy gatekeeper to each DC
-    sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=True)
+    sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=True, auto_deploy=True, docker_management=True)
     sdkg1.connectDatacenter(dc1)
     # run the dummy gatekeeper (in another thread, don't block)
     sdkg1.start()