X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fvalidation.py;h=308d872c0d2294b1c5029b3e72368362b675c8cb;hp=91549e00d8ef15b04f324b6588a89308e3483746;hb=0da52259d5938703bcb71bb1f42cc1da345ff887;hpb=db9dc589ca4ddb7fde50cff07c23b2ea863265cc diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 91549e0..308d872 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -15,6 +15,7 @@ patern_name = "^[ -~]+$" passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60} nameshort_schema = {"type": "string", "minLength": 1, "maxLength": 60, "pattern": "^[^,;()'\"]+$"} name_schema = {"type": "string", "minLength": 1, "maxLength": 255, "pattern": "^[^,;()'\"]+$"} +string_schema = {"type": "string", "minLength": 1, "maxLength": 255} xml_text_schema = {"type": "string", "minLength": 1, "maxLength": 1000, "pattern": "^[^']+$"} description_schema = {"type": ["string", "null"], "maxLength": 255, "pattern": "^[^'\"]+$"} id_schema_fake = {"type": "string", "minLength": 2, @@ -51,7 +52,41 @@ ns_instantiate = { "title": "ns action instantiate input schema", "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "properties": { + "nsName": name_schema, + "nsDescription": description_schema, + "nsdId": id_schema, + "vimAccountId": id_schema, + "ssh_keys": {"type": "string"}, + "vnf": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "member-vnf-index": name_schema, + "vimAccountId": id_schema, + }, + "required": ["member-vnf-index"] + } + }, + "vld": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "name": string_schema, + "vim-network-name": {"OneOf": [string_schema, object_schema]}, + "ip-profile": object_schema, + }, + "required": ["name"] + } + }, + }, + "required": ["nsName", "nsdId", "vimAccountId"] } + ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution "title": "ns action update input schema", "$schema": "http://json-schema.org/draft-04/schema#", @@ -214,7 +249,7 @@ def validate_input(indata, item, new=True): return None except js_e.ValidationError as e: if e.path: - error_pos = "at '" + ":".join(e.path) + "'" + error_pos = "at '" + ":".join(map(str, e.path)) + "'" else: error_pos = "" raise ValidationError("Format error {} '{}' ".format(error_pos, e))