From: garciaale Date: Thu, 3 Dec 2020 22:17:28 +0000 (-0300) Subject: Adds a clear error message when uploading an old descriptor X-Git-Tag: release-v9.0-start~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F10078%2F2;p=osm%2FNBI.git Adds a clear error message when uploading an old descriptor Change-Id: Id600b558858f45001adad1bf6a4eb5f3bb28ff14 Signed-off-by: garciaale --- diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 4e056f5..26aea63 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -456,6 +456,9 @@ class VnfdTopic(DescriptorTopic): DescriptorTopic.__init__(self, db, fs, msg, auth) def pyangbind_validation(self, item, data, force=False): + if self._descriptor_data_is_in_old_format(data): + raise EngineException("ERROR: Unsupported descriptor format. Please, use an ETSI SOL006 descriptor.", + http_code=HTTPStatus.UNPROCESSABLE_ENTITY) try: virtual_compute_descriptors = data.get('virtual-compute-desc') virtual_storage_descriptors = data.get('virtual-storage-desc') @@ -474,6 +477,10 @@ class VnfdTopic(DescriptorTopic): raise EngineException("Error in pyangbind validation: {}".format(str(e)), http_code=HTTPStatus.UNPROCESSABLE_ENTITY) + @staticmethod + def _descriptor_data_is_in_old_format(data): + return ('vnfd-catalog' in data) or ('vnfd:vnfd-catalog' in data) + @staticmethod def _remove_envelop(indata=None): if not indata: @@ -797,6 +804,9 @@ class NsdTopic(DescriptorTopic): DescriptorTopic.__init__(self, db, fs, msg, auth) def pyangbind_validation(self, item, data, force=False): + if self._descriptor_data_is_in_old_format(data): + raise EngineException("ERROR: Unsupported descriptor format. Please, use an ETSI SOL006 descriptor.", + http_code=HTTPStatus.UNPROCESSABLE_ENTITY) try: mynsd = etsi_nfv_nsd.etsi_nfv_nsd() pybindJSONDecoder.load_ietf_json({'nsd': {'nsd': [data]}}, None, None, obj=mynsd, @@ -809,6 +819,10 @@ class NsdTopic(DescriptorTopic): raise EngineException("Error in pyangbind validation: {}".format(str(e)), http_code=HTTPStatus.UNPROCESSABLE_ENTITY) + @staticmethod + def _descriptor_data_is_in_old_format(data): + return ('nsd-catalog' in data) or ('nsd:nsd-catalog' in data) + @staticmethod def _remove_envelop(indata=None): if not indata: