diff --git a/config/vlan.py b/config/vlan.py index a10db74d0904..36ef3da0ac96 100644 --- a/config/vlan.py +++ b/config/vlan.py @@ -145,6 +145,11 @@ def add_vlan_member(db, vid, port, untagged): (not is_port and clicommon.is_pc_router_interface(db.cfgdb, port)): ctx.fail("{} is a router interface!".format(port)) + portchannel_member_table = db.cfgdb.get_table('PORTCHANNEL_MEMBER') + + if (is_port and clicommon.interface_is_in_portchannel(portchannel_member_table, port)): + ctx.fail("{} is part of portchannel!".format(port)) + if (clicommon.interface_is_untagged_member(db.cfgdb, port) and untagged): ctx.fail("{} is already untagged member!".format(port)) diff --git a/tests/vlan_test.py b/tests/vlan_test.py index 438f3acbbbae..f0559560daa6 100644 --- a/tests/vlan_test.py +++ b/tests/vlan_test.py @@ -674,6 +674,16 @@ def test_config_set_router_port_on_member_interface(self): assert result.exit_code == 0 assert 'Interface Ethernet4 is a member of vlan' in result.output + def test_config_vlan_add_member_of_portchannel(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], \ + ["1000", "Ethernet32", "--untagged"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: Ethernet32 is part of portchannel!" in result.output @classmethod def teardown_class(cls):