nanover.essd.utils module

nanover.essd.utils.get_broadcast_addresses(interfaces: Iterable[str] | None = 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 netifaces.ifaddresses().

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

{
  'addr': '172.23.43.33',
  'netmask': '255.255.0.0',
  'broadcast': '172.23.255.255'
}
nanover.essd.utils.get_broadcastable_ip()
nanover.essd.utils.get_ipv4_addresses(interfaces: Iterable[str] | None = 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 netifaces.ifaddresses().

nanover.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 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.

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