self.create_files(structure["files"], output, package_type)
return "Created"
- def validate(self, base_directory, recursive=True):
+ def validate(self, base_directory, recursive=True, old_format=False):
"""
**Validate OSM Descriptors given a path**
desc_type = "-"
try:
desc_type, descriptor_data = validation_im.yaml_validation(self, descriptor_data)
+ if not old_format:
+ if ( desc_type=="vnfd" or desc_type=="nsd" ):
+ print("OSM descriptor '{}' written in an unsupported format. Please update to ETSI SOL006 format".format(desc_path))
+ print("Package validation skipped. It can still be done with 'osm package-validate --old'")
+ print("Package build can still be done with 'osm package-build --skip-validation'")
+ raise Exception("Not SOL006 format")
validation_im.pyangbind_validation(self, desc_type, descriptor_data)
table.append({"type": desc_type, "path": desc_path, "valid": "OK", "error": "-"})
except Exception as e:
- package_type: is the type of package to be created
:return: None
"""
-
+ self._logger.debug("")
for folder in folders:
try:
# print("Folder {} == package_type {}".format(folder[1], package_type))
- file_body: is the content of the file
:return: None
"""
+ self._logger.debug("")
print("Creating file: \t{}".format(file_name))
try:
with open(file_name, "w+") as f:
:returns: readme content
"""
+ self._logger.debug("")
return """# Descriptor created by OSM descriptor package generated\n\n**Created on {} **""".format(
time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()))
:returns: cloud-init content
"""
+ self._logger.debug("")
return "---\n#cloud-config"
def create_files(self, files, file_content, package_type):
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
def _charms_search_on_osm_im_dict(self, osm_im_dict, desc_type):
+ self._logger.debug("")
charms_list = []
for k1, v1 in osm_im_dict.items():
for k2, v2 in v1.items():
return charms_list
def _charms_search_on_sol006_dict(self, sol006_dict, desc_type):
+ self._logger.debug("")
charms_list = []
for k1, v1 in sol006_dict.items():
for k2, v2 in v1.items():