+ Returns:
+ vim_id (str): VIM account id as string
+
+ Raises:
+ NotFound Exception
+ """
+ self._logger.debug("")
+ if vim_account_dict.get(vim_account):
+ return vim_account_dict[vim_account]
+ vim = self._client.vim.get(vim_account)
+ if vim is None:
+ raise NotFound("cannot find vim account '{}'".format(vim_account))
+ vim_account_dict[vim_account] = vim["_id"]
+ return vim["_id"]
+
+ def _get_wim_account_id(self, wim_account: str, wim_account_dict: dict) -> str:
+ """Get WIM account ID.
+ Args:
+ wim_account (str): WIM account id as string
+ wim_account_dict (dict): A dictionary which includes wim account id
+
+ Returns:
+ wim_id (str): WIM account id as string
+
+ Raises:
+ NotFound Exception
+ """
+ self._logger.debug("")
+ # wim_account can be False (boolean) to indicate not use wim account
+ if not isinstance(wim_account, str):
+ return wim_account
+ if wim_account_dict.get(wim_account):
+ return wim_account_dict[wim_account]
+ wim = self._client.wim.get(wim_account)
+ if wim is None:
+ raise NotFound("cannot find wim account '{}'".format(wim_account))
+ wim_account_dict[wim_account] = wim["_id"]
+ return wim["_id"]
+
+ def _get_paas_account_id(self, paas_account: str) -> str:
+ """Get PaaS account ID.
+ Args:
+ paas_account (str): PaaS account id as string
+
+ Returns:
+ paas_id (str): PaaS account id as string
+
+ Raises:
+ NotFound Exception
+ """
+ self._logger.debug("")
+ paas = self._client.paas.get(paas_account)
+ if paas is None:
+ raise NotFound("cannot find PaaS account '{}'".format(paas_account))
+ return paas["_id"]
+
+ def _update_vnf_in_ns_config(self, ns_config: dict, vim_account_dict: dict) -> dict:
+ """Update vnf field in ns_config.
+ Args:
+ ns_config (dict): NS config dictionary which includes additional params
+ vim_account_dict (dict): A dictionary which includes vim account id
+
+ Returns:
+ ns (dict): NS dictionary
+ """
+ if "vnf" in ns_config:
+ for vnf in ns_config["vnf"]:
+ if vnf.get("vim_account"):
+ vnf["vimAccountId"] = self._get_vim_account_id(
+ vnf.pop("vim_account"), vim_account_dict
+ )
+ return ns_config
+
+ def _update_wim_account_in_ns(
+ self, ns_config: dict, wim_account_dict: dict, ns: dict
+ ) -> dict:
+ """Update WIM_account in NS dictionary.
+ Args:
+ ns_config (dict): NS config dictionary which includes additional params
+ wim_account_dict (dict): A dictionary which includes wim account id
+ ns (dict): NS dictionary which includes ns_id, ns_name, description etc.
+
+ Returns:
+ ns (dict): NS dictionary
+ """
+ if "wim_account" in ns_config:
+ wim_account = ns_config.pop("wim_account")
+ if wim_account is not None:
+ ns["wimAccountId"] = self._get_wim_account_id(
+ wim_account, wim_account_dict
+ )
+ return ns
+
+ def _update_vld_in_ns_config(
+ self, ns_config: dict, vim_account_dict: dict, wim_account_dict: dict
+ ) -> dict:
+ """Validating the additionalParamsForNs and additionalParamsForVnf in ns_config.