Feature 10926 - Subscription feature for SOL003 VNF-LCM
[osm/NBI.git] / osm_nbi / validation.py
index 153086b..3fec364 100644 (file)
@@ -94,6 +94,10 @@ ip_schema = {
     "type": "string",
     "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
 }
+ipv6_schema = {
+    "type": "string",
+    "pattern": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))",
+}
 ip_prefix_schema = {
     "type": "string",
     "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
@@ -153,7 +157,7 @@ ns_instantiate_vdu = {
                 "type": "object",
                 "properties": {
                     "name": name_schema,
-                    "ip-address": ip_schema,
+                    "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
                     "mac-address": mac_schema,
                     "floating-ip-required": bool_schema,
                 },
@@ -172,7 +176,7 @@ ip_profile_dns_schema = {
     "items": {
         "type": "object",
         "properties": {
-            "address": ip_schema,
+            "address": {"oneOf": [ip_schema, ipv6_schema]},
         },
         "required": ["address"],
         "additionalProperties": False,
@@ -242,7 +246,7 @@ provider_network_schema = {
 }
 
 ns_instantiate_internal_vld = {
-    "title": "ns action instantiate input schema for vdu",
+    "title": "ns action instantiate input schema for vld",
     "$schema": "http://json-schema.org/draft-04/schema#",
     "type": "object",
     "properties": {
@@ -305,12 +309,26 @@ additional_params_for_vnf = {
                         "kdu_model": name_schema,
                         "k8s-namespace": name_schema,
                         "config-units": integer1_schema,  # number of configuration units of this knf, by default 1
+                        "kdu-deployment-name": name_schema,
                     },
                     "required": ["kdu_name"],
                     "minProperties": 2,
                     "additionalProperties": False,
                 },
             },
+            "affinity-or-anti-affinity-group": {
+                "type": "array",
+                "items": {
+                    "type": "object",
+                    "properties": {
+                        "id": name_schema,
+                        "vim-affinity-group-id": name_schema,
+                    },
+                    "required": ["id"],
+                    "minProperties": 2,
+                    "additionalProperties": False,
+                },
+            },
         },
         "required": ["member-vnf-index"],
         "minProperties": 2,
@@ -329,7 +347,6 @@ ns_instantiate = {
         "nsName": name_schema,
         "nsDescription": {"oneOf": [description_schema, null_schema]},
         "nsdId": id_schema,
-        "vcaId": id_schema,
         "vimAccountId": id_schema,
         "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
         "placement-engine": string_schema,
@@ -350,7 +367,6 @@ ns_instantiate = {
                 "properties": {
                     "member-vnf-index": name_schema,
                     "vimAccountId": id_schema,
-                    "vcaId": id_schema,
                     "vdu": {
                         "type": "array",
                         "minItems": 1,
@@ -388,7 +404,7 @@ ns_instantiate = {
                             "properties": {
                                 "member-vnf-index-ref": name_schema,
                                 "vnfd-connection-point-ref": name_schema,
-                                "ip-address": ip_schema,
+                                "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
                                 # "mac-address": mac_schema,
                             },
                             "required": [
@@ -424,6 +440,39 @@ ns_terminate = {
     "additionalProperties": False,
 }
 
+ns_update = {
+    "title": "ns update input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "lcmOperationType": string_schema,
+        "nsInstanceId": id_schema,
+        "timeout_ns_update": integer1_schema,
+        "updateType": {
+            "enum": ["CHANGE_VNFPKG", "REMOVE_VNF", "MODIFY_VNF_INFORMATION"]
+        },
+        "modifyVnfInfoData": {
+            "type": "object",
+            "properties": {
+                "vnfInstanceId": id_schema,
+                "vnfdId": id_schema,
+            },
+            "required": ["vnfInstanceId", "vnfdId"],
+        },
+        "removeVnfInstanceId": id_schema,
+        "changeVnfPackageData": {
+            "type": "object",
+            "properties": {
+                "vnfInstanceId": id_schema,
+                "vnfdId": id_schema,
+            },
+            "required": ["vnfInstanceId", "vnfdId"],
+        },
+    },
+    "required": ["updateType"],
+    "additionalProperties": False,
+}
+
 ns_action = {  # TODO for the moment it is only contemplated the vnfd primitive execution
     "title": "ns action input schema",
     "$schema": "http://json-schema.org/draft-04/schema#",
@@ -477,6 +526,28 @@ ns_scale = {  # TODO for the moment it is only VDU-scaling
     "additionalProperties": False,
 }
 
+ns_migrate = {
+    "title": "ns migrate input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "lcmOperationType": string_schema,
+        "nsInstanceId": id_schema,
+        "vnfInstanceId": id_schema,
+        "migrateToHost": string_schema,
+        "vdu": {
+            "type": "object",
+                "properties": {
+                    "vduId": name_schema,
+                    "vduCountIndex": integer0_schema,
+                },
+                "required": ["vduId"],
+                "additionalProperties": False,
+        },
+    },
+    "required": ["vnfInstanceId"],
+    "additionalProperties": False
+}
 
 schema_version = {"type": "string", "enum": ["1.0"]}
 schema_type = {"type": "string"}
@@ -496,10 +567,11 @@ vim_account_edit_schema = {
         # "vim_url_admin": description_schema,
         # "vim_tenant": name_schema,
         "vim_tenant_name": name_schema,
-        "vim_user": shortname_schema,
+        "vim_user": string_schema,
         "vim_password": passwd_schema,
         "vca": id_schema,
         "config": {"type": "object"},
+        "prometheus-config": {"type": "object"},
     },
     "additionalProperties": False,
 }
@@ -520,10 +592,11 @@ vim_account_new_schema = {
         # "vim_url_admin": description_schema,
         # "vim_tenant": name_schema,
         "vim_tenant_name": name_schema,
-        "vim_user": shortname_schema,
+        "vim_user": string_schema,
         "vim_password": passwd_schema,
         "vca": id_schema,
         "config": {"type": "object"},
+        "prometheus-config": {"type": "object"},
     },
     "required": [
         "name",
@@ -548,7 +621,7 @@ wim_account_edit_schema = {
         "wim": name_schema,
         "wim_type": wim_type,
         "wim_url": description_schema,
-        "user": shortname_schema,
+        "user": string_schema,
         "password": passwd_schema,
         "config": {"type": "object"},
     },
@@ -567,7 +640,7 @@ wim_account_new_schema = {
         "wim": name_schema,
         "wim_type": wim_type,
         "wim_url": description_schema,
-        "user": shortname_schema,
+        "user": string_schema,
         "password": passwd_schema,
         "config": {
             "type": "object",
@@ -582,7 +655,7 @@ sdn_properties = {
     "name": name_schema,
     "type": {"type": "string"},
     "url": {"type": "string"},
-    "user": shortname_schema,
+    "user": string_schema,
     "password": passwd_schema,
     "config": {"type": "object"},
     "description": description_schema,
@@ -702,7 +775,7 @@ vca_new_schema = {
         "name": name_schema,
         "description": description_schema,
         "endpoints": description_list_schema,
-        "user": shortname_schema,
+        "user": string_schema,
         "secret": passwd_schema,
         "cacert": long_description_schema,
         "lxd-cloud": shortname_schema,
@@ -733,7 +806,7 @@ vca_edit_schema = {
         "description": description_schema,
         "endpoints": description_list_schema,
         "port": integer1_schema,
-        "user": shortname_schema,
+        "user": string_schema,
         "secret": passwd_schema,
         "cacert": long_description_schema,
         "lxd-cloud": shortname_schema,
@@ -776,7 +849,7 @@ osmrepo_properties = {
     "description": description_schema,
     "type": osmrepo_types,
     "url": description_schema
-    # "user": shortname_schema,
+    # "user": string_schema,
     # "password": passwd_schema
 }
 osmrepo_new_schema = {
@@ -802,7 +875,7 @@ pdu_interface = {
         "name": shortname_schema,
         "mgmt": bool_schema,
         "type": {"enum": ["overlay", "underlay"]},
-        "ip-address": ip_schema,
+        "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
         # TODO, add user, password, ssh-key
         "mac-address": mac_schema,
         "vim-network-name": shortname_schema,  # interface is connected to one vim network, or switch port
@@ -906,7 +979,7 @@ user_new_schema = {
     "title": "New user schema",
     "type": "object",
     "properties": {
-        "username": shortname_schema,
+        "username": string_schema,
         "domain_name": shortname_schema,
         "password": passwd_schema,
         "projects": nameshort_list_schema,
@@ -921,7 +994,8 @@ user_edit_schema = {
     "type": "object",
     "properties": {
         "password": passwd_schema,
-        "username": shortname_schema,  # To allow User Name modification
+        "old_password": passwd_schema,
+        "username": string_schema,  # To allow User Name modification
         "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
         "project_role_mappings": project_role_mappings,
         "add_project_role_mappings": project_role_mappings,
@@ -1029,6 +1103,7 @@ nbi_new_input_schemas = {
     "ns_instantiate": ns_instantiate,
     "ns_action": ns_action,
     "ns_scale": ns_scale,
+    "ns_update": ns_update,
     "pdus": pdu_new_schema,
 }
 
@@ -1215,7 +1290,7 @@ authentication_schema = {
         "paramsBasic": {
             "type": "object",
             "properties": {
-                "userName": shortname_schema,
+                "userName": string_schema,
                 "password": passwd_schema,
             },
         },
@@ -1234,6 +1309,63 @@ subscription = {
     "required": ["CallbackUri"],
 }
 
+vnflcmsub_schema = {
+    "title": "vnflcmsubscription input schema",
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "VnfInstanceSubscriptionFilter": {
+            "type": "object",
+            "properties": {
+                "vnfdIds": {"type": "array"},
+                "vnfInstanceIds": {"type": "array"},
+            },
+        },
+        "notificationTypes": {
+            "type": "array",
+            "items": {
+                "enum": [
+                    "VnfIdentifierCreationNotification",
+                    "VnfLcmOperationOccurrenceNotification",
+                    "VnfIdentifierDeletionNotification"
+                    ]
+            }
+        },
+        "operationTypes": {
+            "type": "array",
+            "items": {
+                "enum": [
+                    "INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE",
+                    "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO", "CREATE_SNAPSHOT",
+                    "REVERT_TO_SNAPSHOT", "CHANGE_VNFPKG"
+                    ]
+            }
+        },
+        "operationStates": {
+            "type": "array",
+            "items": {
+                "enum": [
+                    "STARTING", "PROCESSING", "COMPLETED", "FAILED_TEMP", "FAILED",
+                    "ROLLING_BACK", "ROLLED_BACK"
+                    ]
+            }
+        }
+    },
+    "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"]
+ }
+
+vnf_subscription = {
+    "title": "vnf subscription input schema",
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "filter": vnflcmsub_schema,
+        "CallbackUri": description_schema,
+        "authentication": authentication_schema
+    },
+    "required": ["filter", "CallbackUri"]
+}
+
 
 class ValidationError(Exception):
     def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):