def charms_search(self, descriptor_file, desc_type):
self._logger.debug("")
- dict = {}
- 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():
- 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']
- 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
-
+ descriptor_dict = yaml.safe_load(yaml_desc)
+ if "catalog" in descriptor_dict: # Match OSM-IM vnfd-catalog and nsd-catalog
+ charms_list = self._charms_search_on_osm_im_dict(descriptor_dict, desc_type)
+ else:
+ charms_list = self._charms_search_on_sol006_dict(descriptor_dict, desc_type)
+
+ return charms_list
+
+ def _charms_search_on_osm_im_dict(self, osm_im_dict, desc_type):
+ charms_list = []
+ for k1, v1 in osm_im_dict.items():
+ for k2, v2 in v1.items():
+ for entry in v2:
+ if '{}-configuration'.format(desc_type) in entry:
+ vnf_config = entry['{}-configuration'.format(desc_type)]
+ for k3, v3 in vnf_config.items():
+ if 'charm' in v3:
+ charms_list.append((v3['charm']))
+ if 'vdu' in entry:
+ vdus = entry['vdu']
+ for vdu in vdus:
+ if 'vdu-configuration' in vdu:
+ for k4, v4 in vdu['vdu-configuration'].items():
+ if 'charm' in v4:
+ charms_list.append((v4['charm']))
+ return charms_list
+
+ def _charms_search_on_sol006_dict(self, sol006_dict, desc_type):
+ charms_list = []
+ for k1, v1 in sol006_dict.items():
+ for k2, v2 in v1.items():
+ if '{}-configuration'.format(desc_type) in k2:
+ for vnf_config in v2:
+ for k3, v3 in vnf_config.items():
+ if 'charm' in v3:
+ charms_list.append((v3['charm']))
+ if 'vdu-configuration' in k2:
+ for vdu_config in v2:
+ for k3, v3 in vdu_config.items():
+ if 'charm' in v3:
+ charms_list.append((v3['charm']))
+ return charms_list
\ No newline at end of file