Merge pull request #149 from stevenvanrossem/master
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 5 Aug 2016 13:48:15 +0000 (15:48 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 5 Aug 2016 13:48:15 +0000 (15:48 +0200)
use vnf_id from the nsd as contaienr name in the dummy GK

src/emuvim/api/sonata/dummygatekeeper.py

index 432c134..bea0a01 100755 (executable)
@@ -225,7 +225,18 @@ class Service(object):
             # 3. do the dc.startCompute(name="foobar") call to run the container
             # TODO consider flavors, and other annotations
             intfs = vnfd.get("connection_points")
-            self.vnf_name2docker_name[vnf_name] = GK.get_next_vnf_name()
+            # mgmt connection points can be skipped, this is considered to be the connection the default docker0 bridge
+            intfs = [intf for intf in intfs if 'mgmt' not in intf['id']]
+            
+            # use the vnf_id in the nsd as docker name
+            # so deployed containers can be easily mapped back to the nsd
+            vnf_name2id = defaultdict(lambda: "NotExistingNode",
+                                          reduce(lambda x, y: dict(x, **y),
+                                                 map(lambda d: {d["vnf_name"]: d["vnf_id"]},
+                                                     self.nsd["network_functions"])))
+            self.vnf_name2docker_name[vnf_name] = vnf_name2id[vnf_name]
+            # self.vnf_name2docker_name[vnf_name] = GK.get_next_vnf_name()
+
             LOG.info("Starting %r as %r in DC %r" % (vnf_name, self.vnf_name2docker_name[vnf_name], vnfd.get("dc")))
             LOG.debug("Interfaces for %r: %r" % (vnf_name, intfs))
             vnfi = target_dc.startCompute(self.vnf_name2docker_name[vnf_name], network=intfs, image=docker_name, flavor_name="small")