UPLOAD_FOLDER = os.path.join(GK_STORAGE, "uploads/")
CATALOG_FOLDER = os.path.join(GK_STORAGE, "catalog/")
+# Enable Dockerfile build functionality
+BUILD_DOCKERFILE = False
+
# flag to indicate that we run without the emulator (only the bare API for integration testing)
GK_STANDALONE_MODE = False
self.nsd = None
self.vnfds = dict()
self.local_docker_files = dict()
+ self.remote_docker_image_urls = dict()
self.instances = dict()
def onboard(self):
self._load_package_descriptor()
self._load_nsd()
self._load_vnfd()
- self._load_docker_files()
# 3. prepare container images (e.g. download or build Dockerfile)
- self._build_images_from_dockerfiles()
- self._download_predefined_dockerimages()
-
+ if BUILD_DOCKERFILE:
+ self._load_docker_files()
+ self._build_images_from_dockerfiles()
+ else:
+ self._load_docker_urls()
+ self._pull_predefined_dockerimages()
LOG.info("On-boarded service: %r" % self.manifest.get("package_name"))
def start_service(self):
"""
unzip *.son file and store contents in CATALOG_FOLDER/services/<service_uuid>/
"""
+ LOG.info("Unzipping: %r" % self.package_file_path)
with zipfile.ZipFile(self.package_file_path, "r") as z:
z.extractall(self.package_content_path)
+
def _load_package_descriptor(self):
"""
Load the main package descriptor YAML and keep it as dict.
self.local_docker_files[k] = docker_path
LOG.debug("Found Dockerfile: %r" % docker_path)
+ def _load_docker_urls(self):
+ """
+ Get all URLs to pre-build docker images in some repo.
+ :return:
+ """
+ for k, v in self.vnfds.iteritems():
+ for vu in v.get("virtual_deployment_units"):
+ if vu.get("vm_image_format") == "docker":
+ self.remote_docker_image_urls[k] = vu.get("vm_image")
+ LOG.debug("Found Docker image URL: %r" % self.remote_docker_image_urls[k])
+
def _build_images_from_dockerfiles(self):
"""
Build Docker images for each local Dockerfile found in the package: self.local_docker_files
LOG.debug("DOCKER BUILD: %s" % line)
LOG.info("Docker image created: %s" % k)
- def _download_predefined_dockerimages(self):
+ def _pull_predefined_dockerimages(self):
"""
If the package contains URLs to pre-build Docker images, we download them with this method.
"""
- # TODO implement this if we want to be able to download docker images instead of building them
+ # TODO implement this
pass
def _check_docker_image_exists(self, image_name):