Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4374,6 +4374,12 @@ def add(ctx, interface_name, ip_addr, gw):
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
return

portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER')

if interface_is_in_portchannel(portchannel_member_table, interface_name):
ctx.fail("{} is configured as a member of portchannel."
.format(interface_name))

try:
ip_address = ipaddress.ip_interface(ip_addr)
except ValueError as err:
Expand Down
12 changes: 12 additions & 0 deletions tests/ip_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ def test_add_interface_ipv4_with_leading_zeros(self):
assert result.exit_code != 0
assert ERROR_MSG in result.output

def test_ip_add_on_interface_which_is_member_of_portchannel(self):
runner = CliRunner()
db = Db()
obj = {'config_db':db.cfgdb}

# config int ip add Ethernet32 100.10.10.1/24
result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Ethernet32", "100.10.10.1/24"], obj=obj)
assert result.exit_code != 0
print(result.output)
print(result.exit_code)
assert 'Error: Ethernet32 is configured as a member of portchannel.' in result.output

''' Tests for IPv6 '''

def test_add_del_interface_valid_ipv6(self):
Expand Down