print('Building charm {}/charms/layers/{}'.format(package_folder, charmName))
self.charm_build(package_folder, charmName)
print('Charm built: {}'.format(charmName))
+ elif os.path.isdir('{}/charms/ops/{}'.format(package_folder, charmName)):
+ self.charmcraft_build(package_folder, charmName)
else:
if not os.path.isdir('{}/charms/{}'.format(package_folder, charmName)):
raise ClientException('The charm: {} referenced in the descriptor file '
raise ClientException("failed to build the charm: {}".format(src_folder))
self._logger.verbose("charm {} built".format(src_folder))
+ def charmcraft_build(self, package_folder, charm_name):
+ """
+ Build the charms inside the package (new operator framework charms)
+ params: package_folder is the name of the folder where is the charms to compile.
+ build_name is the name of the layer or interface
+ """
+ self._logger.debug("Building charm {}".format(charm_name))
+ src_folder = f"{package_folder}/charms/ops/{charm_name}"
+ current_directory = os.getcwd()
+ os.chdir(src_folder)
+ try:
+ result = subprocess.run(["charmcraft", "build"])
+ if result.returncode == 1:
+ raise ClientException("failed to build the charm: {}".format(src_folder))
+ subprocess.run(["rm", "-rf", f"../../{charm_name}"])
+ subprocess.run(["mv", "build", f"../../{charm_name}"])
+ self._logger.verbose("charm {} built".format(src_folder))
+ finally:
+ os.chdir(current_directory)
+
def build_tarfile(self, package_folder, charm_list=None):
"""
Creates a .tar.gz file given a package_folder
def _charms_search_on_vnfd_sol006_dict(self, sol006_dict):
self._logger.debug("")
charms_list = []
- for k1, v1 in sol006_dict.items():
- for k2, v2 in v1.items():
- if k2 == "df":
- for df in v2:
- lcm_ops = df.get("lcm-operations-configuration", {})
- ops_config = lcm_ops.get("operate-vnf-op-config", {})
- for day_12_config in ops_config.get("day1-2", []):
- self._logger.debug("Execution environment found")
- for ee in day_12_config.get("execution-environment-list", []):
- if "juju" in ee:
- charms_list.append((ee["juju"]['charm']))
+ dfs = sol006_dict.get("vnfd", {}).get("df", [])
+ for df in dfs:
+ day_1_2s = df.get("lcm-operations-configuration", {}).get("operate-vnf-op-config", {}).get("day1-2")
+ for day_1_2 in day_1_2s:
+ exec_env_list = day_1_2.get("execution-environment-list", [])
+ for exec_env in exec_env_list:
+ if "juju" in exec_env and "charm" in exec_env["juju"]:
+ charms_list.append(exec_env["juju"]["charm"])
return charms_list
def _charms_search_on_nsd_sol006_dict(self, sol006_dict):
description=_description,
license='Apache 2',
install_requires=[
- 'Click', 'prettytable', 'pyyaml', 'pycurl', 'python-magic',
- 'jinja2', 'osm-im', 'verboselogs', 'packaging', 'requests',
+ 'Click', 'prettytable', 'pyyaml==5.3.1', 'pycurl', 'python-magic',
+ 'jinja2==2.11.2', 'osm-im', 'verboselogs', 'packaging',
+ 'requests==2.24.0', 'charmcraft',
],
setup_requires=['setuptools-version-command'],
test_suite='nose.collector',