Skip to content

Commit bf46638

Browse files
authored
Handling error scenario of adding port to Vlan which is part of LAG (sonic-net#1516)
*Handled error scenario when adding a port to Vlan which is already part of a LAG. Added unit test to cover the scenario. This is fix for the bug sonic-net#4456 Signed-off-by: Sudharsan Dhamal Gopalarathnam <[email protected]>
1 parent ae39883 commit bf46638

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

config/vlan.py

+5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ def add_vlan_member(db, vid, port, untagged):
145145
(not is_port and clicommon.is_pc_router_interface(db.cfgdb, port)):
146146
ctx.fail("{} is a router interface!".format(port))
147147

148+
portchannel_member_table = db.cfgdb.get_table('PORTCHANNEL_MEMBER')
149+
150+
if (is_port and clicommon.interface_is_in_portchannel(portchannel_member_table, port)):
151+
ctx.fail("{} is part of portchannel!".format(port))
152+
148153
if (clicommon.interface_is_untagged_member(db.cfgdb, port) and untagged):
149154
ctx.fail("{} is already untagged member!".format(port))
150155

tests/vlan_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,16 @@ def test_config_set_router_port_on_member_interface(self):
674674
assert result.exit_code == 0
675675
assert 'Interface Ethernet4 is a member of vlan' in result.output
676676

677+
def test_config_vlan_add_member_of_portchannel(self):
678+
runner = CliRunner()
679+
db = Db()
680+
681+
result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], \
682+
["1000", "Ethernet32", "--untagged"], obj=db)
683+
print(result.exit_code)
684+
print(result.output)
685+
assert result.exit_code != 0
686+
assert "Error: Ethernet32 is part of portchannel!" in result.output
677687

678688
@classmethod
679689
def teardown_class(cls):

0 commit comments

Comments
 (0)