From c214d9e7158f71ed040c544b9cb4ae8224cd83c4 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 8 Nov 2019 14:23:04 +0100 Subject: [PATCH] validation.py: fix class definition, vnfd and nsd first fields, improved message in Exceptions Change-Id: I0bd8094a20898cbf33df26696f24784663e2c791 Signed-off-by: garciadeblas --- osm_im/validation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osm_im/validation.py b/osm_im/validation.py index 0863434..7334fbb 100644 --- a/osm_im/validation.py +++ b/osm_im/validation.py @@ -25,7 +25,7 @@ import pyangbind.lib.pybindJSON as pybindJSON class ValidationException(Exception): pass -class Validation(): +class Validation: def pyangbind_validation(self, item, data, force=False): ''' @@ -55,15 +55,15 @@ class Validation(): try: data = yaml.safe_load(descriptor) except Exception as e: - raise ValidationException("Error in YAML validation. Not a proper YAML file") - if 'vnfd:vnfd-catalog' in data: + raise ValidationException("Error in YAML validation. Not a proper YAML file: {}".format(e)) + if 'vnfd:vnfd-catalog' in data or 'vnfd-catalog' in data: item = "vnfd" - elif 'nsd:nsd-catalog' in data: + elif 'nsd:nsd-catalog' in data or 'nsd-catalog' in data: item = "nsd" elif 'nst' in data: item = "nst" else: - raise ValidationException("Error in YAML validation. Not possible to determine the type of descriptor in the first line. Expected values: vnfd:vnfd-catalog, nsd:nsd-catalog, nst") + raise ValidationException("Error in YAML validation. Not possible to determine the type of descriptor in the first line. Expected values: vnfd:vnfd-catalog, vnfd-catalog, nsd:nsd-catalog, nsd-catalog, nst") return item, data -- 2.25.1