Fix age key generation to convert pubkey to string
[osm/NBI.git] / osm_nbi / validation.py
index 1bf597c..a1911dd 100644 (file)
@@ -142,6 +142,7 @@ ns_instantiate_vdu = {
     "properties": {
         "id": name_schema,
         "vim-flavor-id": name_schema,
+        "instance_name": name_schema,
         "volume": {
             "type": "array",
             "minItems": 1,
@@ -328,6 +329,82 @@ additional_params_for_vnf = {
     },
 }
 
+vnf_schema = {
+    "type": "array",
+    "minItems": 1,
+    "items": {
+        "type": "object",
+        "properties": {
+            "member-vnf-index": name_schema,
+            "vimAccountId": id_schema,
+            "vdu": {
+                "type": "array",
+                "minItems": 1,
+                "items": ns_instantiate_vdu,
+            },
+            "internal-vld": {
+                "type": "array",
+                "minItems": 1,
+                "items": ns_instantiate_internal_vld,
+            },
+        },
+        "required": ["member-vnf-index"],
+        "minProperties": 2,
+        "additionalProperties": False,
+    },
+}
+
+vld_schema = {
+    "type": "array",
+    "minItems": 1,
+    "items": {
+        "type": "object",
+        "properties": {
+            "name": string_schema,
+            "vim-network-name": {"oneOf": [string_schema, object_schema]},
+            "vim-network-id": {"oneOf": [string_schema, object_schema]},
+            "ns-net": object_schema,
+            "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
+            "ip-profile": ip_profile_schema,
+            "provider-network": provider_network_schema,
+            "vnfd-connection-point-ref": {
+                "type": "array",
+                "minItems": 1,
+                "items": {
+                    "type": "object",
+                    "properties": {
+                        "member-vnf-index-ref": name_schema,
+                        "vnfd-connection-point-ref": name_schema,
+                        "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
+                        # "mac-address": mac_schema,
+                    },
+                    "required": [
+                        "member-vnf-index-ref",
+                        "vnfd-connection-point-ref",
+                    ],
+                    "minProperties": 3,
+                    "additionalProperties": False,
+                },
+            },
+        },
+        "required": ["name"],
+        "additionalProperties": False,
+    },
+}
+
+ns_config_template = {
+    "title": " ns config template input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": string_schema,
+        "nsdId": id_schema,
+        "config": object_schema,
+    },
+    "required": ["name", "nsdId", "config"],
+    "additionalProperties": False,
+}
+
 ns_instantiate = {
     "title": "ns action instantiate input schema",
     "$schema": "http://json-schema.org/draft-04/schema#",
@@ -340,6 +417,7 @@ ns_instantiate = {
         "nsDescription": {"oneOf": [description_schema, null_schema]},
         "nsdId": id_schema,
         "vimAccountId": id_schema,
+        "nsConfigTemplateId": id_schema,
         "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
         "placement-engine": string_schema,
         "placement-constraints": object_schema,
@@ -351,67 +429,8 @@ ns_instantiate = {
         "timeout_ns_deploy": integer1_schema,
         "nsr_id": id_schema,
         "vduImage": name_schema,
-        "vnf": {
-            "type": "array",
-            "minItems": 1,
-            "items": {
-                "type": "object",
-                "properties": {
-                    "member-vnf-index": name_schema,
-                    "vimAccountId": id_schema,
-                    "vdu": {
-                        "type": "array",
-                        "minItems": 1,
-                        "items": ns_instantiate_vdu,
-                    },
-                    "internal-vld": {
-                        "type": "array",
-                        "minItems": 1,
-                        "items": ns_instantiate_internal_vld,
-                    },
-                },
-                "required": ["member-vnf-index"],
-                "minProperties": 2,
-                "additionalProperties": False,
-            },
-        },
-        "vld": {
-            "type": "array",
-            "minItems": 1,
-            "items": {
-                "type": "object",
-                "properties": {
-                    "name": string_schema,
-                    "vim-network-name": {"oneOf": [string_schema, object_schema]},
-                    "vim-network-id": {"oneOf": [string_schema, object_schema]},
-                    "ns-net": object_schema,
-                    "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
-                    "ip-profile": ip_profile_schema,
-                    "provider-network": provider_network_schema,
-                    "vnfd-connection-point-ref": {
-                        "type": "array",
-                        "minItems": 1,
-                        "items": {
-                            "type": "object",
-                            "properties": {
-                                "member-vnf-index-ref": name_schema,
-                                "vnfd-connection-point-ref": name_schema,
-                                "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
-                                # "mac-address": mac_schema,
-                            },
-                            "required": [
-                                "member-vnf-index-ref",
-                                "vnfd-connection-point-ref",
-                            ],
-                            "minProperties": 3,
-                            "additionalProperties": False,
-                        },
-                    },
-                },
-                "required": ["name"],
-                "additionalProperties": False,
-            },
-        },
+        "vnf": vnf_schema,
+        "vld": vld_schema,
     },
     "required": ["nsName", "nsdId", "vimAccountId"],
     "additionalProperties": False,
@@ -446,6 +465,7 @@ ns_update = {
                 "REMOVE_VNF",
                 "MODIFY_VNF_INFORMATION",
                 "OPERATE_VNF",
+                "VERTICAL_SCALE",
             ]
         },
         "modifyVnfInfoData": {
@@ -483,6 +503,16 @@ ns_update = {
             },
             "required": ["vnfInstanceId", "changeStateTo"],
         },
+        "verticalScaleVnf": {
+            "type": "object",
+            "properties": {
+                "vnfInstanceId": id_schema,
+                "vnfdId": id_schema,
+                "vduId": name_schema,
+                "countIndex": integer0_schema,
+            },
+            "required": ["vnfInstanceId", "vnfdId", "vduId"],
+        },
     },
     "required": ["updateType"],
     "additionalProperties": False,
@@ -610,34 +640,20 @@ ns_heal = {
     "additionalProperties": False,
 }
 
-ns_verticalscale = {
-    "title": "vertial scale input schema",
+nslcmop_cancel = {
+    "title": "Cancel nslcmop input schema",
     "$schema": "http://json-schema.org/draft-04/schema#",
     "type": "object",
     "properties": {
-        "lcmOperationType": string_schema,
-        "verticalScale": string_schema,
-        "nsInstanceId": id_schema,
-        "changeVnfFlavorData": {
-            "type": "object",
-            "properties": {
-                "vnfInstanceId": id_schema,
-                "additionalParams": {
-                    "type": "object",
-                    "properties": {
-                        "vduid": string_schema,
-                        "vduCountIndex": integer0_schema,
-                        "virtualMemory": integer1_schema,
-                        "sizeOfStorage": integer0_schema,
-                        "numVirtualCpu": integer1_schema,
-                    },
-                },
-            },
-            "required": ["vnfInstanceId", "additionalParams"],
-            "additionalProperties": False,
+        "nsLcmOpOccId": id_schema,
+        "cancelMode": {
+            "enum": [
+                "GRACEFUL",
+                "FORCEFUL",
+            ]
         },
     },
-    "required": ["lcmOperationType", "verticalScale", "nsInstanceId"],
+    "required": ["cancelMode"],
     "additionalProperties": False,
 }
 
@@ -932,6 +948,7 @@ k8srepo_properties = {
     "cacert": long_description_schema,
     "user": string_schema,
     "password": passwd_schema,
+    "oci": bool_schema,
 }
 k8srepo_new_schema = {
     "title": "k8scluster creation input schema",
@@ -955,7 +972,7 @@ osmrepo_properties = {
     "name": name_schema,
     "description": description_schema,
     "type": osmrepo_types,
-    "url": description_schema
+    "url": description_schema,
     # "user": string_schema,
     # "password": passwd_schema
 }
@@ -1056,6 +1073,147 @@ vnfpkgop_new_schema = {
     "additionalProperties": False,
 }
 
+clustercreation_new_schema = {
+    "title": "cluster creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "vim_account": string_schema,
+        "k8s_version": string_schema,
+        "node_size": string_schema,
+        "node_count": integer0_schema,
+        "description": string_schema,
+        "region_name": string_schema,
+        "resource_group": string_schema,
+        "infra_controller_profiles": shortname_schema,
+        "infra_config_profiles": shortname_schema,
+        "resource_profiles": shortname_schema,
+        "app_profiles": shortname_schema,
+    },
+    "required": [
+        "name",
+        "vim_account",
+        "k8s_version",
+        "node_size",
+        "node_count",
+        "description",
+    ],
+    "additionalProperties": False,
+}
+
+infra_controller_profile_create_new_schema = {
+    "title": "infra profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+infra_controller_profile_create_edit_schema = {
+    "title": "infra profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+infra_config_profile_create_new_schema = {
+    "title": "infra profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+infra_config_profile_create_edit_schema = {
+    "title": "infra profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+app_profile_create_new_schema = {
+    "title": "app profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+app_profile_create_edit_schema = {
+    "title": "app profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+resource_profile_create_new_schema = {
+    "title": "resource profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+resource_profile_create_edit_schema = {
+    "title": "resource profile creation operation input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": string_schema,
+    },
+    "additionalProperties": False,
+}
+
+attach_profile = {
+    "type": "array",
+    "items": {
+        "type": "object",
+        "properties": {"id": id_schema},
+        "additionalProperties": False,
+    },
+}
+remove_profile = {
+    "type": "array",
+    "items": {
+        "type": "object",
+        "properties": {"id": id_schema},
+        "additionalProperties": False,
+    },
+}
+attach_dettach_profile_schema = {
+    "title": "attach/dettach profiles",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "add_profile": attach_profile,
+        "remove_profile": remove_profile,
+    },
+    "additionalProperties": False,
+}
 # USERS
 project_role_mappings = {
     "title": "list pf projects/roles",
@@ -1069,6 +1227,7 @@ project_role_mappings = {
     },
     "minItems": 1,
 }
+
 project_role_mappings_optional = {
     "title": "list of projects/roles or projects only",
     "$schema": "http://json-schema.org/draft-04/schema#",
@@ -1081,6 +1240,7 @@ project_role_mappings_optional = {
     },
     "minItems": 1,
 }
+
 user_new_schema = {
     "$schema": "http://json-schema.org/draft-04/schema#",
     "title": "New user schema",
@@ -1224,6 +1384,9 @@ nbi_edit_input_schemas = {
     "vim_accounts": vim_account_edit_schema,
     "sdns": sdn_edit_schema,
     "pdus": pdu_edit_schema,
+    "vnf": vnf_schema,
+    "vld": vld_schema,
+    "additionalParamsForVnf": additional_params_for_vnf,
 }
 
 # NETSLICE SCHEMAS
@@ -1491,6 +1654,48 @@ vnf_subscription = {
     "required": ["filter", "CallbackUri"],
 }
 
+oka_schema = {
+    "title": "Create OKA package input schema",
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": description_schema,
+    },
+    "additionalProperties": False,
+}
+
+ksu_schema = {
+    "title": "ksu schema",
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "name": name_schema,
+        "description": description_schema,
+        "profile": {
+            "type": "object",
+            "properties": {
+                "profile_type": string_schema,
+                "_id": id_schema,
+            },
+            "additionalProperties": False,
+        },
+        "oka": {
+            "type": "array",
+            "items": {
+                "type": "object",
+                "properties": {
+                    "_id": id_schema,
+                    "sw_catalog_path": string_schema,
+                    "transformation": object_schema,
+                },
+                "additionalProperties": False,
+            },
+        },
+    },
+    "additionalProperties": False,
+}
+
 
 class ValidationError(Exception):
     def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):