Skip to content
Snippets Groups Projects
Commit 1296e935 authored by Georgios Katsikas's avatar Georgios Katsikas
Browse files

fix: remove hardcoded service settings after pathcomp bug fix

parent 9dfe1e7f
No related branches found
No related tags found
2 merge requests!359Release TeraFlowSDN 5.0,!332feat: support for SD-Fabric dataplane
Showing
with 64 additions and 256 deletions
......@@ -335,56 +335,15 @@ class P4FabricACLServiceHandler(_ServiceHandler):
self.__settings = self.__settings_handler.get('/settings')
LOGGER.info("{} with settings: {}".format(self.__service_label, self.__settings))
except Exception as ex:
self.__settings = {}
LOGGER.error("Failed to parse service settings: {}".format(ex))
def _default_settings(self):
acl = [
{
PORT_ID: 1,
TRN_PORT_DST: 8080,
ACTION: ACTION_DROP
}
]
switch_info = {
"p4-sw1": {
ARCH: TARGET_ARCH_V1MODEL,
DPID: 1,
ACL: acl
}
}
self.__settings = {
SWITCH_INFO: switch_info
}
# port_map = {
# "p4-sw1": {
# "port-1": {
# PORT_ID: 1,
# ACL: [
# {
# IPV4_SRC: "10.158.72.11",
# IPV4_PREFIX_LEN: 32,
# ACTION: ACTION_DROP
# },
# {
# TRN_PORT_DST: 8080,
# ACTION: ACTION_DROP
# }
# ]
# }
# }
# }
LOGGER.error("Failed to retrieve service settings: {}".format(ex))
raise Exception(ex)
def _parse_settings(self):
#TODO: Pass settings in a correct way
try:
self.__switch_info = self.__settings[SWITCH_INFO]
self.__switch_info = self.__settings.value[SWITCH_INFO]
except Exception as ex:
LOGGER.error("Failed to parse settings: {}".format(ex))
self._default_settings() #TODO: Remove when bug is fixed
self.__switch_info = self.__settings[SWITCH_INFO]
LOGGER.error("Failed to parse service settings: {}".format(ex))
raise Exception(ex)
assert isinstance(self.__switch_info, dict), "Switch info object must be a map with switch names as keys"
for switch_name, switch_info in self.__switch_info.items():
......
......@@ -305,43 +305,15 @@ class P4FabricINTServiceHandler(_ServiceHandler):
self.__settings = self.__settings_handler.get('/settings')
LOGGER.info("{} with settings: {}".format(self.__service_label, self.__settings))
except Exception as ex:
self.__settings = {}
LOGGER.error("Failed to parse service settings: {}".format(ex))
def _default_settings(self):
switch_info = {
"p4-sw1": {
ARCH: TARGET_ARCH_V1MODEL,
DPID: 1,
MAC: "fa:16:3e:93:8c:c0",
IP: "10.10.10.120",
PORT_INT: {
PORT_ID: 3,
PORT_TYPE: "host"
},
RECIRCULATION_PORT_LIST: RECIRCULATION_PORTS_V1MODEL,
INT_REPORT_MIRROR_ID_LIST: INT_REPORT_MIRROR_ID_LIST_V1MODEL
}
}
int_collector_info = {
MAC: "fa:16:3e:fb:cf:96",
IP: "10.10.10.41",
PORT: 32766,
VLAN_ID: 4094
}
self.__settings = {
SWITCH_INFO: switch_info,
INT_COLLECTOR_INFO: int_collector_info
}
LOGGER.error("Failed to retrieve service settings: {}".format(ex))
raise Exception(ex)
def _parse_settings(self):
#TODO: Pass settings in a correct way
try:
self.__switch_info = self.__settings[SWITCH_INFO]
self.__switch_info = self.__settings.value[SWITCH_INFO]
except Exception as ex:
LOGGER.error("Failed to parse settings: {}".format(ex))
self._default_settings() #TODO: Remove when bug is fixed
self.__switch_info = self.__settings[SWITCH_INFO]
LOGGER.error("Failed to parse service settings: {}".format(ex))
raise Exception(ex)
assert isinstance(self.__switch_info, dict), "Switch info object must be a map with switch names as keys"
for switch_name, switch_info in self.__switch_info.items():
......@@ -364,7 +336,7 @@ class P4FabricINTServiceHandler(_ServiceHandler):
switch_info[INT_REPORT_MIRROR_ID_LIST] = INT_REPORT_MIRROR_ID_LIST_V1MODEL
assert isinstance(switch_info[RECIRCULATION_PORT_LIST], list), "Switch {} - Recirculation ports must be described as a list".format(switch_name)
self.__int_collector_info = self.__settings[INT_COLLECTOR_INFO]
self.__int_collector_info = self.__settings.value[INT_COLLECTOR_INFO]
assert isinstance(self.__int_collector_info, dict), "INT collector info object must be a map with mac, ip, port, and vlan_id keys)"
self.__int_collector_mac = self.__int_collector_info[MAC]
......
......@@ -318,69 +318,15 @@ class P4FabricL2SimpleServiceHandler(_ServiceHandler):
self.__settings = self.__settings_handler.get('/settings')
LOGGER.info("{} with settings: {}".format(self.__service_label, self.__settings))
except Exception as ex:
self.__settings = {}
LOGGER.error("Failed to parse service settings: {}".format(ex))
def _default_settings(self):
port_list = [
{
PORT_ID: 1,
PORT_TYPE: "host",
VLAN_ID: 4094
},
{
PORT_ID: 2,
PORT_TYPE: "host",
VLAN_ID: 4094
},
]
fwd_list = [
{
PORT_ID: 1,
HOST_MAC: "fa:16:3e:75:9c:e5"
},
{
PORT_ID: 2,
HOST_MAC: "fa:16:3e:e2:af:28"
}
]
switch_info = {
"p4-sw1": {
ARCH: TARGET_ARCH_V1MODEL,
DPID: 1,
PORT_LIST: port_list,
FORWARDING_LIST: fwd_list
}
}
self.__settings = {
SWITCH_INFO: switch_info
}
# port_map = {
# "p4-sw1": {
# "port-1": {
# PORT_ID: 1,
# PORT_TYPE: PORT_TYPE_HOST,
# VLAN_ID: 4094,
# FORWARDING_LIST: ["fa:16:3e:75:9c:e5"]
# },
# "port-2": {
# PORT_ID: 2,
# PORT_TYPE: PORT_TYPE_HOST,
# VLAN_ID: 4094,
# FORWARDING_LIST: ["fa:16:3e:e2:af:28"]
# }
# }
# }
LOGGER.error("Failed to retrieve service settings: {}".format(ex))
raise Exception(ex)
def _parse_settings(self):
#TODO: Pass settings in a correct way
try:
self.__switch_info = self.__settings[SWITCH_INFO]
self.__switch_info = self.__settings.value[SWITCH_INFO]
except Exception as ex:
LOGGER.error("Failed to parse settings: {}".format(ex))
self._default_settings() #TODO: Remove when bug is fixed
self.__switch_info = self.__settings[SWITCH_INFO]
LOGGER.error("Failed to parse service settings: {}".format(ex))
raise Exception(ex)
assert isinstance(self.__switch_info, dict), "Switch info object must be a map with switch names as keys"
for switch_name, switch_info in self.__switch_info.items():
......
......@@ -316,85 +316,15 @@ class P4FabricL3ServiceHandler(_ServiceHandler):
self.__settings = self.__settings_handler.get('/settings')
LOGGER.info("{} with settings: {}".format(self.__service_label, self.__settings))
except Exception as ex:
self.__settings = {}
LOGGER.error("Failed to parse service settings: {}".format(ex))
def _default_settings(self):
port_list = [
{
PORT_ID: 1,
PORT_TYPE: "host"
},
{
PORT_ID: 2,
PORT_TYPE: "host"
},
]
routing_list = [
{
PORT_ID: 1,
IPV4_DST: "10.158.72.11",
IPV4_PREFIX_LEN: 32,
MAC_SRC: "fa:16:3e:e2:af:28",
MAC_DST: "fa:16:3e:75:9c:e5"
},
{
PORT_ID: 2,
IPV4_DST: "172.16.10.9",
IPV4_PREFIX_LEN: 32,
MAC_SRC: "fa:16:3e:75:9c:e5",
MAC_DST: "fa:16:3e:e2:af:28"
}
]
switch_info = {
"p4-sw1": {
ARCH: TARGET_ARCH_V1MODEL,
DPID: 1,
PORT_LIST: port_list,
ROUTING_LIST: routing_list
}
}
self.__settings = {
SWITCH_INFO: switch_info
}
# port_map = {
# "p4-sw1": {
# "port-1": {
# PORT_ID: 1,
# PORT_TYPE: PORT_TYPE_HOST,
# ROUTING_LIST: [
# {
# IPV4_DST: "10.158.72.11",
# IPV4_PREFIX_LEN: 32,
# MAC_SRC: "fa:16:3e:e2:af:28",
# MAC_DST: "fa:16:3e:75:9c:e5"
# }
# ]
# },
# "port-2": {
# PORT_ID: 2,
# PORT_TYPE: PORT_TYPE_HOST,
# ROUTING_LIST: [
# {
# IPV4_DST: "172.16.10.9",
# IPV4_PREFIX_LEN: 32,
# MAC_SRC: "fa:16:3e:75:9c:e5",
# MAC_DST: "fa:16:3e:e2:af:28"
# }
# ]
# }
# }
# }
LOGGER.error("Failed to retrieve service settings: {}".format(ex))
raise Exception(ex)
def _parse_settings(self):
#TODO: Pass settings in a correct way
try:
self.__switch_info = self.__settings[SWITCH_INFO]
self.__switch_info = self.__settings.value[SWITCH_INFO]
except Exception as ex:
LOGGER.error("Failed to parse settings: {}".format(ex))
self._default_settings() #TODO: Remove when bug is fixed
self.__switch_info = self.__settings[SWITCH_INFO]
LOGGER.error("Failed to parse service settings: {}".format(ex))
raise Exception(ex)
assert isinstance(self.__switch_info, dict), "Switch info object must be a map with switch names as keys"
for switch_name, switch_info in self.__switch_info.items():
......
......@@ -9,11 +9,11 @@
"service_status": {"service_status": "SERVICESTATUS_PLANNED"},
"service_endpoint_ids": [
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "1"}
},
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "2"}
}
],
......@@ -25,7 +25,7 @@
"resource_key": "/settings",
"resource_value": {
"switch_info": {
"p4-sw1": {
"sw1": {
"arch": "v1model",
"dpid": 1,
"acl": [
......
......@@ -9,11 +9,11 @@
"service_status": {"service_status": "SERVICESTATUS_PLANNED"},
"service_endpoint_ids": [
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "1"}
},
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "2"}
}
],
......@@ -25,11 +25,11 @@
"resource_key": "/settings",
"resource_value": {
"switch_info": {
"p4-sw1": {
"sw1": {
"arch": "v1model",
"dpid": 1,
"mac": "fa:16:3e:93:8c:c0",
"ip": "10.10.10.120",
"mac": "ee:ee:8c:6c:f3:2c",
"ip": "192.168.5.139",
"int_port": {
"port_id": 3,
"port_type": "host"
......@@ -37,8 +37,8 @@
}
},
"int_collector_info": {
"mac": "fa:16:3e:fb:cf:96",
"ip": "10.10.10.41",
"mac": "46:e4:58:c6:74:53",
"ip": "192.168.5.137",
"port": 32766,
"vlan_id": 4094
}
......
......@@ -9,11 +9,11 @@
"service_status": {"service_status": "SERVICESTATUS_PLANNED"},
"service_endpoint_ids": [
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "1"}
},
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "2"}
}
],
......@@ -25,7 +25,7 @@
"resource_key": "/settings",
"resource_value": {
"switch_info": {
"p4-sw1": {
"sw1": {
"arch": "v1model",
"dpid": 1,
"port_list": [
......@@ -43,11 +43,11 @@
"fwd_list": [
{
"port_id": 1,
"host_mac": "fa:16:3e:75:9c:e5"
"host_mac": "00:00:00:00:00:01"
},
{
"port_id": 2,
"host_mac": "fa:16:3e:e2:af:28"
"host_mac": "00:00:00:00:00:02"
}
]
}
......
......@@ -9,11 +9,11 @@
"service_status": {"service_status": "SERVICESTATUS_PLANNED"},
"service_endpoint_ids": [
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "1"}
},
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"endpoint_uuid": {"uuid": "2"}
}
],
......@@ -25,7 +25,7 @@
"resource_key": "/settings",
"resource_value": {
"switch_info": {
"p4-sw1": {
"sw1": {
"arch": "v1model",
"dpid": 1,
"port_list": [
......@@ -41,17 +41,17 @@
"routing_list": [
{
"port_id": 1,
"ipv4_dst": "10.158.72.11",
"ipv4_dst": "10.0.0.1",
"ipv4_prefix_len": 32,
"mac_src": "fa:16:3e:e2:af:28",
"mac_dst": "fa:16:3e:75:9c:e5"
"mac_src": "00:00:00:00:00:02",
"mac_dst": "00:00:00:00:00:01"
},
{
"port_id": 2,
"ipv4_dst": "172.16.10.9",
"ipv4_dst": "10.0.0.2",
"ipv4_prefix_len": 32,
"mac_src": "fa:16:3e:75:9c:e5",
"mac_dst": "fa:16:3e:e2:af:28"
"mac_src": "00:00:00:00:00:01",
"mac_dst": "00:00:00:00:00:02"
}
]
}
......
......@@ -11,11 +11,11 @@
"device_id": {"device_uuid": {"uuid": "tfs-sdn-controller"}},
"name": "tfs-sdn-controller",
"device_type": "teraflowsdn",
"device_drivers": ["DEVICEDRIVER_IETF_L3VPN"],
"device_drivers": ["DEVICEDRIVER_IETF_L2VPN"],
"device_operational_status": "DEVICEOPERATIONALSTATUS_UNDEFINED",
"device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.10.10.41"}},
{"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8002"}},
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "192.168.5.137"}},
{"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8003"}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {
"endpoints": [{"uuid": "mgmt", "name": "mgmt", "type": "mgmt-int"}],
"scheme": "http", "username": "admin", "password": "admin", "import_topology": "topology"
......@@ -51,18 +51,18 @@
}
},
{
"device_id": {"device_uuid": {"uuid": "p4-sw1"}},
"device_id": {"device_uuid": {"uuid": "sw1"}},
"device_type": "p4-switch",
"device_drivers": ["DEVICEDRIVER_P4"],
"device_operational_status": "DEVICEOPERATIONALSTATUS_DISABLED",
"name": "p4-sw1",
"name": "sw1",
"device_config": {
"config_rules": [
{"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "10.10.10.120"}},
{"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/address", "resource_value": "192.168.5.139"}},
{"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/port", "resource_value": "50001"}},
{"action": "CONFIGACTION_SET", "custom": {"resource_key": "_connect/settings", "resource_value": {
"id": 1,
"name": "p4-sw1",
"name": "sw1",
"vendor": "Open Networking Foundation",
"hw_ver": "BMv2 simple_switch",
"sw_ver": "Stratum",
......@@ -81,32 +81,32 @@
],
"links": [
{
"link_id": {"link_uuid": {"uuid": "p4-sw1/1==edge-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "p4-sw1"}}, "endpoint_uuid": {"uuid": "1"}},
"link_id": {"link_uuid": {"uuid": "sw1/1==edge-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "1"}},
{"device_id": {"device_uuid": {"uuid": "edge-net"}}, "endpoint_uuid": {"uuid": "eth1"}}
]
},
{
"link_id": {"link_uuid": {"uuid": "edge-net/eth1==p4-sw1/1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
"link_id": {"link_uuid": {"uuid": "edge-net/eth1==sw1/1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "edge-net"}}, "endpoint_uuid": {"uuid": "eth1"}},
{"device_id": {"device_uuid": {"uuid": "p4-sw1"}}, "endpoint_uuid": {"uuid": "1"}}
{"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "1"}}
]
},
{
"link_id": {"link_uuid": {"uuid": "p4-sw1/2==corporate-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "p4-sw1"}}, "endpoint_uuid": {"uuid": "2"}},
"link_id": {"link_uuid": {"uuid": "sw1/2==corporate-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "2"}},
{"device_id": {"device_uuid": {"uuid": "corporate-net"}}, "endpoint_uuid": {"uuid": "eth1"}}
]
},
{
"link_id": {"link_uuid": {"uuid": "corporate-net/eth1==p4-sw1/2"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
"link_id": {"link_uuid": {"uuid": "corporate-net/eth1==sw1/2"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "corporate-net"}}, "endpoint_uuid": {"uuid": "eth1"}},
{"device_id": {"device_uuid": {"uuid": "p4-sw1"}}, "endpoint_uuid": {"uuid": "2"}}
{"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "2"}}
]
},
{
"link_id": {"link_uuid": {"uuid": "p4-sw1/3==tfs-sdn-controller/mgmt"}}, "link_type": "LINKTYPE_MANAGEMENT", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "p4-sw1"}}, "endpoint_uuid": {"uuid": "3"}},
"link_id": {"link_uuid": {"uuid": "sw1/3==tfs-sdn-controller/mgmt"}}, "link_type": "LINKTYPE_MANAGEMENT", "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "3"}},
{"device_id": {"device_uuid": {"uuid": "tfs-sdn-controller"}}, "endpoint_uuid": {"uuid": "mgmt"}}
]
}
......
......@@ -18,10 +18,11 @@
description: "Chassis configuration for a single Stratum bmv2 switch with 3 ports"
chassis {
platform: PLT_P4_SOFT_SWITCH
name: "bmv2-switch"
name: "sw1"
}
nodes {
id: 1
name: "sw1 node 1"
slot: 1
index: 1
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment