Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202012][dhcp-relay] Add support for dhcp_relay config cli #2640

Merged
merged 6 commits into from
Feb 14, 2023

Conversation

yaqiangz
Copy link
Contributor

@yaqiangz yaqiangz commented Jan 31, 2023

Why I did it

Currently the config cli of dhcpv4 is may cause confusion and config of dhcpv6 is missing.

How I did it

Add dhcp_relay config cli and test cases.

config dhcp_relay ipv4 helper (add | del) <vlan_id> <helper_ip_list>
config dhcp_relay ipv6 destination (add | del) <vlan_id> <destination_ip_list>

How to verify it

  1. Verify by unitest, all passed
2023-01-31T17:13:39.5310534Z ----------- coverage: platform linux, python 3.7.3-final-0 -----------
2023-01-31T17:13:39.5311171Z Name                                          Stmts   Miss  Cover
2023-01-31T17:13:39.5311934Z -----------------------------------------------------------------
2023-01-31T17:13:39.5318510Z config/dhcp_relay.py                            101     11    89%
2023-01-31T17:13:39.5375220Z utilities_common/dhcp_relay_util.py               7      0   100%
2023-01-31T17:13:39.5378676Z -----------------------------------------------------------------
2023-01-31T17:13:39.5379423Z Coverage HTML written to dir htmlcov
2023-01-31T17:13:39.5379772Z Coverage XML written to file coverage.xml
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml
  1. Build sonic-utilities and install in DUT and run cli, test cli
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv6 destination add 1000 fc02:2000::6    
Added DHCP relay address [fc02:2000::6] to Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv6 destination add 1000 fc02:2000::7 fc02:2000::8
Added DHCP relay address [fc02:2000::7,fc02:2000::8] to Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ show dhcprelay_helper ipv6                                                
--------  ------------
Vlan1000  fc02:2000::1
          fc02:2000::2
          fc02:2000::3
          fc02:2000::4
          fc02:2000::6
          fc02:2000::7
          fc02:2000::8
--------  ------------
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv6 destination del 1000 fc02:2000::6   
Removed DHCP relay address [fc02:2000::6] from Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv6 destination del 1000 fc02:2000::7 fc02:2000::8   
Removed DHCP relay address [fc02:2000::7,fc02:2000::8] from Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ show dhcprelay_helper ipv6                                                
--------  ------------
Vlan1000  fc02:2000::1
          fc02:2000::2
          fc02:2000::3
          fc02:2000::4
--------  ------------
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv4 helper add 1000 192.0.0.49
Added DHCP relay address [192.0.0.49] to Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv4 helper add 1000 192.0.0.50 192.0.0.51
Added DHCP relay address [192.0.0.50,192.0.0.51] to Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv4 helper del 1000 192.0.0.49   
Removed DHCP relay address [192.0.0.49] from Vlan1000
Restarting DHCP relay service...
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv4 helper del 1000 192.0.0.49
Usage: config dhcp_relay ipv4 helper del [OPTIONS] <vid> DHCP_RELAY_HELPERS...
Try "config dhcp_relay ipv4 helper del -h" for help. Error: 192.0.0.49 is not a DHCP relay for Vlan1000
admin@str-e1031-acs-3:~$ sudo config dhcp_relay ipv4 helper del 1000 192.0.0.50 192.0.0.51   
Removed DHCP relay address [192.0.0.50,192.0.0.51] from Vlan1000
Restarting DHCP relay service...

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@yaqiangz yaqiangz changed the title [Please ignore] test [dhcp-relay] Add support for dhcp_relay config cli Feb 2, 2023
@yaqiangz
Copy link
Contributor Author

yaqiangz commented Feb 2, 2023

@kellyyeh @jcaiMR @Blueve Could you please help to review this PR?

@yaqiangz yaqiangz changed the title [dhcp-relay] Add support for dhcp_relay config cli [202012][dhcp-relay] Add support for dhcp_relay config cli Feb 3, 2023
config/dhcp_relay.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants