Added NS parameter validation 02/6302/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 27 Jun 2018 13:47:22 +0000 (15:47 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 27 Jun 2018 14:31:44 +0000 (16:31 +0200)
Change-Id: I788bc58e51cce7d73f9dc7c711abba4de262dfa8
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/engine.py
osm_nbi/html_public/version
osm_nbi/nbi.py
osm_nbi/validation.py

index 76b0f13..50d1bd1 100644 (file)
@@ -538,6 +538,7 @@ class Engine(object):
         :param ns_request: params to be used for the nsr
         :return: the _id of nsr descriptor stored at database
         """
+        rollback_index = len(rollback)
         step = ""
         try:
             # look for nsr
@@ -649,7 +650,7 @@ class Engine(object):
             step = "creating nsr at database"
             self._format_new_data(session, "nsrs", nsr_descriptor)
             self.db.create("nsrs", nsr_descriptor)
-            rollback.insert(0, {"item": "nsrs", "_id": nsr_id})
+            rollback.insert(rollback_index, {"item": "nsrs", "_id": nsr_id})
             return nsr_id
         except Exception as e:
             raise EngineException("Error {}: {}".format(step, e))
index 63dd2ef..c9b57d9 100644 (file)
@@ -1,3 +1,3 @@
-0.1.10
-2018-05-28
+0.1.11
+2018-06-27
 
index 4468f26..e34cfad 100644 (file)
@@ -694,7 +694,7 @@ class Server(object):
                     outdata = {"id": _id}
                 elif item == "ns_instances_content":
                     _id = self.engine.new_item(rollback, session, engine_item, indata, kwargs, force=force)
-                    self.engine.ns_operation(rollback, session, _id, "instantiate", {}, None)
+                    self.engine.ns_operation(rollback, session, _id, "instantiate", indata, None)
                     self._set_location_header(topic, version, item, _id)
                     outdata = {"id": _id}
                 elif item == "ns_instances" and item2:
index 91549e0..308d872 100644 (file)
@@ -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))