return directory_name, package_name
def charms_search(self, descriptor_file, desc_type):
- self._logger.debug("")
+ self._logger.debug("descriptor_file: {}, desc_type: {}".format(descriptor_file,
+ desc_type))
with open("{}".format(descriptor_file)) as yaml_desc:
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_sol006_dict(descriptor_dict, desc_type)
- else:
+ #self._logger.debug("\n"+yaml.safe_dump(descriptor_dict, indent=4, default_flow_style=False))
+
+ if ( (desc_type=="vnf" and ("vnfd:vnfd-catalog" in descriptor_dict or "vnfd-catalog" in descriptor_dict)) or
+ (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ):
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
hash_md5.update(chunk)
return hash_md5.hexdigest()
- def fields_building(self, descriptor_json, file, package_type):
+ def fields_building(self, descriptor_dict, file, package_type):
"""
From an artifact descriptor, obtain the fields required for indexing
- :param descriptor_json: artifact description
+ :param descriptor_dict: artifact description
:param file: artifact package
:param package_type: type of artifact (vnf or ns)
:return: fields
base_path = '/{}/'.format(package_type)
aux_dict = {}
if package_type == "vnf":
- if descriptor_json.get('vnfd-catalog', False):
- aux_dict = descriptor_json.get('vnfd-catalog', {}).get('vnfd', [{}])[0]
+ if descriptor_dict.get('vnfd-catalog', False):
+ aux_dict = descriptor_dict.get('vnfd-catalog', {}).get('vnfd', [{}])[0]
else:
- aux_dict = descriptor_json.get('vnfd:vnfd-catalog', {}).get('vnfd', [{}])[0]
+ aux_dict = descriptor_dict.get('vnfd:vnfd-catalog', {}).get('vnfd', [{}])[0]
images = []
for vdu in aux_dict.get('vdu', ()):
images.append(vdu.get('image'))
fields['images'] = images
if package_type == "ns":
- if descriptor_json.get('nsd-catalog', False):
- aux_dict = descriptor_json.get('nsd-catalog', {}).get('nsd', [{}])[0]
+ if descriptor_dict.get('nsd-catalog', False):
+ aux_dict = descriptor_dict.get('nsd-catalog', {}).get('nsd', [{}])[0]
else:
- aux_dict = descriptor_json.get('nsd:nsd-catalog', {}).get('nsd', [{}])[0]
+ aux_dict = descriptor_dict.get('nsd:nsd-catalog', {}).get('nsd', [{}])[0]
vnfs = []
with open(descriptor_file, 'r') as f:
descriptor_data = f.read()
validation = validation_im()
- desc_type, descriptor_data = validation.yaml_validation(descriptor_data)
- validation_im.pyangbind_validation(self, desc_type, descriptor_data)
- if 'vnf' in list(descriptor_data.keys())[0]:
+ desc_type, descriptor_dict = validation.yaml_validation(descriptor_data)
+ validation_im.pyangbind_validation(self, desc_type, descriptor_dict)
+ if 'vnf' in list(descriptor_dict.keys())[0]:
package_type = 'vnf'
else:
# raise ClientException("Not VNF package")
package_type = 'ns'
- self._logger.debug("Descriptor: {}".format(descriptor_data))
- fields = self.fields_building(descriptor_data, path, package_type)
+ self._logger.debug("Descriptor: {}".format(descriptor_dict))
+ fields = self.fields_building(descriptor_dict, path, package_type)
self._logger.debug("Descriptor sucessfully validated")
return {"detail": "{}D successfully validated".format(package_type.upper()),
"code": "OK"}, True, fields, package_type