Skip to content

Commit 985492b

Browse files
committed
Don't create the members@ array in config_db for PC when reading from minigraph (sonic-net#13660)
Fixes sonic-net#11873. When loading from minigraph, for port channels, don't create the members@ array in config_db in the PORTCHANNEL table. This is no longer needed or used. In addition, when adding a port channel member from the CLI, that member doesn't get added into the members@ array, resulting in a bit of inconsistency. This gets rid of that inconsistency.
1 parent b2e124c commit 985492b

File tree

9 files changed

+20
-86
lines changed

9 files changed

+20
-86
lines changed

src/sonic-config-engine/minigraph.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,9 @@ def parse_dpg(dpg, hname):
511511
intfs_inpc.append(pcmbr_list[i])
512512
pc_members[(pcintfname, pcmbr_list[i])] = {}
513513
if pcintf.find(str(QName(ns, "Fallback"))) != None:
514-
pcs[pcintfname] = {'members': pcmbr_list, 'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75))), 'lacp_key': 'auto'}
514+
pcs[pcintfname] = {'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75))), 'lacp_key': 'auto'}
515515
else:
516-
pcs[pcintfname] = {'members': pcmbr_list, 'min_links': str(int(math.ceil(len(pcmbr_list) * 0.75))), 'lacp_key': 'auto' }
516+
pcs[pcintfname] = {'min_links': str(int(math.ceil(len(pcmbr_list) * 0.75))), 'lacp_key': 'auto' }
517517
port_nhipv4_map = {}
518518
port_nhipv6_map = {}
519519
nhg_int = ""
@@ -1223,7 +1223,7 @@ def filter_acl_table_for_backend(acls, vlan_members):
12231223
}
12241224
return filter_acls
12251225

1226-
def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role, device_type, is_storage_device, vlan_members):
1226+
def filter_acl_table_bindings(acls, neighbors, port_channels, pc_members, sub_role, device_type, is_storage_device, vlan_members):
12271227
if device_type == 'BackEndToRRouter' and is_storage_device:
12281228
return filter_acl_table_for_backend(acls, vlan_members)
12291229

@@ -1242,8 +1242,8 @@ def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role, device_t
12421242

12431243
# Get the front panel port channel.
12441244
for port_channel_intf in port_channels:
1245-
backend_port_channel = any(lag_member in backplane_port_list \
1246-
for lag_member in port_channels[port_channel_intf]['members'])
1245+
backend_port_channel = any(lag_member[1] in backplane_port_list \
1246+
for lag_member in list(pc_members.keys()) if lag_member[0] == port_channel_intf)
12471247
if not backend_port_channel:
12481248
front_port_channel_intf.append(port_channel_intf)
12491249

@@ -1754,12 +1754,15 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
17541754

17551755
if port_config_file:
17561756
port_set = set(ports.keys())
1757-
for (pc_name, mbr_map) in list(pcs.items()):
1757+
for (pc_name, pc_member) in list(pc_members.keys()):
17581758
# remove portchannels that contain ports not existing in port_config.ini
17591759
# when port_config.ini exists
1760-
if not set(mbr_map['members']).issubset(port_set):
1761-
print("Warning: ignore '%s' as part of its member interfaces is not in the port_config.ini" % pc_name, file=sys.stderr)
1760+
if (pc_name, pc_member) in pc_members and pc_member not in port_set:
1761+
print("Warning: ignore '%s' as at least one of its member interfaces ('%s') is not in the port_config.ini" % (pc_name, pc_member), file=sys.stderr)
17621762
del pcs[pc_name]
1763+
pc_mbr_del_keys = [f for f in list(pc_members.keys()) if f[0] == pc_name]
1764+
for pc_mbr_del_key in pc_mbr_del_keys:
1765+
del pc_members[pc_mbr_del_key]
17631766

17641767
# set default port channel MTU as 9100 and admin status up and default TPID 0x8100
17651768
for pc in pcs.values():
@@ -1863,7 +1866,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
18631866
results['DHCP_RELAY'] = dhcp_relay_table
18641867
results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers)
18651868
results['TACPLUS_SERVER'] = dict((item, {'priority': '1', 'tcp_port': '49'}) for item in tacacs_servers)
1866-
results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, sub_role, current_device['type'], is_storage_device, vlan_members)
1869+
results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, pc_members, sub_role, current_device['type'], is_storage_device, vlan_members)
18671870
results['FEATURE'] = {
18681871
'telemetry': {
18691872
'state': 'enabled'

src/sonic-config-engine/tests/test_cfggen.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ def test_minigraph_portchannels(self, **kwargs):
332332
output = self.run_script(argument)
333333
self.assertEqual(
334334
utils.to_dict(output.strip()),
335-
utils.to_dict("{'PortChannel1': {'admin_status': 'up', 'min_links': '1', 'members': ['Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")
335+
utils.to_dict("{'PortChannel1': {'admin_status': 'up', 'min_links': '1', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")
336336
)
337337

338338
def test_minigraph_portchannel_with_more_member(self):
339339
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v PORTCHANNEL'
340340
output = self.run_script(argument)
341341
self.assertEqual(
342342
utils.to_dict(output.strip()),
343-
utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '3', 'members': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}"))
343+
utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '3', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}"))
344344

345345
def test_minigraph_portchannel_members(self):
346346
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v "PORTCHANNEL_MEMBER.keys()|list"'

src/sonic-config-engine/tests/test_minigraph_case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_minigraph_portchannels(self):
159159
output = self.run_script(argument)
160160
self.assertEqual(
161161
utils.to_dict(output.strip()),
162-
utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '1', 'members': ['Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")
162+
utils.to_dict("{'PortChannel01': {'admin_status': 'up', 'min_links': '1', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}}")
163163
)
164164

165165
def test_minigraph_console_mgmt_feature(self):

src/sonic-config-engine/tests/test_multinpu_cfggen.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ def test_frontend_asic_portchannels(self):
159159
argument = "-m {} -p {} -n asic0 --var-json \"PORTCHANNEL\"".format(self.sample_graph, self.port_config[0])
160160
output = json.loads(self.run_script(argument))
161161
self.assertDictEqual(output, \
162-
{'PortChannel0002': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet0', 'Ethernet4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
163-
'PortChannel4001': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP0', 'Ethernet-BP4'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
164-
'PortChannel4002': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP8', 'Ethernet-BP12'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}})
162+
{'PortChannel0002': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
163+
'PortChannel4001': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
164+
'PortChannel4002': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}})
165165

166166
def test_backend_asic_portchannels(self):
167167
argument = "-m {} -p {} -n asic3 --var-json \"PORTCHANNEL\"".format(self.sample_graph, self.port_config[3])
168168
output = json.loads(self.run_script(argument))
169169
self.assertDictEqual(output, \
170-
{'PortChannel4013': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP384', 'Ethernet-BP388'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
171-
'PortChannel4014': {'admin_status': 'up', 'min_links': '2', 'members': ['Ethernet-BP392', 'Ethernet-BP396'], 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}})
170+
{'PortChannel4013': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'},
171+
'PortChannel4014': {'admin_status': 'up', 'min_links': '2', 'mtu': '9100', 'tpid': '0x8100', 'lacp_key': 'auto'}})
172172

173173
def test_frontend_asic_portchannel_mem(self):
174174
argument = "-m {} -p {} -n asic0 -v \"PORTCHANNEL_MEMBER.keys()|list\"".format(self.sample_graph, self.port_config[0])

src/sonic-yang-models/tests/files/sample_config_db.json

-13
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,26 @@
7777
"PortChannel0003": {
7878
"admin_status": "up",
7979
"min_links": "1",
80-
"members": [
81-
"Ethernet1"
82-
],
8380
"tpid": "0x8100",
8481
"mtu": "9100",
8582
"lacp_key": "auto"
8683
},
8784
"PortChannel0004": {
8885
"admin_status": "up",
8986
"min_links": "1",
90-
"members": [
91-
"Ethernet2"
92-
],
9387
"tpid": "0x9200",
9488
"mtu": "9100",
9589
"lacp_key": "auto"
9690
},
9791
"PortChannel2": {
9892
"admin_status": "up",
9993
"min_links": "1",
100-
"members": [
101-
"Ethernet12"
102-
],
10394
"tpid": "0x9200",
10495
"mtu": "9100",
10596
"lacp_key": "auto"
10697
},
10798
"PortChannel42": {
10899
"admin_status": "up",
109-
"members": [
110-
"Ethernet-BP0",
111-
"Ethernet-BP4"
112-
],
113100
"min_links": "2",
114101
"mtu": "9100",
115102
"tpid": "0x8100"

src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json

-9
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@
2929
"PORTCHANNEL_LIST": [
3030
{
3131
"admin_status": "up",
32-
"members": [
33-
"Ethernet0"
34-
],
3532
"min_links": "1",
3633
"mtu": "9100",
3734
"lacp_key": "auto",
3835
"name": "PortChannel2"
3936
},
4037
{
4138
"admin_status": "up",
42-
"members": [
43-
"Ethernet10"
44-
],
4539
"min_links": "1",
4640
"mtu": "9100",
4741
"lacp_key": "auto",
@@ -151,9 +145,6 @@
151145
"PORTCHANNEL_LIST": [
152146
{
153147
"admin_status": "up",
154-
"members": [
155-
"Ethernet0"
156-
],
157148
"min_links": "1",
158149
"mtu": "9100",
159150
"lacp_key": "auto",

src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json

-18
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
"PORTCHANNEL_LIST": [
2222
{
2323
"admin_status": "up",
24-
"members": [
25-
"Ethernet0"
26-
],
2724
"min_links": "1",
2825
"mtu": "9100",
2926
"tpid": "0x8100",
@@ -55,9 +52,6 @@
5552
"PORTCHANNEL_LIST": [
5653
{
5754
"admin_status": "up",
58-
"members": [
59-
"Ethernet0"
60-
],
6155
"min_links": "1024",
6256
"mtu": "9100",
6357
"name": "PortChannel0001"
@@ -87,9 +81,6 @@
8781
"PORTCHANNEL_LIST": [
8882
{
8983
"admin_status": "up",
90-
"members": [
91-
"Ethernet0"
92-
],
9384
"min_links": "1025",
9485
"mtu": "9100",
9586
"name": "PortChannel0001"
@@ -303,9 +294,6 @@
303294
"PORTCHANNEL_LIST": [
304295
{
305296
"admin_status": "up",
306-
"members": [
307-
"Ethernet0"
308-
],
309297
"min_links": "1",
310298
"mtu": "9100",
311299
"name": "PortChannel0001"
@@ -350,9 +338,6 @@
350338
"PORTCHANNEL_LIST": [
351339
{
352340
"admin_status": "up",
353-
"members": [
354-
"Ethernet0"
355-
],
356341
"min_links": "1",
357342
"mtu": "9100",
358343
"name": "PortChannel0001"
@@ -396,9 +381,6 @@
396381
"PORTCHANNEL_LIST": [
397382
{
398383
"admin_status": "up",
399-
"members": [
400-
"Ethernet0"
401-
],
402384
"min_links": "1",
403385
"mtu": "9100",
404386
"name": "PortChannel0001"

src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json

-12
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@
196196
"PORTCHANNEL_LIST": [
197197
{
198198
"admin_status": "up",
199-
"members": [
200-
"Ethernet0"
201-
],
202199
"min_links": "1",
203200
"mtu": "9100",
204201
"tpid": "0x8100",
@@ -246,9 +243,6 @@
246243
"PORTCHANNEL_LIST": [
247244
{
248245
"admin_status": "up",
249-
"members": [
250-
"Ethernet0"
251-
],
252246
"min_links": "1",
253247
"mtu": "9100",
254248
"tpid": "0x8100",
@@ -296,9 +290,6 @@
296290
"PORTCHANNEL_LIST": [
297291
{
298292
"admin_status": "up",
299-
"members": [
300-
"Ethernet0"
301-
],
302293
"min_links": "1",
303294
"mtu": "9100",
304295
"tpid": "0x8100",
@@ -346,9 +337,6 @@
346337
"PORTCHANNEL_LIST": [
347338
{
348339
"admin_status": "up",
349-
"members": [
350-
"Ethernet0"
351-
],
352340
"min_links": "1",
353341
"mtu": "9100",
354342
"tpid": "0x8100",

src/sonic-yang-models/yang-models/sonic-portchannel.yang

-17
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,6 @@ module sonic-portchannel {
5858
}
5959
}
6060

61-
leaf-list members {
62-
/* leaf-list members are unique by default */
63-
type union {
64-
type leafref {
65-
path /port:sonic-port/port:PORT/port:PORT_LIST/port:name;
66-
}
67-
type string {
68-
pattern "";
69-
}
70-
}
71-
/* Today in SONiC, we do not delete the list once
72-
* created, instead we set to empty list. Due to that
73-
* below default values are needed.
74-
*/
75-
default "";
76-
}
77-
7861
leaf min_links {
7962
type uint16 {
8063
range 1..1024;

0 commit comments

Comments
 (0)