ipmininet.utils module¶
utils: utility functions to manipulate host, interfaces, …
-
class
ipmininet.utils.
L3Router
¶ Bases:
object
Placeholder class to identify L3 routing devices (primarily routers, but this could also be used for a device needing to participate to some routing protocol e.g. for TE purposes)
-
static
is_l3router_intf
(itf: mininet.link.Intf) → bool¶ Returns whether an interface belongs to an L3Router (in the Mininet meaning: an intf with an associated node)
-
static
-
ipmininet.utils.
address_pair
(n: mininet.node.Node, use_v4=True, use_v6=True) → Tuple[Optional[str], Optional[str]]¶ Returns a tuple (ip, ip6) with ip/ip6 being one of the IPv4/IPv6 addresses of the node n
-
ipmininet.utils.
find_node
(start: mininet.node.Node, node_name: str) → Optional[mininet.link.Intf]¶ Parameters: - start – The starting node of the search
- node_name – The name of the node to find
Returns: The interface of the node connected to start with node_name as name
-
ipmininet.utils.
get_set
(d: Dict[KT, VT], key, default: Type[CT_co])¶ Attempt to return the value for the given key, otherwise initialize it
Parameters: - d – dict
- key – key of d
- default – constructor
-
ipmininet.utils.
has_cmd
(cmd: str) → bool¶ Return whether the given executable is available on the system or not
-
ipmininet.utils.
is_container
(x) → bool¶ Return whether x is a container (=iterable but not a string)
-
ipmininet.utils.
is_subnet_of
(a: Union[ipaddress.IPv4Network, ipaddress.IPv6Network], b: Union[ipaddress.IPv4Network, ipaddress.IPv6Network]) → bool¶ Return True if network a is a subnet of network b.
-
ipmininet.utils.
otherIntf
(intf: mininet.link.Intf) → Optional[IPIntf]¶ “Get the interface on the other side of a link
-
ipmininet.utils.
prefix_for_netmask
(mask: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str]) → int¶ Return the prefix length associated to a given netmask. Will return garbage if the netmask is unproperly formatted!
-
ipmininet.utils.
realIntfList
(n: mininet.node.Node) → List[IPIntf]¶ Return the list of interfaces of node n excluding loopback
-
ipmininet.utils.
require_cmd
(cmd: str, help_str: Optional[str] = None)¶ Ensures that a command is available in $PATH
Parameters: - cmd – the command to test
- help_str – an optional help string to display if cmd is not found