|
1 | 1 | import click
|
2 | 2 | import utilities_common.cli as clicommon
|
3 | 3 | import utilities_common.dhcp_relay_util as dhcp_relay_util
|
| 4 | +from swsscommon.swsscommon import SonicV2Connector |
4 | 5 |
|
5 | 6 | from jsonpatch import JsonPatchConflict
|
6 | 7 | from time import sleep
|
@@ -65,6 +66,14 @@ def is_dhcpv6_relay_config_exist(db, vlan_name):
|
65 | 66 | return True
|
66 | 67 |
|
67 | 68 |
|
| 69 | +def delete_state_db_entry(entry_name): |
| 70 | + state_db = SonicV2Connector() |
| 71 | + state_db.connect(state_db.STATE_DB) |
| 72 | + exists = state_db.exists(state_db.STATE_DB, 'DHCPv6_COUNTER_TABLE|{}'.format(entry_name)) |
| 73 | + if exists: |
| 74 | + state_db.delete(state_db.STATE_DB, 'DHCPv6_COUNTER_TABLE|{}'.format(entry_name)) |
| 75 | + |
| 76 | + |
68 | 77 | @vlan.command('del')
|
69 | 78 | @click.argument('vid', metavar='<vid>', required=True, type=int)
|
70 | 79 | @click.option('--no_restart_dhcp_relay', is_flag=True, type=click.BOOL, required=False, default=False,
|
@@ -109,6 +118,8 @@ def del_vlan(db, vid, no_restart_dhcp_relay):
|
109 | 118 | # set dhcpv4_relay table
|
110 | 119 | set_dhcp_relay_table('VLAN', config_db, vlan, None)
|
111 | 120 |
|
| 121 | + delete_state_db_entry(vlan) |
| 122 | + |
112 | 123 | if not no_restart_dhcp_relay and is_dhcpv6_relay_config_exist(db, vlan):
|
113 | 124 | # set dhcpv6_relay table
|
114 | 125 | set_dhcp_relay_table('DHCP_RELAY', config_db, vlan, None)
|
|
0 commit comments