X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Femuvim%2Fapi%2Fsonata%2Fdummygatekeeper.py;h=916e168769a5a65f152c34bd6f20db8af5affc98;hb=aa6d3a7011e65bcf65670f6d4962a28af66d2099;hp=715432ebee9518e1219640b7558e766e3ddc3f04;hpb=6b5224d7f2f9c52802b37d5454ac02a8fe2c6634;p=osm%2Fvim-emu.git diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index 715432e..916e168 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -166,7 +166,9 @@ class Service(object): fwd_links = self.nsd["forwarding_graphs"][0]["constituent_virtual_links"] eline_fwd_links = [l for l in vlinks if (l["id"] in fwd_links) and (l["connectivity_type"] == "E-Line")] - cookie = 1 # not clear why this is needed - to check with Steven + # cookie is used as identifier for the flowrules installed by the dummygatekeeper + # eg. different services get a unique cookie for their flowrules + cookie = 1 for link in eline_fwd_links: src_id, src_if_name = link["connection_points_reference"][0].split(":") dst_id, dst_if_name = link["connection_points_reference"][1].split(":") @@ -187,7 +189,6 @@ class Service(object): src_docker_name, dst_docker_name, vnf_src_interface=src_if_name, vnf_dst_interface=dst_if_name, bidirectional=True, cmd="add-flow", cookie=cookie) - cookie += 1 # re-configure the VNFs IP assignment and ensure that a new subnet is used for each E-Link src_vnfi = self._get_vnf_instance(instance_uuid, src_name) @@ -225,7 +226,16 @@ 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() + + # 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") @@ -462,6 +472,7 @@ class Packages(fr.Resource): Return a list of UUID's of uploaded service packages. :return: dict/list """ + LOG.info("GET /packages") return {"service_uuid_list": list(GK.services.iterkeys())} @@ -493,7 +504,8 @@ class Instantiations(fr.Resource): Returns a list of UUIDs containing all running services. :return: dict / list """ - return {"service_instance_list": [ + LOG.info("GET /instantiations") + return {"service_instantiations_list": [ list(s.instances.iterkeys()) for s in GK.services.itervalues()]}