- def ns_update_vnfr(self, db_vnfrs, ns_RO_info):
- """
- Updates database vnfr with the RO info, e.g. ip_address, vim_id... Descriptor db_vnfrs is also updated
- :param db_vnfrs:
- :param ns_RO_info:
- :return:
- """
- for vnf_index, db_vnfr in db_vnfrs.items():
- vnfr_deployed = ns_RO_info.get(vnf_index)
- if not vnfr_deployed:
- continue
- vnfr_update = {}
- db_vnfr["ip-address"] = vnfr_update["ip-address"] = vnfr_deployed.get("ip_address")
- for index, vdur in enumerate(db_vnfr["vdur"]):
- vdu_deployed = vnfr_deployed["vdur"].get(vdur["vdu-id-ref"])
- if not vdu_deployed:
- continue
- vnfr_update["vdur.{}.vim-id".format(index)] = vdu_deployed.get("vim_id")
- db_vnfr["vdur"][index]["vim-id"] = vnfr_update["vdur.{}.vim-id".format(index)]
- vnfr_update["vdur.{}.ip-address".format(index)] = vdu_deployed.get("ip_address")
- db_vnfr["vdur"][index]["ip-address"] = vnfr_update["vdur.{}.ip-address".format(index)]
- for index2, interface in enumerate(vdur["interfaces"]):
- iface_deployed = vdu_deployed["interfaces"].get(interface["name"])
- if not iface_deployed:
- continue
- db_vnfr["vdur"][index]["interfaces"][index2]["vim-id"] =\
- vnfr_update["vdur.{}.interfaces.{}.vim-id".format(index, index2)] = iface_deployed.get("vim_id")
- db_vnfr["vdur"][index]["interfaces"][index2]["ip-address"] =\
- vnfr_update["vdur.{}.interfaces.{}.ip-address".format(index, index2)] = iface_deployed.get(
- "ip_address")
- db_vnfr["vdur"][index]["interfaces"][index2]["mac-address"] =\
- vnfr_update["vdur.{}.interfaces.{}.mac-address".format(index, index2)] = iface_deployed.get(
- "mac_address")
- self.update_db_2("vnfrs", db_vnfr["_id"], vnfr_update)
-
- def ns_update_vnfr_2(self, db_vnfrs, nsr_desc_RO):