Skip to content

Commit ff226d0

Browse files
authored
Prevent configuring IP interface on a port which is a member of VLAN (#1374)
**- What I did** Fixed bug #6426 Added a validation in config/main.py to prevent configuring IP interface on a port which is a member of VLAN **- How I did it** Change config/main.py **- How to verify it** Add interface as member in vlan Try to configure IP address on same interface **- Previous command output (if the output of a command-line utility has changed)** Success in the above scenario. **- New command output (if the output of a command-line utility has changed)** prevent configuration: "Interface Ethernet0 is a member of vlan Aborting!"
1 parent f1522b9 commit ff226d0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

config/main.py

+7
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,13 @@ def add(ctx, interface_name, ip_addr, gw):
26452645
if interface_name is None:
26462646
ctx.fail("'interface_name' is None!")
26472647

2648+
# Add a validation to check this interface is not a member in vlan before
2649+
# changing it to a router port
2650+
vlan_member_table = config_db.get_table('VLAN_MEMBER')
2651+
if (interface_is_in_vlan(vlan_member_table, interface_name)):
2652+
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
2653+
return
2654+
26482655
try:
26492656
net = ipaddress.ip_network(ip_addr, strict=False)
26502657
if '/' not in ip_addr:

0 commit comments

Comments
 (0)