dummy GK now executes emulator specific entrypoint scripts specified in Dockerfiles...
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 21 Jun 2016 07:03:35 +0000 (09:03 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 21 Jun 2016 07:03:35 +0000 (09:03 +0200)
src/emuvim/api/sonata/README.md
src/emuvim/api/sonata/dummygatekeeper.py

index 6fdc5ce..d662f1e 100755 (executable)
@@ -37,6 +37,16 @@ To list all running services do:
 
 * `curl http://127.0.0.1:5000/instantiations`
 
+## VNF Requirements
+
+A VNF container that is used with the dummy gatekeeper should specify a emulator specific entrypoint script in its Dockerfile:
+
+* `ENV SON_EMU_CMD ./start.sh`
+
+This script is called by the dummy gatekeeper after a VNF was started and the chaining was done. The script can then be used to trigger the execution of individual VNF software.
+
+ATTENTION: The specified script must not block!
+
 ## API definition
 
 This page describes the dummy gatekeeper API. This gatekeeper fakes the original platform gatekeeper during development SDK tools like son-push. 
index c5de3cc..c6421dc 100755 (executable)
@@ -152,6 +152,9 @@ class Service(object):
                 ret = network.setChain(src_vnf, dst_vnf, vnf_src_interface=src_port, vnf_dst_interface=dst_port, bidirectional = True, cmd="add-flow", cookie = cookie)
                 cookie += 1
 
+        # 4. run the emulator specific entrypoint scripts in the VNFIs of this service instance
+        self._trigger_emulator_start_scripts_in_vnfis(self.instances[instance_uuid]["vnf_instances"])
+
         LOG.info("Service started. Instance id: %r" % instance_uuid)
         return instance_uuid
 
@@ -180,9 +183,18 @@ class Service(object):
             self.vnfname2num[vnf_name] = GK.get_next_vnf_name()
             LOG.info("VNF "+vnf_name+" mapped to "+self.vnfname2num[vnf_name]+" on dc "+str(vnfd.get("dc")))
             vnfi = target_dc.startCompute(self.vnfname2num[vnf_name], network=intfs, image=docker_name, flavor_name="small")
-            # 6. store references to the compute objects in self.instances
             return vnfi
 
+    def _trigger_emulator_start_scripts_in_vnfis(self, vnfi_list):
+        for vnfi in vnfi_list:
+            config = vnfi.dcinfo.get("Config", dict())
+            env = config.get("Env", list())
+            for env_var in env:
+                if "SON_EMU_CMD=" in env_var:
+                    cmd = str(env_var.split("=")[1])
+                    LOG.info("Executing entrypoint script in %r: %r" % (vnfi.name, cmd))
+                    vnfi.cmdPrint(cmd)
+
     def _unpack_service_package(self):
         """
         unzip *.son file and store contents in CATALOG_FOLDER/services/<service_uuid>/