diff --git a/config/main.py b/config/main.py index 996549ca3c..f5e3cf5a55 100644 --- a/config/main.py +++ b/config/main.py @@ -1790,11 +1790,11 @@ def add_portchannel_member(ctx, portchannel_name, port_name): ctx.fail("{} is not present.".format(portchannel_name)) # Dont allow a port to be member of port channel if it is configured with an IP address - for key in db.get_table('INTERFACE').keys(): - if type(key) != tuple: + for key,value in db.get_table('INTERFACE').items(): + if type(key) == tuple: continue - if key[0] == port_name: - ctx.fail(" {} has ip address {} configured".format(port_name, key[1])) + if key == port_name: + ctx.fail(" {} has ip address configured".format(port_name)) return # Dont allow a port to be member of port channel if it is configured as a VLAN member diff --git a/tests/portchannel_test.py b/tests/portchannel_test.py index 1ccf19495f..ebf77e86b5 100644 --- a/tests/portchannel_test.py +++ b/tests/portchannel_test.py @@ -119,7 +119,7 @@ def test_add_portchannel_member_which_has_ipaddress(self): print(result.exit_code) print(result.output) assert result.exit_code != 0 - assert "Error: Ethernet0 has ip address 14.14.0.1/24 configured" in result.output + assert "Error: Ethernet0 has ip address configured" in result.output def test_add_portchannel_member_which_is_member_of_vlan(self): runner = CliRunner()