From: stevenvanrossem Date: Mon, 10 Apr 2017 09:51:20 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: v3.1~33^2~2 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=commitdiff_plain;h=c911ca6a6560d062fed5d294bc5a80c26da69672 Merge remote-tracking branch 'upstream/master' Conflicts: src/emuvim/api/sonata/dummygatekeeper.py --- c911ca6a6560d062fed5d294bc5a80c26da69672 diff --cc src/emuvim/api/sonata/dummygatekeeper.py index 76ed3c2,93d5cda..59960a9 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@@ -293,30 -345,22 +293,42 @@@ class Service(object) mem_lim = int(mem_limit) cpu_period, cpu_quota = self._calculate_cpu_cfs_values(float(cpu_bw)) + 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"]))) + + # check if we need to deploy the management ports (defined as type:management both on in the vnfd and nsd) + intfs = vnfd.get("connection_points", []) + mgmt_intf_names = [] + if USE_DOCKER_MGMT: + vnf_id = vnf_name2id[vnf_name] + mgmt_intfs = [vnf_id + ':' + intf['id'] for intf in intfs if intf.get('type') == 'management'] + # check if any of these management interfaces are used in a management-type network in the nsd + for nsd_intf_name in mgmt_intfs: + vlinks = [ l["connection_points_reference"] for l in self.nsd.get("virtual_links", [])] + for link in vlinks: + if nsd_intf_name in link and self.check_mgmt_interface(link): + # this is indeed a management interface and can be skipped + vnf_id, vnf_interface, vnf_sap_docker_name = parse_interface(nsd_intf_name) + found_interfaces = [intf for intf in intfs if intf.get('id') == vnf_interface] + intfs.remove(found_interfaces[0]) + mgmt_intf_names.append(vnf_interface) + - # 4. do the dc.startCompute(name="foobar") call to run the container + # 4. generate the volume paths for the docker container + volumes=list() + # a volume to extract log files + docker_log_path = "/tmp/results/%s/%s"%(self.uuid,vnf_name) + LOG.debug("LOG path for vnf %s is %s."%(vnf_name,docker_log_path)) + if not os.path.exists(docker_log_path): + LOG.debug("Creating folder %s"%docker_log_path) + os.makedirs(docker_log_path) + + volumes.append(docker_log_path+":/mnt/share/") + + + # 5. do the dc.startCompute(name="foobar") call to run the container # TODO consider flavors, and other annotations - intfs = vnfd.get("connection_points") - # TODO: get all vnf id's from the nsd for this vnfd and use those as dockername # use the vnf_id in the nsd as docker name # so deployed containers can be easily mapped back to the nsd @@@ -325,14 -372,17 +337,22 @@@ 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", - cpu_quota=cpu_quota, cpu_period=cpu_period, cpuset=cpu_list, mem_limit=mem_lim) + vnfi = target_dc.startCompute( + self.vnf_name2docker_name[vnf_name], + network=intfs, + image=docker_name, + flavor_name="small", + cpu_quota=cpu_quota, + cpu_period=cpu_period, + cpuset=cpu_list, + mem_limit=mem_lim, + volumes=volumes) + + # rename the docker0 interfaces (eth0) to the management port name defined in the VNFD + if USE_DOCKER_MGMT: + for intf_name in mgmt_intf_names: + self._vnf_reconfigure_network(vnfi, 'eth0', new_name=intf_name) + return vnfi def _stop_vnfi(self, vnfi): diff --cc src/emuvim/dashboard/__init__.py index 45ad698,0000000..45ad698 mode 100644,000000..100755 --- a/src/emuvim/dashboard/__init__.py +++ b/src/emuvim/dashboard/__init__.py