def is_ipv4(ip_str):
    """
    Validate whether given string is IPv4.

    :param ip_str: String to validate.
    :type ip_str: ``str``

    :rtype: ``bool``
    """
    try:
        addr = ipaddress.ip_address(ip_str)
        return addr.version == 4
    except:
        return False

    Validate whether given string is IPv4.

    :param ip_str: String to validate.
    :type ip_str: ``str``

    :rtype: ``bool``
    
st2common/st2common/util/ip_utils.py