Skip to content

Commit 27502f0

Browse files
authored
[dhcp_relay] Update CLI reference document and add a new API for ip address type (sonic-net#1717)
#### What I did Update CLI reference document following PR : sonic-net#8211 Add a new API on utilities_common to get IP type. #### How I did it - Update doc/Command-Reference.md with new DHCP CLI. - Add ipaddress_type API to utilities_common/cli.py #### How to verify it - Build an image with PR sonic-net#8211 and this PR. - Run DHCP CLI commands
1 parent cd3ee78 commit 27502f0

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

doc/Command-Reference.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -2231,27 +2231,32 @@ This sub-section of commands is used to add or remove the DHCP Relay Destination
22312231
22322232
**config vlan dhcp_relay add**
22332233
2234-
This command is used to add a DHCP Relay Destination IP address to the a VLAN. Note that more that one DHCP Relay Destination IP address can be added on a VLAN interface.
2234+
This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface.
22352235
22362236
- Usage:
22372237
```
2238-
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ip>
2238+
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ips>
22392239
```
22402240
22412241
- Example:
22422242
```
22432243
admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7
2244-
Added DHCP relay destination address 7.7.7.7 to Vlan1000
2244+
Added DHCP relay destination address ['7.7.7.7'] to Vlan1000
2245+
Restarting DHCP relay service...
2246+
```
2247+
```
2248+
admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1
2249+
Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000
22452250
Restarting DHCP relay service...
22462251
```
22472252
22482253
**config vlan dhcp_relay delete**
22492254
2250-
This command is used to delete a configured DHCP Relay Destination IP address from a VLAN interface.
2255+
This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface.
22512256
22522257
- Usage:
22532258
```
2254-
config vlan dhcp_relay del <vlan-id> <dhcp_relay_destination_ip>
2259+
config vlan dhcp_relay del <vlan-id> <dhcp_relay_destination_ips>
22552260
```
22562261
22572262
- Example:
@@ -2260,6 +2265,11 @@ This command is used to delete a configured DHCP Relay Destination IP address fr
22602265
Removed DHCP relay destination address 7.7.7.7 from Vlan1000
22612266
Restarting DHCP relay service...
22622267
```
2268+
```
2269+
admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1
2270+
Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000
2271+
Restarting DHCP relay service...
2272+
```
22632273
22642274
Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay)
22652275

utilities_common/cli.py

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import click
99
import json
10+
import netaddr
1011

1112
from natsort import natsorted
1213
from sonic_py_common import multi_asic
@@ -203,6 +204,17 @@ def is_ipaddress(val):
203204
return False
204205
return True
205206

207+
def ipaddress_type(val):
208+
""" Return the IP address type """
209+
if not val:
210+
return None
211+
212+
try:
213+
ip_version = netaddr.IPAddress(str(val))
214+
except netaddr.core.AddrFormatError:
215+
return None
216+
217+
return ip_version.version
206218

207219
def is_ip_prefix_in_key(key):
208220
'''

0 commit comments

Comments
 (0)