import fnmatch


def iface_matches(network_iface, pattern):
    """Return if a network interface's name or associated addresses match
    the glob in `pattern`.

    Params:
    - network_iface: NetworkInterface object
    - pattern:       string containing a glob to match names or IP addresses
                     against
    Returns: True if the name or at least one of the IP addresses in
    `network_iface` matches `pattern`, False otherwise

    """
    if fnmatch.fnmatch(network_iface.name, pattern):
        return True
    for family, addrs in network_iface.addresses.items():
        if fnmatch.filter(addrs, pattern):
            return True
    return False