Fix age key generation to convert pubkey to string
[osm/NBI.git] / osm_nbi / validation.py
index f9213d8..a1911dd 100644 (file)
@@ -35,6 +35,10 @@ shortname_schema = {
     "pattern": "^[^,;()\\.\\$'\"]+$",
 }
 passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60}
+user_passwd_schema = {
+    "type": "string",
+    "pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$",
+}
 name_schema = {
     "type": "string",
     "minLength": 1,
@@ -96,7 +100,7 @@ ip_schema = {
 }
 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]))",
+    "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]))",  # noqa: W605
 }
 ip_prefix_schema = {
     "type": "string",
@@ -137,6 +141,8 @@ ns_instantiate_vdu = {
     "type": "object",
     "properties": {
         "id": name_schema,
+        "vim-flavor-id": name_schema,
+        "instance_name": name_schema,
         "volume": {
             "type": "array",
             "minItems": 1,
@@ -194,19 +200,6 @@ ip_profile_dhcp_schema = {
 }
 
 ip_profile_schema = {
-    "title": "ip profile validation schema",
-    "$schema": "http://json-schema.org/draft-04/schema#",
-    "type": "object",
-    "properties": {
-        "ip-version": {"enum": ["ipv4", "ipv6"]},
-        "subnet-address": ip_prefix_schema,
-        "gateway-address": ip_schema,
-        "dns-server": ip_profile_dns_schema,
-        "dhcp-params": ip_profile_dhcp_schema,
-    },
-}
-
-ip_profile_update_schema = {
     "title": "ip profile validation schema",
     "$schema": "http://json-schema.org/draft-04/schema#",
     "type": "object",
@@ -253,7 +246,7 @@ ns_instantiate_internal_vld = {
         "name": name_schema,
         "vim-network-name": name_schema,
         "vim-network-id": name_schema,
-        "ip-profile": ip_profile_update_schema,
+        "ip-profile": ip_profile_schema,
         "provider-network": provider_network_schema,
         "internal-connection-point": {
             "type": "array",
@@ -336,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#",
@@ -348,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,
@@ -359,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": object_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,
@@ -449,7 +460,13 @@ ns_update = {
         "nsInstanceId": id_schema,
         "timeout_ns_update": integer1_schema,
         "updateType": {
-            "enum": ["CHANGE_VNFPKG", "REMOVE_VNF", "MODIFY_VNF_INFORMATION", "OPERATE_VNF"]
+            "enum": [
+                "CHANGE_VNFPKG",
+                "REMOVE_VNF",
+                "MODIFY_VNF_INFORMATION",
+                "OPERATE_VNF",
+                "VERTICAL_SCALE",
+            ]
         },
         "modifyVnfInfoData": {
             "type": "object",
@@ -482,10 +499,20 @@ ns_update = {
                     },
                     "required": ["vdu_id", "count-index"],
                     "additionalProperties": False,
-                }
+                },
             },
             "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,
@@ -556,16 +583,16 @@ ns_migrate = {
         "migrateToHost": string_schema,
         "vdu": {
             "type": "object",
-                "properties": {
-                    "vduId": name_schema,
-                    "vduCountIndex": integer0_schema,
-                },
-                "required": ["vduId"],
-                "additionalProperties": False,
+            "properties": {
+                "vduId": name_schema,
+                "vduCountIndex": integer0_schema,
+            },
+            "required": ["vduId"],
+            "additionalProperties": False,
         },
     },
     "required": ["vnfInstanceId"],
-    "additionalProperties": False
+    "additionalProperties": False,
 }
 
 ns_heal = {
@@ -613,6 +640,23 @@ ns_heal = {
     "additionalProperties": False,
 }
 
+nslcmop_cancel = {
+    "title": "Cancel nslcmop input schema",
+    "$schema": "http://json-schema.org/draft-04/schema#",
+    "type": "object",
+    "properties": {
+        "nsLcmOpOccId": id_schema,
+        "cancelMode": {
+            "enum": [
+                "GRACEFUL",
+                "FORCEFUL",
+            ]
+        },
+    },
+    "required": ["cancelMode"],
+    "additionalProperties": False,
+}
+
 schema_version = {"type": "string", "enum": ["1.0"]}
 schema_type = {"type": "string"}
 vim_type = shortname_schema  # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
@@ -787,12 +831,11 @@ k8scluster_deploy_method_schema = {
     "title": "Deployment methods for K8s cluster",
     "type": "object",
     "properties": {
-        "helm-chart": {"type": "boolean"},
         "juju-bundle": {"type": "boolean"},
         "helm-chart-v3": {"type": "boolean"},
     },
     "additionalProperties": False,
-    "minProperties": 3,
+    "minProperties": 2,
 }
 k8scluster_nets_schema = {
     "title": "k8scluster nets input schema",
@@ -902,6 +945,10 @@ k8srepo_properties = {
     "description": description_schema,
     "type": k8srepo_types,
     "url": description_schema,
+    "cacert": long_description_schema,
+    "user": string_schema,
+    "password": passwd_schema,
+    "oci": bool_schema,
 }
 k8srepo_new_schema = {
     "title": "k8scluster creation input schema",
@@ -925,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
 }
@@ -1026,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",
@@ -1039,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#",
@@ -1051,6 +1240,7 @@ project_role_mappings_optional = {
     },
     "minItems": 1,
 }
+
 user_new_schema = {
     "$schema": "http://json-schema.org/draft-04/schema#",
     "title": "New user schema",
@@ -1058,7 +1248,7 @@ user_new_schema = {
     "properties": {
         "username": string_schema,
         "domain_name": shortname_schema,
-        "password": passwd_schema,
+        "password": user_passwd_schema,
         "projects": nameshort_list_schema,
         "project_role_mappings": project_role_mappings,
     },
@@ -1070,13 +1260,16 @@ user_edit_schema = {
     "title": "User edit schema for administrators",
     "type": "object",
     "properties": {
-        "password": passwd_schema,
+        "password": user_passwd_schema,
         "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,
         "remove_project_role_mappings": project_role_mappings_optional,
+        "system_admin_id": id_schema,
+        "unlock": bool_schema,
+        "renew": bool_schema,
     },
     "minProperties": 1,
     "additionalProperties": False,
@@ -1191,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
@@ -1405,32 +1601,46 @@ vnflcmsub_schema = {
                 "enum": [
                     "VnfIdentifierCreationNotification",
                     "VnfLcmOperationOccurrenceNotification",
-                    "VnfIdentifierDeletionNotification"
-                    ]
-            }
+                    "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"
-                    ]
-            }
+                    "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"
-                    ]
-            }
-        }
+                    "STARTING",
+                    "PROCESSING",
+                    "COMPLETED",
+                    "FAILED_TEMP",
+                    "FAILED",
+                    "ROLLING_BACK",
+                    "ROLLED_BACK",
+                ]
+            },
+        },
     },
-    "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"]
- }
+    "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
+}
 
 vnf_subscription = {
     "title": "vnf subscription input schema",
@@ -1439,9 +1649,51 @@ vnf_subscription = {
     "properties": {
         "filter": vnflcmsub_schema,
         "CallbackUri": description_schema,
-        "authentication": authentication_schema
+        "authentication": authentication_schema,
     },
-    "required": ["filter", "CallbackUri"]
+    "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,
 }