From: stevenvanrossem Date: Fri, 14 Apr 2017 14:09:21 +0000 (+0200) Subject: Add flag to the topology file to auto-deploy an uploaded service. X-Git-Tag: v3.1~30^2~31 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=4378f16256c242eccfd169a1e685e6aab2ed0e88;p=osm%2Fvim-emu.git Add flag to the topology file to auto-deploy an uploaded service. --- diff --git a/src/emuvim/api/sonata/__init__.py b/src/emuvim/api/sonata/__init__.py index 613191c..af891d3 100755 --- a/src/emuvim/api/sonata/__init__.py +++ b/src/emuvim/api/sonata/__init__.py @@ -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): diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index ff217f0..5d54d33 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -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: diff --git a/src/emuvim/examples/sonata_simple_topology.py b/src/emuvim/examples/sonata_simple_topology.py index 0627247..1339ec7 100755 --- a/src/emuvim/examples/sonata_simple_topology.py +++ b/src/emuvim/examples/sonata_simple_topology.py @@ -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()