-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[macsec] cli multi-namespace support (#11285)
Enable multi-asic platform support for macsec cli
- Loading branch information
Showing
6 changed files
with
193 additions
and
83 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
81 changes: 81 additions & 0 deletions
81
dockers/docker-macsec/cli-plugin-tests/mock_single_asic.py
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,81 @@ | ||
# MONKEY PATCH!!! | ||
from unittest import mock | ||
|
||
from sonic_py_common import multi_asic | ||
from utilities_common import multi_asic as multi_asic_util | ||
|
||
mock_intf_table = { | ||
'': { | ||
'eth0': { | ||
2: [{'addr': '10.1.1.1', 'netmask': '255.255.255.0', 'broadcast': '10.1.1.1'}], | ||
10: [{'addr': '3100::1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}] | ||
}, | ||
'Ethernet0': { | ||
17: [{'addr': '82:fd:d1:5b:45:2f', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], | ||
2: [ | ||
{'addr': '20.1.1.1', 'netmask': '255.255.255.0', 'broadcast': '20.1.1.1'}, | ||
{'addr': '21.1.1.1', 'netmask': '255.255.255.0', 'broadcast': '21.1.1.1'} | ||
], | ||
10: [ | ||
{'addr': 'aa00::1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}, | ||
{'addr': '2100::1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}, | ||
{'addr': 'fe80::64be:a1ff:fe85:c6c4%Ethernet0', 'netmask': 'ffff:ffff:ffff:ffff::/64'} | ||
] | ||
}, | ||
'PortChannel0001': { | ||
17: [{'addr': '82:fd:d1:5b:45:2f', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], | ||
2: [{'addr': '30.1.1.1', 'netmask': '255.255.255.0', 'broadcast': '30.1.1.1'}], | ||
10: [ | ||
{'addr': 'ab00::1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}, | ||
{'addr': 'fe80::cc8d:60ff:fe08:139f%PortChannel0001', 'netmask': 'ffff:ffff:ffff:ffff::/64'} | ||
] | ||
}, | ||
'Vlan100': { | ||
17: [{'addr': '82:fd:d1:5b:45:2f', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], | ||
2: [{'addr': '40.1.1.1', 'netmask': '255.255.255.0', 'broadcast': '30.1.1.1'}], | ||
10: [ | ||
{'addr': 'cc00::1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}, | ||
{'addr': 'fe80::c029:3fff:fe41:cf56%Vlan100', 'netmask': 'ffff:ffff:ffff:ffff::/64'} | ||
] | ||
}, | ||
'lo': { | ||
2: [{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'broadcast': '127.255.255.255'}], | ||
10: [{'addr': '::1', 'netmask':'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128'}] | ||
} | ||
} | ||
} | ||
|
||
|
||
def mock_get_num_asics(): | ||
return 1 | ||
|
||
def mock_is_multi_asic(): | ||
return False | ||
|
||
def mock_get_namespace_list(namespace=None): | ||
return [''] | ||
|
||
|
||
def mock_single_asic_get_ip_intf_from_ns(namespace): | ||
interfaces = [] | ||
try: | ||
interfaces = list(mock_intf_table[namespace].keys()) | ||
except KeyError: | ||
pass | ||
return interfaces | ||
|
||
|
||
def mock_single_asic_get_ip_intf_addr_from_ns(namespace, iface): | ||
ipaddresses = [] | ||
try: | ||
ipaddresses = mock_intf_table[namespace][iface] | ||
except KeyError: | ||
pass | ||
return ipaddresses | ||
|
||
|
||
multi_asic.is_multi_asic = mock_is_multi_asic | ||
multi_asic.get_num_asics = mock_get_num_asics | ||
multi_asic.get_namespace_list = mock_get_namespace_list | ||
multi_asic_util.multi_asic_get_ip_intf_from_ns = mock_single_asic_get_ip_intf_from_ns | ||
multi_asic_util.multi_asic_get_ip_intf_addr_from_ns = mock_single_asic_get_ip_intf_addr_from_ns |
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
Oops, something went wrong.