# limitations under the License.
import yaml
-import json
-# import logging
+import importlib
from osm_im.vnfd import vnfd as vnfd_im
from osm_im.nsd import nsd as nsd_im
from osm_im.nst import nst as nst_im
+from osm_im import etsi_nfv_vnfd, etsi_nfv_nsd
from pyangbind.lib.serialise import pybindJSONDecoder
import pyangbind.lib.pybindJSON as pybindJSON
class ValidationException(Exception):
pass
-class Validation():
+class Validation:
def pyangbind_validation(self, item, data, force=False):
'''
myobj = nsd_im()
elif item == "nst":
myobj = nst_im()
+ elif item == "etsi_nfv_vnfd":
+ myobj = etsi_nfv_vnfd.etsi_nfv_vnfd()
+ elif item == "etsi_nfv_nsd":
+ myobj = etsi_nfv_nsd.etsi_nfv_nsd()
else:
raise ValidationException("Not possible to validate '{}' item".format(item))
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"
+ elif 'vnfd' in data:
+ item = "etsi_nfv_vnfd"
+ elif 'nsd' in data:
+ item = "etsi_nfv_nsd"
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