sonic-buildimage/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py
shlomibitton edd6f4086c [dhcp_relay] Adapt config/show CLI commands to support DHCPv6 relay (#8211)
#### Why I did it
- Adapt config/show CLI commands to support DHCPv6 relay
- Support multiple dhcp servers assignment in one command
- Fix IP validation
- Adapt UT and add new UT cases

#### How I did it
- Modify config/show dhcp relay files
- Modify config/show UT files

#### How to verify it
This PR has a dependency on PR https://github.com/Azure/sonic-utilities/pull/1717
Build an image with the dependent PR and this PR
Use config/show DHCPv6 relay commands.
2021-08-25 12:45:03 -07:00

22 lines
544 B
Python

from natsort import natsorted
import show.vlan as vlan
def get_dhcp_helper_address(ctx, vlan):
cfg, _ = ctx
vlan_dhcp_helper_data, _, _ = cfg
vlan_config = vlan_dhcp_helper_data.get(vlan)
if not vlan_config:
return ""
dhcp_helpers = vlan_config.get('dhcp_servers', [])
dhcpv6_helpers = vlan_config.get('dhcpv6_servers', [])
return '\n'.join(natsorted(dhcp_helpers) + natsorted(dhcpv6_helpers))
vlan.VlanBrief.register_column('DHCP Helper Address', get_dhcp_helper_address)
def register(cli):
pass