narupa.essd.utils module

narupa.essd.utils.get_broadcast_addresses(interfaces: Optional[Iterable[str]] = None) → List[Dict[str, str]]

Gets all the IPV4 addresses currently available on all the given interfaces that have broadcast addresses.

Parameters:interfaces – Optional list of interfaces to extract addresses from. If none are provided, all interfaces will be used.
Returns:A list of dictionaries containing the IP address and other information for each interface,

as returned by :fun:`netifaces.ifaddresses`.

In the netifaces API, the address entries are returned as dictionaries in the following format:

narupa.essd.utils.get_broadcastable_ip()
narupa.essd.utils.get_ipv4_addresses(interfaces: Optional[Iterable[str]] = None) → List[Dict[str, str]]

Gets all the IPV4 addresses currently available on all the given interfaces.

Parameters:interfaces – Optional list of interfaces to extract addresses from. If none are provided, all interfaces will be used.
Returns:A list of dictionaries containing the IP address and other information for each interface, as returned by :fun:`netifaces.ifaddresses`.
narupa.essd.utils.is_in_network(address: str, interface_address_entry: Dict[str, str]) → bool

An internal mechanism for determining whether a given IP address is part of the same network as a given interface network as defined by their IPv4 subnet mask and broadcast address.

Parameters:
  • address – An IPv4 address.
  • interface_address_entry – An IPv4 address entry, as produced by :fun:`netifaces.ifaddresses`. It must contain the netmask and broadcast fields, representing the subnet mask IP and the broadcast IP for the given interface
Returns:

True, if the given address is in the same network as given interface address, False otherwise.

Raises:

ValueError: if invalid IP addresses are given for any field.

Raises:

KeyError: if the netmask and broadcast fields are not present in the interface address entry

argument.

narupa.essd.utils.resolve_host_broadcast_address(host: str, ipv4_addrs: List[Dict[str, str]] = None)