Newer
Older
# Load L3VPN service template
self.__load_template(2, os.path.join(TEMPLATES_PATH, "L3-VPN_template_empty.json"))
tfs_request = json.loads(str(self.__teraflow_template))["services"][0]
# Generate unique service UUID
tfs_request["service_id"]["service_uuid"]["uuid"] += "-" + str(int(datetime.now().timestamp() * 1e7))
# Configure service endpoints
for endpoint in tfs_request["service_endpoint_ids"]:
endpoint["device_id"]["device_uuid"]["uuid"] = origin_router_id if endpoint is tfs_request["service_endpoint_ids"][0] else destination_router_id
endpoint["endpoint_uuid"]["uuid"] = origin_router_if if endpoint is tfs_request["service_endpoint_ids"][0] else destination_router_if
for i, constraint in enumerate(ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"]):
bound = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["bound"]
metric_type = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["metric-type"]
metric_unit = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["metric-unit"]
service_constraint ={
"custom": {
"constraint_type": f"{metric_type}[{metric_unit}]",
"constraint_value": f"{bound}"
}
}
self.answer[self.subnet]["QoS Requirements"].append(service_constraint["custom"])
tfs_request["service_constraints"].append(service_constraint)
# Add configuration rules
for i, config_rule in enumerate(tfs_request["service_config"]["config_rules"][1:], start=1):
router_id = origin_router_id if i == 1 else destination_router_id
router_if = origin_router_if if i == 1 else destination_router_if
resource_value = config_rule["custom"]["resource_value"]
sdp_index = i - 1
vlan_value = ietf_intent["ietf-network-slice-service:network-slice-services"]["slice-service"][0]["sdps"]["sdp"][sdp_index]["service-match-criteria"]["match-criterion"][0]["value"]
resource_value["router_id"] = destination_router_id if i == 1 else origin_router_id
resource_value["vlan_id"] = int(vlan_value)
resource_value["address_ip"] = destination_router_id if i == 1 else origin_router_id
resource_value["policy_AZ"] = "policyA"
resource_value["policy_ZA"] = "policyB"
resource_value["ni_name"] = 'ELAN{:s}'.format(str(vlan_value))
config_rule["custom"]["resource_key"] = f"/device[{router_id}]/endpoint[{router_if}]/settings"
logging.info(f"L3VPN Intent realized\n")
self.answer[self.subnet]["VLAN"] = vlan_value
def __ixia(self, ietf_intent):
"""
Prepare an Ixia service request based on the IETF intent.
This method configures an Ixia service request by:
1. Defining endpoint routers
2. Loading a service template
3. Generating a unique service UUID
4. Configuring service endpoints
5. Adding QoS constraints
Args:
ietf_intent (dict): IETF-formatted network slice intent.
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
Returns:
dict: An Ixia service request for configuration.
"""
self.answer[self.subnet]["QoS Requirements"] = []
# Add service constraints
for i, constraint in enumerate(ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"]):
bound = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["bound"]
metric_type = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["metric-type"]
metric_unit = ietf_intent["ietf-network-slice-service:network-slice-services"]["slo-sle-templates"]["slo-sle-template"][0]["slo-policy"]["metric-bound"][i]["metric-unit"]
service_constraint ={
"custom": {
"constraint_type": f"{metric_type}[{metric_unit}]",
"constraint_value": f"{bound}"
}
}
self.answer[self.subnet]["QoS Requirements"].append(service_constraint["custom"])
self.answer[self.subnet]["VLAN"] = ietf_intent["ietf-network-slice-service:network-slice-services"]["slice-service"][0]["sdps"]["sdp"][0]["service-match-criteria"]["match-criterion"][0]["value"]
# Extraer la lista de métricas de forma segura
metric_bounds = ietf_intent.get("ietf-network-slice-service:network-slice-services", {}) \
.get("slo-sle-templates", {}) \
.get("slo-sle-template", [{}])[0] \
.get("slo-policy", {}) \
.get("metric-bound", [])
# Inicializar valores
bandwidth = None
latency = None
tolerance = None
# Asignar valores según el tipo de métrica
for metric in metric_bounds:
metric_type = metric.get("metric-type")
bound = metric.get("bound")
if metric_type == "one-way-bandwidth":
bandwidth = bound
elif metric_type == "one-way-delay-maximum":
latency = bound
elif metric_type == "one-way-delay-variation-maximum":
tolerance = bound
# Construcción del diccionario intent
intent = {
"src_node_ip": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
.get("slice-service", [{}])[0]
.get("sdps", {}).get("sdp", [{}])[0]
.get("attachment-circuits", {}).get("attachment-circuit", [{}])[0]
.get("sdp-peering", {}).get("peer-sap-id"),
"dst_node_ip": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
.get("slice-service", [{}])[0]
.get("sdps", {}).get("sdp", [{}, {}])[1]
.get("attachment-circuits", {}).get("attachment-circuit", [{}])[0]
.get("sdp-peering", {}).get("peer-sap-id"),
"vlan_id": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
.get("slice-service", [{}])[0]
.get("sdps", {}).get("sdp", [{}])[0]
.get("service-match-criteria", {}).get("match-criterion", [{}])[0]
.get("value"),
"bandwidth": bandwidth,
"latency": latency,
"tolerance": tolerance,
"latency_version": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
.get("slo-sle-templates", {}).get("slo-sle-template", [{}])[0]
.get("description"),
"reliability": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
.get("slo-sle-templates", {}).get("slo-sle-template", [{}])[0]
.get("sle-policy", {}).get("reliability"),
}
logging.info(f"IXIA Intent realized\n")
return intent