mirror of
				https://github.com/Telecominfraproject/ols-nos.git
				synced 2025-11-04 03:57:57 +00:00 
			
		
		
		
	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
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			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()
 |