Пример #1
0
 def _pack(self, proj_path, pkg_path):
     """
     Wraps the tng-sdk-package packaging functionality.
     """
     args = [
         "--package", proj_path,
         "--output", pkg_path,
         "--store-backend", "TangoProjectFilesystemBackend",
         "--format", "eu.5gtango",
         "--quiet",
         "--offline",
         "--loglevel"
     ]
     if self.args.verbose:
         args.append("info")
         # args.append("-v")
     else:
         args.append("error")
     # Hotfix: Always skip validateion here, because vim-emu treats
     # some fields, like vcpus as type stirng not int etc.
     if self.args.skip_validation or True:
         args.append("--skip-validation")
     # be sure that output dir is there
     ensure_dir(pkg_path)
     # call the package component
     LOG.debug("Calling package with args: {}".format(args))
     r = tngpkg.run(args)
     if r.error is not None:
         raise BaseException("Can't create package {}: {}"
                             .format(pkg_path, r.error))
     # return the full path to the package
     pkg_path = r.metadata.get("_storage_location")
     LOG.debug("Packed {} to {}".format(proj_path, pkg_path))
     return pkg_path
Пример #2
0
 def _unpack(self, pkg_path, proj_path):
     """
     Wraps the tng-sdk-package unpacking functionality.
     """
     args = [
         "--unpackage", pkg_path,
         "--output", proj_path,
         "--store-backend", "TangoProjectFilesystemBackend",
         "--format", "eu.5gtango",
         "--quiet",
         "--offline",
         "--loglevel"
     ]
     if self.args.verbose:
         args.append("info")
         # args.append("-v")
     else:
         args.append("error")
     if self.args.skip_validation:
         args.append("--skip-validation")
     # call the package component
     r = tngpkg.run(args)
     if r.error is not None:
         raise BaseException("Can't read package {}: {}"
                             .format(pkg_path, r.error))
     # return the full path to the project
     proj_path = r.metadata.get("_storage_location")
     LOG.debug("Unpacked {} to {}".format(pkg_path, proj_path))
     return proj_path
Пример #3
0
 def _pack(self, proj_path, pkg_path):
     """
     Wraps the tng-sdk-package packaging functionality.
     """
     args = [
         "--package", proj_path,
         "--output", pkg_path,
         "--store-backend", "TangoProjectFilesystemBackend",
         "--quiet",
         "--loglevel"
     ]
     if self.args.verbose:
         args.append("info")
     else:
         args.append("warning")
     # be sure that output dir is there
     ensure_dir(pkg_path)
     # call the package component
     r = tngpkg.run(args)
     if r.error is not None:
         raise BaseException("Can't create package {}: {}"
                             .format(pkg_path, r.error))
     # return the full path to the package
     pkg_path = r.metadata.get("_storage_location")
     LOG.debug("Packed {} to {}".format(proj_path, pkg_path))
     return pkg_path
 def test_pyapi_package_auto_name(self):
     # specify output dir. but not file name.
     pkg_path = tempfile.mkdtemp()
     args = [
         "--package", "misc/5gtango_ns_project_example1/", "--output",
         pkg_path
     ]
     r = tngpkg.run(args)
     self.assertIsNone(r.error)
     self.assertTrue(os.path.exists(pkg_path))
     shutil.rmtree(pkg_path)
 def test_pyapi_unpackage(self):
     tempdir = tempfile.mkdtemp()
     # set arguments using a list
     args = [
         "--unpackage", "misc/5gtango-ns-package-example.tgo", "--output",
         tempdir, "--store-backend", "TangoProjectFilesystemBackend"
     ]
     r = tngpkg.run(args)
     self.assertIsNone(r.error)
     self.assertTrue(
         os.path.exists(
             os.path.join(tempdir,
                          "5gtango-ns-package-example/project.yml")))
     shutil.rmtree(tempdir)
Пример #6
0
 def _unpack(self, pkg_path, proj_path):
     """
     Wraps the tng-sdk-package unpacking functionality.
     """
     args = [
         "--unpackage", pkg_path, "--output", proj_path, "--store-backend",
         "TangoProjectFilesystemBackend", "--format", "eu.5gtango",
         "--skip-validation", "--quiet", "--offline"
     ]
     r = tngpkg.run(args)
     if r.error is not None:
         raise BaseException("Can't read package {}: {}".format(
             pkg_path, r.error))
     # return the full path to the project
     proj_path = r.metadata.get("_storage_location")
     return proj_path