Skip to content

Commit 398da58

Browse files
Validation check correction while adding a member to PortChannel (sonic-net#2078)
Corrected the validation check while adding a member to a PortChannel This PR will fix the issue - sonic-net#9908 The CLI command should reject when trying to add member to a Portchannel when link-local is enabled in it. `` root@sonic:/home/admin# config ipv6 enable link-local root@sonic:/home/admin# root@sonic:/home/admin# config portchannel add PortChannel0001 root@sonic:/home/admin# root@sonic:/home/admin# config portchannel member add PortChannel0001 Ethernet64 Usage: config portchannel member add [OPTIONS] <portchannel_name> <port_name> Try "config portchannel member add -h" for help. Error: Ethernet64 has ip address configured root@sonic:/home/admin# `` Signed-off-by: Akhilesh Samineni [email protected]
1 parent 483fc6e commit 398da58

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

config/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1790,11 +1790,11 @@ def add_portchannel_member(ctx, portchannel_name, port_name):
17901790
ctx.fail("{} is not present.".format(portchannel_name))
17911791

17921792
# Dont allow a port to be member of port channel if it is configured with an IP address
1793-
for key in db.get_table('INTERFACE').keys():
1794-
if type(key) != tuple:
1793+
for key,value in db.get_table('INTERFACE').items():
1794+
if type(key) == tuple:
17951795
continue
1796-
if key[0] == port_name:
1797-
ctx.fail(" {} has ip address {} configured".format(port_name, key[1]))
1796+
if key == port_name:
1797+
ctx.fail(" {} has ip address configured".format(port_name))
17981798
return
17991799

18001800
# Dont allow a port to be member of port channel if it is configured as a VLAN member

tests/portchannel_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_add_portchannel_member_which_has_ipaddress(self):
119119
print(result.exit_code)
120120
print(result.output)
121121
assert result.exit_code != 0
122-
assert "Error: Ethernet0 has ip address 14.14.0.1/24 configured" in result.output
122+
assert "Error: Ethernet0 has ip address configured" in result.output
123123

124124
def test_add_portchannel_member_which_is_member_of_vlan(self):
125125
runner = CliRunner()

0 commit comments

Comments
 (0)