From 4b30b876b197d05b09f34d1ae4b57e331165d0fa Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 2 Dec 2020 23:10:14 +0000 Subject: [PATCH] Validation will fail by default if not using SOL006 format Change-Id: I343ba1dbc1dc3b047af08366dea68d403ee04545 Signed-off-by: garciadeblas --- osmclient/common/package_tool.py | 9 ++++++++- osmclient/scripts/osm.py | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/osmclient/common/package_tool.py b/osmclient/common/package_tool.py index 7229565..1457e79 100644 --- a/osmclient/common/package_tool.py +++ b/osmclient/common/package_tool.py @@ -86,7 +86,7 @@ class PackageTool(object): 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** @@ -109,6 +109,12 @@ class PackageTool(object): 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: @@ -217,6 +223,7 @@ class PackageTool(object): :returns: cloud-init content """ + self._logger.debug("") return "---\n#cloud-config" def create_files(self, files, file_content, package_type): diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index c97f984..3af70c6 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -543,7 +543,7 @@ def vnfd_list(ctx, nf_type, filter, long): table = PrettyTable(['nfpkg name', 'id', 'desc type']) for vnfd in resp: name = vnfd.get('id', vnfd.get('name','-')) - descriptor_type = 'sol005' if 'product-name' in vnfd else 'rel8' + descriptor_type = 'sol006' if 'product-name' in vnfd else 'rel8' if long: onb_state = vnfd['_admin'].get('onboardingState','-') op_state = vnfd['_admin'].get('operationalState','-') @@ -4312,7 +4312,7 @@ def package_create(ctx, # exit(1) @cli_osm.command(name='package-validate', - short_help='Validate a package descriptor') + short_help='Validate a package descriptor') @click.argument('base-directory', default=".", required=False) @@ -4320,10 +4320,15 @@ def package_create(ctx, default=True, help='The activated recursive option will validate the yaml files' ' within the indicated directory and in its subdirectories') +@click.option('--old', + is_flag=True, + default=False, + help='Validates also the descriptors using the previous OSM format (pre SOL006)') @click.pass_context def package_validate(ctx, base_directory, - recursive): + recursive, + old): """ Validate descriptors given a base directory. @@ -4332,7 +4337,7 @@ def package_validate(ctx, """ # try: check_client_version(ctx.obj, ctx.command.name) - results = ctx.obj.package_tool.validate(base_directory, recursive) + results = ctx.obj.package_tool.validate(base_directory, recursive, old) table = PrettyTable() table.field_names = ["TYPE", "PATH", "VALID", "ERROR"] # Print the dictionary generated by the validation function -- 2.25.1