sonic-buildimage/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py
Yaqiang Zhu 284ba61a86
[dhcp-relay] Add dhcp_relay show cli (#13614)
Why I did it
Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it
Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it
Unit test all passed
2023-03-06 10:48:25 -08:00

57 lines
1.3 KiB
Python

import click
import importlib
dhcp6_relay = importlib.import_module('show.plugins.dhcp-relay')
import utilities_common.cli as clicommon
def clear_dhcp_relay_ipv6_counter(interface):
counter = dhcp6_relay.DHCPv6_Counter()
counter_intf = counter.get_interface()
if interface:
counter.clear_table(interface)
else:
for intf in counter_intf:
counter.clear_table(intf)
# sonic-clear dhcp6relay_counters
@click.group(cls=clicommon.AliasedGroup)
def dhcp6relay_clear():
pass
@dhcp6relay_clear.command('dhcp6relay_counters')
@click.option('-i', '--interface', required=False)
def dhcp6relay_clear_counters(interface):
""" Clear dhcp6relay message counts """
clear_dhcp_relay_ipv6_counter(interface)
@click.group(cls=clicommon.AliasedGroup, name="dhcp_relay")
def dhcp_relay():
pass
@dhcp_relay.group(cls=clicommon.AliasedGroup, name="ipv6")
def dhcp_relay_ipv6():
pass
@dhcp_relay_ipv6.command('counters')
@click.option('-i', '--interface', required=False)
def clear_dhcp_relay_ipv6_counters(interface):
""" Clear dhcp_relay ipv6 message counts """
clear_dhcp_relay_ipv6_counter(interface)
def register(cli):
cli.add_command(dhcp6relay_clear_counters)
cli.add_command(dhcp_relay)
if __name__ == '__main__':
dhcp6relay_clear_counters()
dhcp_relay()