Fix bug 1701: remove vcaId parameter in NS deployment

With this change, in the deployment request, the NBI will get the vca id
from the vim id, which is information that already has.

Change-Id: I31ec3d82da8f55641c3b4869cb3afed465073549
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py
index 94adb7b..de77d5d 100644
--- a/osm_nbi/instance_topics.py
+++ b/osm_nbi/instance_topics.py
@@ -432,6 +432,18 @@
 
         return ns_k8s_namespace
 
+    def _get_vim_account(self, vim_id: str, session):
+        try:
+            db_filter = self._get_project_filter(session)
+            db_filter["_id"] = vim_id
+            return self.db.get_one("vim_accounts", db_filter)
+        except Exception:
+            raise EngineException(
+                "Invalid vimAccountId='{}' not present for the project".format(
+                    vim_id
+                )
+            )
+
     def _create_nsr_descriptor_from_nsd(self, nsd, ns_request, nsr_id, session):
         now = time()
         additional_params, _ = self._format_additional_params(
@@ -478,7 +490,10 @@
         ns_request["nsr_id"] = nsr_id
         if ns_request and ns_request.get("config-units"):
             nsr_descriptor["config-units"] = ns_request["config-units"]
-
+        vim_account_id = nsr_descriptor["instantiate_params"].get("vimAccountId")
+        if vim_account_id:
+            vca_id = self._get_vim_account(vim_account_id, session).get("vca")
+            nsr_descriptor["instantiate_params"]["vcaId"] = vca_id
         # Create vld
         if nsd.get("virtual-link-desc"):
             nsr_vld = deepcopy(nsd.get("virtual-link-desc", []))
@@ -1326,6 +1341,18 @@
             )
         vim_accounts.append(vim_account)
 
+    def _get_vim_account(self, vim_id: str, session):
+        try:
+            db_filter = self._get_project_filter(session)
+            db_filter["_id"] = vim_id
+            return self.db.get_one("vim_accounts", db_filter)
+        except Exception:
+            raise EngineException(
+                "Invalid vimAccountId='{}' not present for the project".format(
+                    vim_id
+                )
+            )
+
     def _check_valid_wim_account(self, wim_account, wim_accounts, session):
         if not isinstance(wim_account, str):
             return
@@ -1600,15 +1627,14 @@
             # update vim-account-id
 
             vim_account = indata["vimAccountId"]
-            vca_id = indata.get("vcaId")
+            vca_id = self._get_vim_account(vim_account, session).get("vca")
             # check instantiate parameters
             for vnf_inst_params in get_iterable(indata.get("vnf")):
                 if vnf_inst_params["member-vnf-index"] != member_vnf_index:
                     continue
                 if vnf_inst_params.get("vimAccountId"):
                     vim_account = vnf_inst_params.get("vimAccountId")
-                if vnf_inst_params.get("vcaId"):
-                    vca_id = vnf_inst_params.get("vcaId")
+                    vca_id = self._get_vim_account(vim_account, session).get("vca")
 
                 # get vnf.vdu.interface instantiation params to update vnfr.vdur.interfaces ip, mac
                 for vdu_inst_param in get_iterable(vnf_inst_params.get("vdu")):
diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py
index 681a67d..6a6eeee 100644
--- a/osm_nbi/validation.py
+++ b/osm_nbi/validation.py
@@ -330,7 +330,6 @@
         "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,
@@ -351,7 +350,6 @@
                 "properties": {
                     "member-vnf-index": name_schema,
                     "vimAccountId": id_schema,
-                    "vcaId": id_schema,
                     "vdu": {
                         "type": "array",
                         "minItems": 1,