Example #1
0
def validate_ipv4(value, module):
    if value:
        address = value.split('/')
        if len(address) != 2:
            module.fail_json(msg='address format is <ipv4 address>/<mask>, got invalid format %s' % value)

        if not is_masklen(address[1]):
            module.fail_json(msg='invalid value for mask: %s, mask should be in range 0-32' % address[1])
Example #2
0
def is_ipv4(value):
    if value:
        address = value.split('/')
        if is_masklen(address[1]) and validate_ip_address(address[0]):
            return True
    return False