Ejemplo n.º 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 {0}'.format(value))

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