Merge remote-tracking branch 'upstream/master'
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Mon, 10 Apr 2017 09:51:20 +0000 (11:51 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Mon, 10 Apr 2017 09:51:20 +0000 (11:51 +0200)
Conflicts:
src/emuvim/api/sonata/dummygatekeeper.py

1  2 
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/dashboard/__init__.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))
  
-             # 4. do the dc.startCompute(name="foobar") call to run the container
 +            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. 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
  
              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):
index 45ad698,0000000..45ad698
mode 100644,000000..100755
--- /dev/null