+ return extra_dict
+
+ @staticmethod
+ def _prefix_ip_address(ip_address):
+ if "/" not in ip_address:
+ ip_address += "/32"
+ return ip_address
+
+ @staticmethod
+ def _process_ip_proto(ip_proto):
+ if ip_proto:
+ if ip_proto == 1:
+ ip_proto = "icmp"
+ elif ip_proto == 6:
+ ip_proto = "tcp"
+ elif ip_proto == 17:
+ ip_proto = "udp"
+ return ip_proto
+
+ @staticmethod
+ def _process_classification_params(
+ target_classification: Dict[str, Any],
+ indata: Dict[str, Any],
+ vim_info: Dict[str, Any],
+ target_record_id: str,
+ **kwargs: Dict[str, Any],
+ ) -> Dict[str, Any]:
+ """[summary]
+
+ Args:
+ target_classification (Dict[str, Any]): Classification dictionary parameters that needs to be processed to create resource on VIM
+ indata (Dict[str, Any]): Deployment info
+ vim_info (Dict[str, Any]):To add items created by OSM on the VIM.
+ target_record_id (str): Task record ID.
+ **kwargs (Dict[str, Any]): Used to send additional information to the task.
+
+ Returns:
+ Dict[str, Any]: Return parameters required to create classification and Items on which classification is dependent.
+ """
+ vnfr_id = target_classification["vnfr_id"]
+ vdur_id = target_classification["vdur_id"]
+ port_index = target_classification["ingress_port_index"]
+ extra_dict = {}
+
+ classification_data = {
+ "name": target_classification["id"],
+ "source_port_range_min": target_classification["source-port"],
+ "source_port_range_max": target_classification["source-port"],
+ "destination_port_range_min": target_classification["destination-port"],
+ "destination_port_range_max": target_classification["destination-port"],
+ }
+
+ classification_data["source_ip_prefix"] = Ns._prefix_ip_address(
+ target_classification["source-ip-address"]
+ )
+
+ classification_data["destination_ip_prefix"] = Ns._prefix_ip_address(
+ target_classification["destination-ip-address"]
+ )
+
+ classification_data["protocol"] = Ns._process_ip_proto(
+ int(target_classification["ip-proto"])
+ )
+
+ db = kwargs.get("db")
+ vdu_text = Ns._get_vnfr_vdur_text(db, vnfr_id, vdur_id)
+
+ extra_dict = {"depends_on": [vdu_text]}
+
+ extra_dict = {"depends_on": [vdu_text]}
+ classification_data["logical_source_port"] = "TASK-" + vdu_text
+ classification_data["logical_source_port_index"] = port_index
+
+ extra_dict["params"] = classification_data
+
+ return extra_dict
+
+ @staticmethod
+ def _process_sfi_params(
+ target_sfi: Dict[str, Any],
+ indata: Dict[str, Any],
+ vim_info: Dict[str, Any],
+ target_record_id: str,
+ **kwargs: Dict[str, Any],
+ ) -> Dict[str, Any]:
+ """[summary]
+
+ Args:
+ target_sfi (Dict[str, Any]): SFI dictionary parameters that needs to be processed to create resource on VIM
+ indata (Dict[str, Any]): deployment info
+ vim_info (Dict[str, Any]): To add items created by OSM on the VIM.
+ target_record_id (str): Task record ID.
+ **kwargs (Dict[str, Any]): Used to send additional information to the task.
+
+ Returns:
+ Dict[str, Any]: Return parameters required to create SFI and Items on which SFI is dependent.
+ """
+
+ vnfr_id = target_sfi["vnfr_id"]
+ vdur_id = target_sfi["vdur_id"]
+
+ sfi_data = {
+ "name": target_sfi["id"],
+ "ingress_port_index": target_sfi["ingress_port_index"],
+ "egress_port_index": target_sfi["egress_port_index"],
+ }
+
+ db = kwargs.get("db")
+ vdu_text = Ns._get_vnfr_vdur_text(db, vnfr_id, vdur_id)
+
+ extra_dict = {"depends_on": [vdu_text]}
+ sfi_data["ingress_port"] = "TASK-" + vdu_text
+ sfi_data["egress_port"] = "TASK-" + vdu_text
+
+ extra_dict["params"] = sfi_data
+
+ return extra_dict
+
+ @staticmethod
+ def _get_vnfr_vdur_text(db, vnfr_id, vdur_id):
+ vnf_preffix = "vnfrs:{}".format(vnfr_id)
+ db_vnfr = db.get_one("vnfrs", {"_id": vnfr_id})
+ vdur_list = []
+ vdu_text = ""
+
+ if db_vnfr:
+ vdur_list = [
+ vdur["id"] for vdur in db_vnfr["vdur"] if vdur["vdu-id-ref"] == vdur_id
+ ]
+
+ if vdur_list:
+ vdu_text = vnf_preffix + ":vdur." + vdur_list[0]
+
+ return vdu_text
+
+ @staticmethod
+ def _process_sf_params(
+ target_sf: Dict[str, Any],
+ indata: Dict[str, Any],
+ vim_info: Dict[str, Any],
+ target_record_id: str,
+ **kwargs: Dict[str, Any],
+ ) -> Dict[str, Any]:
+ """[summary]
+
+ Args:
+ target_sf (Dict[str, Any]): SF dictionary parameters that needs to be processed to create resource on VIM
+ indata (Dict[str, Any]): Deployment info.
+ vim_info (Dict[str, Any]):To add items created by OSM on the VIM.
+ target_record_id (str): Task record ID.
+ **kwargs (Dict[str, Any]): Used to send additional information to the task.
+
+ Returns:
+ Dict[str, Any]: Return parameters required to create SF and Items on which SF is dependent.
+ """
+
+ nsr_id = kwargs.get("nsr_id", "")
+ sfis = target_sf["sfis"]
+ ns_preffix = "nsrs:{}".format(nsr_id)
+ extra_dict = {"depends_on": [], "params": []}
+ sf_data = {"name": target_sf["id"], "sfis": sfis}
+
+ for count, sfi in enumerate(sfis):
+ sfi_text = ns_preffix + ":sfi." + sfi
+ sfis[count] = "TASK-" + sfi_text
+ extra_dict["depends_on"].append(sfi_text)
+
+ extra_dict["params"] = sf_data
+
+ return extra_dict
+
+ @staticmethod
+ def _process_sfp_params(
+ target_sfp: Dict[str, Any],
+ indata: Dict[str, Any],
+ vim_info: Dict[str, Any],
+ target_record_id: str,
+ **kwargs: Dict[str, Any],
+ ) -> Dict[str, Any]:
+ """[summary]
+
+ Args:
+ target_sfp (Dict[str, Any]): SFP dictionary parameters that needs to be processed to create resource on VIM.
+ indata (Dict[str, Any]): Deployment info
+ vim_info (Dict[str, Any]):To add items created by OSM on the VIM.
+ target_record_id (str): Task record ID.
+ **kwargs (Dict[str, Any]): Used to send additional information to the task.
+
+ Returns:
+ Dict[str, Any]: Return parameters required to create SFP and Items on which SFP is dependent.
+ """
+
+ nsr_id = kwargs.get("nsr_id")
+ sfs = target_sfp["sfs"]
+ classifications = target_sfp["classifications"]
+ ns_preffix = "nsrs:{}".format(nsr_id)
+ extra_dict = {"depends_on": [], "params": []}
+ sfp_data = {
+ "name": target_sfp["id"],
+ "sfs": sfs,
+ "classifications": classifications,
+ }
+
+ for count, sf in enumerate(sfs):
+ sf_text = ns_preffix + ":sf." + sf
+ sfs[count] = "TASK-" + sf_text
+ extra_dict["depends_on"].append(sf_text)
+
+ for count, classi in enumerate(classifications):
+ classi_text = ns_preffix + ":classification." + classi
+ classifications[count] = "TASK-" + classi_text
+ extra_dict["depends_on"].append(classi_text)
+
+ extra_dict["params"] = sfp_data