bug 650 adding WIM account instantiation parameter. 39/7339/3
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 20 Mar 2019 17:24:11 +0000 (17:24 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 21 Mar 2019 11:27:25 +0000 (11:27 +0000)
Allow manual selection of wim or deployment without Wim

Change-Id: I1eebb3204e78002768f1e843ba9ed242acec3e79
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/instance_topics.py
osm_nbi/validation.py

index 9dced30..7ad252f 100644 (file)
@@ -395,6 +395,7 @@ class NsLcmOpTopic(BaseTopic):
         """
         vnfds = {}
         vim_accounts = []
+        wim_accounts = []
         nsd = nsr["nsd"]
 
         def check_valid_vnf_member_index(member_vnf_index):
@@ -467,6 +468,19 @@ class NsLcmOpTopic(BaseTopic):
                 raise EngineException("Invalid vimAccountId='{}' not present for the project".format(vim_account))
             vim_accounts.append(vim_account)
 
+        def check_valid_wim_account(wim_account):
+            if not isinstance(wim_account, str):
+                return
+            elif wim_account in wim_accounts:
+                return
+            try:
+                db_filter = self._get_project_filter(session, write=False, show_all=True)
+                db_filter["_id"] = wim_account
+                self.db.get_one("wim_accounts", db_filter)
+            except Exception:
+                raise EngineException("Invalid wimAccountId='{}' not present for the project".format(wim_account))
+            wim_accounts.append(wim_account)
+
         if operation == "action":
             # check vnf_member_index
             if indata.get("vnf_member_index"):
@@ -507,6 +521,7 @@ class NsLcmOpTopic(BaseTopic):
         if operation == "instantiate":
             # check vim_account
             check_valid_vim_account(indata["vimAccountId"])
+            check_valid_wim_account(indata.get("wimAccountId"))
             for in_vnf in get_iterable(indata.get("vnf")):
                 vnfd = check_valid_vnf_member_index(in_vnf["member-vnf-index"])
                 _check_vnf_instantiation_params(in_vnf, vnfd)
@@ -514,6 +529,7 @@ class NsLcmOpTopic(BaseTopic):
                     check_valid_vim_account(in_vnf["vimAccountId"])
 
             for in_vld in get_iterable(indata.get("vld")):
+                check_valid_wim_account(in_vld.get("wimAccountId"))
                 for vldd in get_iterable(nsd.get("vld")):
                     if in_vld["name"] == vldd["name"] or in_vld["name"] == vldd["id"]:
                         break
index c79cdaf..1dd70dc 100644 (file)
@@ -224,9 +224,10 @@ ns_instantiate = {
         "nsInstanceId": id_schema,
         "netsliceInstanceId": id_schema,
         "nsName": name_schema,
-        "nsDescription": {"oneOf": [description_schema, {"type": "null"}]},
+        "nsDescription": {"oneOf": [description_schema, null_schema]},
         "nsdId": id_schema,
         "vimAccountId": id_schema,
+        "wimAccountId": {"OneOf": [id_schema, bool_schema, null_schema]},
         "additionalParamsForNs": object_schema,
         "additionalParamsForVnf": additional_params_for_vnf,
         "ssh_keys": {"type": "array", "items": {"type": "string"}},
@@ -265,6 +266,7 @@ ns_instantiate = {
                     "name": string_schema,
                     "vim-network-name": {"OneOf": [string_schema, object_schema]},
                     "vim-network-id": {"OneOf": [string_schema, object_schema]},
+                    "wimAccountId": {"OneOf": [id_schema, bool_schema, null_schema]},
                     "ip-profile": object_schema,
                     "vnfd-connection-point-ref": {
                         "type": "array",
@@ -679,7 +681,7 @@ nsi_instantiate = {
         "lcmOperationType": string_schema,
         "nsiInstanceId": id_schema,
         "nsiName": name_schema,
-        "nsiDescription": {"oneOf": [description_schema, {"type": "null"}]},
+        "nsiDescription": {"oneOf": [description_schema, null_schema]},
         "nstId": string_schema,
         "vimAccountId": id_schema,
         "ssh_keys": {"type": "string"},