Skip to content

Commit

Permalink
Fix for dhcp_relay deletion on a VLAN (sonic-net#813)
Browse files Browse the repository at this point in the history
Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
  • Loading branch information
AkhileshSamineni committed Feb 21, 2020
1 parent fa21372 commit ea374a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,8 @@ def add_vlan_dhcp_relay_destination(ctx, vid, dhcp_relay_destination_ip):
return
else:
dhcp_relay_dests.append(dhcp_relay_destination_ip)
db.set_entry('VLAN', vlan_name, {"dhcp_servers":dhcp_relay_dests})
vlan['dhcp_servers'] = dhcp_relay_dests
db.set_entry('VLAN', vlan_name, vlan)
click.echo("Added DHCP relay destination address {} to {}".format(dhcp_relay_destination_ip, vlan_name))
try:
click.echo("Restarting DHCP relay service...")
Expand All @@ -1218,7 +1219,11 @@ def del_vlan_dhcp_relay_destination(ctx, vid, dhcp_relay_destination_ip):
dhcp_relay_dests = vlan.get('dhcp_servers', [])
if dhcp_relay_destination_ip in dhcp_relay_dests:
dhcp_relay_dests.remove(dhcp_relay_destination_ip)
db.set_entry('VLAN', vlan_name, {"dhcp_servers":dhcp_relay_dests})
if len(dhcp_relay_dests) == 0:
del vlan['dhcp_servers']
else:
vlan['dhcp_servers'] = dhcp_relay_dests
db.set_entry('VLAN', vlan_name, vlan)
click.echo("Removed DHCP relay destination address {} from {}".format(dhcp_relay_destination_ip, vlan_name))
try:
click.echo("Restarting DHCP relay service...")
Expand Down

0 comments on commit ea374a7

Please sign in to comment.