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

Update cli.py to support checking ipv4 address validation #2905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
import lazy_object_proxy
import netaddr
import ipaddress

from natsort import natsorted
from sonic_py_common import multi_asic
Expand Down Expand Up @@ -217,6 +218,11 @@ def ipaddress_type(val):

return ip_version.version

def is_ipv4addr_network_addr(ipaddr):
if ipaddress.IPv4Network(ipaddr, False).network_address == ipaddress.ip_address(ipaddr.split('/')[0]):
return True
return False

def is_ip_prefix_in_key(key):
'''
Function to check if IP address is present in the key. If it
Expand Down
Loading