forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC4292][Namespace]: Fix implementation of RouteUpdater for multi-as…
…ic platform (sonic-net#176) * [RFC4292][Namespace]: Fix implementation of RouteUpdater for multi-asic platform. For multi-asic platforms, the default route was getting retrieved from only the last namespace as the result dictionary was being written with the same key. To avoid this, modify implementation to retrieve default routes from all front end asic namespaces.Update implementation to ensure that only external routes are displayed in the result. Add test case to test multiple namespaces.
- Loading branch information
1 parent
b8f19ee
commit 64c93a1
Showing
8 changed files
with
429 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
{ | ||
"DEVICE_METADATA|localhost": { | ||
"chassis_serial_number": "SAMPLETESTSN", | ||
"sub_role": "FrontEnd" | ||
}, | ||
"PORT_TABLE:Ethernet0": { | ||
"description": "snowflake", | ||
"alias": "etp1", | ||
"role": "Ext", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet4": { | ||
"description": "snowflake", | ||
"alias": "etp2", | ||
"role": "Ext", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet-BP0": { | ||
"description": "snowflake", | ||
"alias": "etp3", | ||
"role": "Int", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet-BP4": { | ||
"description": "snowflake", | ||
"alias": "etp4", | ||
"role": "Int", | ||
"speed": 100000 | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel01:Ethernet-BP0": { | ||
"status": "enabled" | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel01:Ethernet-BP4": { | ||
"status": "enabled" | ||
}, | ||
"LAG_TABLE:PortChannel01": { | ||
"admin_status": "up", | ||
"oper_status": "up", | ||
"mtu": "9216" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,38 @@ | ||
{ | ||
"DEVICE_METADATA|localhost": { | ||
"chassis_serial_number": "SAMPLETESTSN", | ||
"sub_role": "FrontEnd" | ||
}, | ||
"PORT_TABLE:Ethernet8": { | ||
"description": "snowflake", | ||
"alias": "etp5", | ||
"role": "Ext", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet12": { | ||
"speed": 1000, | ||
"role": "Ext", | ||
"alias": "etp6" | ||
}, | ||
"PORT_TABLE:Ethernet-BP8": { | ||
"role": "Int", | ||
"alias": "etp7" | ||
}, | ||
"PORT_TABLE:Ethernet-BP12": { | ||
"description": "snowflake", | ||
"role": "Int", | ||
"alias": "etp8", | ||
"speed": 1000 | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel02:Ethernet-BP08": { | ||
"status": "enabled" | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel02:Ethernet-BP12": { | ||
"status": "enabled" | ||
}, | ||
"LAG_TABLE:PortChannel02": { | ||
"admin_status": "up", | ||
"oper_status": "up", | ||
"mtu": "9216" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,53 @@ | ||
{ | ||
"DEVICE_METADATA|localhost": { | ||
"chassis_serial_number": "SAMPLETESTSN", | ||
"sub_role": "BackEnd" | ||
}, | ||
"PORT_TABLE:Ethernet-BP16": { | ||
"description": "backplane", | ||
"alias": "etp9", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet-BP20": { | ||
"description": "backplane", | ||
"alias": "etp10", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet-BP24": { | ||
"description": "backplane", | ||
"alias": "etp11", | ||
"speed": 100000 | ||
}, | ||
"PORT_TABLE:Ethernet-BP28": { | ||
"description": "backplane", | ||
"alias": "etp12", | ||
"speed": 100000 | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel03:Ethernet-BP16": { | ||
"status": "enabled" | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel03:Ethernet-BP20": { | ||
"status": "enabled" | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel04:Ethernet-BP24": { | ||
"status": "enabled" | ||
}, | ||
"LAG_MEMBER_TABLE:PortChannel04:Ethernet-BP28": { | ||
"status": "enabled" | ||
}, | ||
"LAG_TABLE:PortChannel03": { | ||
"admin_status": "up", | ||
"oper_status": "up", | ||
"mtu": "9216" | ||
}, | ||
"LAG_TABLE:PortChannel04": { | ||
"admin_status": "up", | ||
"oper_status": "up", | ||
"mtu": "9216" | ||
}, | ||
"LAG_TABLE:PortChannel_Temp": { | ||
"admin_status": "up", | ||
"oper_status": "up", | ||
"mtu": "9216" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import json | ||
|
||
import tests.mock_tables.dbconnector | ||
from sonic_py_common import multi_asic | ||
from swsssdk import SonicDBConfig | ||
|
||
INPUT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
int_port_channel = ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04'] | ||
|
||
def mock_get_num_asics(): | ||
ns_list = SonicDBConfig.get_ns_list() | ||
if len(ns_list) > 1: | ||
return(len(ns_list) - 1) | ||
else: | ||
return 1 | ||
|
||
|
||
def mock_is_multi_asic(): | ||
if mock_get_num_asics() > 1: | ||
return True | ||
else: | ||
return False | ||
|
||
def mock_get_all_namespaces(): | ||
if mock_get_num_asics() == 1: | ||
return {'front_ns': [], 'back_ns': []} | ||
else: | ||
return {'front_ns': ['asic0', 'asic1'], 'back_ns': ['asic2']} | ||
|
||
def mock_is_port_channel_internal(port_channel, namespace=None): | ||
if (mock_get_num_asics() == 1): | ||
return False | ||
else: | ||
return True if port_channel in int_port_channel else False | ||
|
||
def mock_get_port_table(namespace=None): | ||
if namespace is not None: | ||
fname = os.path.join(INPUT_DIR, namespace, 'config_db.json') | ||
else: | ||
fname = os.path.join(INPUT_DIR, 'config_db.json') | ||
port_table = {} | ||
db = {} | ||
with open(fname) as f: | ||
db = json.load(f) | ||
for k in db: | ||
if 'PORT_TABLE' in db: | ||
new_key = k[len('PORT_TABLE:'):] | ||
port_table[new_key] = db[k] | ||
return port_table | ||
|
||
multi_asic.get_num_asics = mock_get_num_asics | ||
multi_asic.is_multi_asic = mock_is_multi_asic | ||
multi_asic.get_all_namespaces = mock_get_all_namespaces | ||
multi_asic.is_port_channel_internal = mock_is_port_channel_internal | ||
multi_asic.get_port_table = mock_get_port_table |
Oops, something went wrong.