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

[dhcp_relay] Update CLI reference document and add a new API for ip address type #1717

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2225,27 +2225,32 @@ This sub-section of commands is used to add or remove the DHCP Relay Destination

**config vlan dhcp_relay add**

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.
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.

- Usage:
```
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ip>
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ips>
```

- Example:
```
admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7
Added DHCP relay destination address 7.7.7.7 to Vlan1000
Added DHCP relay destination address ['7.7.7.7'] to Vlan1000
Restarting DHCP relay service...
```
```
admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1
Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000
Restarting DHCP relay service...
```

**config vlan dhcp_relay delete**

This command is used to delete a configured DHCP Relay Destination IP address from a VLAN interface.
This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface.

- Usage:
```
config vlan dhcp_relay del <vlan-id> <dhcp_relay_destination_ip>
config vlan dhcp_relay del <vlan-id> <dhcp_relay_destination_ips>
```

- Example:
Expand All @@ -2254,6 +2259,11 @@ This command is used to delete a configured DHCP Relay Destination IP address fr
Removed DHCP relay destination address 7.7.7.7 from Vlan1000
Restarting DHCP relay service...
```
```
admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1
Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000
Restarting DHCP relay service...
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay)

Expand Down
12 changes: 12 additions & 0 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import click
import json
import netaddr

from natsort import natsorted
from sonic_py_common import multi_asic
Expand Down Expand Up @@ -200,6 +201,17 @@ def is_ipaddress(val):
return False
return True

def ipaddress_type(val):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ipaddress_type used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, on the other PR for the CLI:
sonic-net/sonic-buildimage#8211
This is why this PR is a dependency for the other.

""" Return the IP address type """
if not val:
return None

try:
ip_version = netaddr.IPAddress(str(val))
except netaddr.core.AddrFormatError:
return None

return ip_version.version

def is_ip_prefix_in_key(key):
'''
Expand Down