+ def _load_package_descriptor(self):
+ """
+ Load the main package descriptor YAML and keep it as dict.
+ :return:
+ """
+ self.manifest = load_yaml(
+ os.path.join(
+ self.package_content_path, "META-INF/MANIFEST.MF"))
+
+ def _load_nsd(self):
+ """
+ Load the entry NSD YAML and keep it as dict.
+ :return:
+ """
+ if "entry_service_template" in self.manifest:
+ nsd_path = os.path.join(
+ self.package_content_path,
+ make_relative_path(self.manifest.get("entry_service_template")))
+ self.nsd = load_yaml(nsd_path)
+ LOG.debug("Loaded NSD: %r" % self.nsd.get("ns_name"))
+
+ def _load_vnfd(self):
+ """
+ Load all VNFD YAML files referenced in MANIFEST.MF and keep them in dict.
+ :return:
+ """
+ if "package_content" in self.manifest:
+ for pc in self.manifest.get("package_content"):
+ if pc.get("content-type") == "application/sonata.function_descriptor":
+ vnfd_path = os.path.join(
+ self.package_content_path,
+ make_relative_path(pc.get("name")))
+ vnfd = load_yaml(vnfd_path)
+ self.vnfds[vnfd.get("vnf_name")] = vnfd
+ LOG.debug("Loaded VNFD: %r" % vnfd.get("vnf_name"))
+
+ def _load_docker_files(self):
+ """
+ Get all paths to Dockerfiles from MANIFEST.MF and store them in dict.
+ :return:
+ """
+ if "package_content" in self.manifest:
+ for df in self.manifest.get("package_content"):
+ if df.get("content-type") == "application/sonata.docker_files":
+ docker_path = os.path.join(
+ self.package_content_path,
+ make_relative_path(df.get("name")))
+ # FIXME: Mapping to docker image names is hardcoded because of the missing mapping in the example package
+ self.local_docker_files[helper_map_docker_name(df.get("name"))] = docker_path
+ LOG.debug("Found Dockerfile: %r" % docker_path)
+
+ def _build_images_from_dockerfiles(self):
+ """
+ Build Docker images for each local Dockerfile found in the package: self.local_docker_files
+ """
+ dc = DockerClient()
+ LOG.info("Building %d Docker images (this may take several minutes) ..." % len(self.local_docker_files))
+ for k, v in self.local_docker_files.iteritems():
+ for line in dc.build(path=v.replace("Dockerfile", ""), tag=k, rm=False, nocache=False):
+ LOG.debug("DOCKER BUILD: %s" % line)
+ LOG.info("Docker image created: %s" % k)
+
+ def _download_predefined_dockerimages(self):
+ """
+ If the package contains URLs to pre-build Docker images, we download them with this method.
+ """
+ # TODO implement