import shutil
import yaml
import logging
+import pathlib
+
class PackageTool(object):
def __init__(self, client=None):
def charms_search(self, descriptor_file, desc_type):
self._logger.debug("")
- dict = {}
- list = []
+
+ descriptor_dict = {}
+ charm_list = []
+ bundle_list = []
+
with open("{}".format(descriptor_file)) as yaml_desc:
- dict = yaml.safe_load(yaml_desc)
- for k1, v1 in dict.items():
- for k2, v2 in v1.items():
+ descriptor_dict = yaml.safe_load(yaml_desc)
+ for _, v1 in descriptor_dict.items():
+ for _, v2 in v1.items():
for entry in v2:
- if '{}-configuration'.format(desc_type) in entry:
- name = entry['{}-configuration'.format(desc_type)]
- for k3, v3 in name.items():
- if 'charm' in v3:
- list.append((v3['charm']))
- if 'vdu' in entry:
- name = entry['vdu']
+ if "{}-configuration".format(desc_type) in entry:
+ name = entry["{}-configuration".format(desc_type)]
+ for _, v3 in name.items():
+ if "charm" in v3:
+ charm_list.append((v3["charm"]))
+ if "vdu" in entry:
+ name = entry["vdu"]
for vdu in name:
- if 'vdu-configuration' in vdu:
- for k4, v4 in vdu['vdu-configuration'].items():
- if 'charm' in v4:
- list.append((v4['charm']))
- return list
+ if "vdu-configuration" in vdu:
+ for _, v4 in vdu["vdu-configuration"].items():
+ if "charm" in v4:
+ charm_list.append((v4["charm"]))
+ if "kdu" in entry:
+ name = entry["kdu"]
+ for kdu in name:
+ if "juju-bundle" in kdu:
+ bundle_list.append(kdu["juju-bundle"])
+
+ path = pathlib.Path(descriptor_file).parent
+ for bundle in bundle_list:
+ descriptor_dict = {}
+ with open("{}/juju-bundles/{}".format(path, bundle)) as yaml_desc:
+ descriptor_dict = yaml.safe_load(yaml_desc)
+ if "applications" in descriptor_dict:
+ for _, v in descriptor_dict["applications"].items():
+ charm_list.append(pathlib.Path(v["charm"]).name)
+
+ return charm_list
description=_description,
license='Apache 2',
install_requires=[
- 'Click', 'prettytable', 'pyyaml', 'pycurl', 'python-magic',
+ 'Click', 'prettytable<=1.0.1', 'pyyaml', 'pycurl', 'python-magic',
'jinja2', 'osm-im', 'verboselogs', 'packaging', 'ruamel.yaml',
'requests'
],