Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
cisco_source.execute_commands(commands)
#cisco_destiny = cisco_connector(destination_address, ni_name, remote_router, vlan, vlan % 10 + 1)
cisco_destiny = cisco_connector(destinations["destination"], destinations["config"])
commands = cisco_destiny.full_create_command_template()
cisco_destiny.execute_commands(commands)
def __tfs_l2vpn_delete(self):
"""
Delete L2VPN configurations from Cisco devices.
This method removes L2VPN configurations from Cisco routers
Notes:
- Uses cisco_connector to generate and execute deletion commands
- Clears Network Interface (NI) settings
"""
# Delete Source Endpoint Configuration
source_address = "10.60.125.44"
cisco_source = cisco_connector(source_address)
cisco_source.execute_commands(cisco_source.create_command_template_delete())
# Delete Destination Endpoint Configuration
destination_address = "10.60.125.45"
cisco_destiny = cisco_connector(destination_address)
cisco_destiny.execute_commands(cisco_destiny.create_command_template_delete())
def __tfs_l3vpn(self, ietf_intent):
"""
Translate L3VPN (Layer 3 Virtual Private Network) intent into a TeraFlow service request.
Similar to __tfs_l2vpn, but configured for Layer 3 VPN:
1. Defines endpoint routers
2. Loads service template
3. Generates unique service UUID
4. Configures service endpoints
5. Adds QoS constraints
6. Prepares configuration rules for network interfaces
Args:
ietf_intent (dict): IETF-formatted network slice intent.
Returns:
dict: A TeraFlow service request for L3VPN configuration.
"""
# Hardcoded router endpoints
# TODO (should be dynamically determined)
origin_router_id = ietf_intent["ietf-network-slice-service:network-slice-services"]["slice-service"][0]["sdps"]["sdp"][0]["attachment-circuits"]["attachment-circuit"][0]["sdp-peering"]["peer-sap-id"]
origin_router_if = '0/0/0-GigabitEthernet0/0/0/0'
destination_router_id = ietf_intent["ietf-network-slice-service:network-slice-services"]["slice-service"][0]["sdps"]["sdp"][1]["attachment-circuits"]["attachment-circuit"][0]["sdp-peering"]["peer-sap-id"]
# 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.
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
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