charmhelpers.contrib.network package

charmhelpers.contrib.network.ip module

charmhelpers.contrib.network.ip.format_ipv6_addr(address)

If address is IPv6, wrap it in ‘[]’ otherwise return None.

This is required by most configuration files when specifying IPv6 addresses.

charmhelpers.contrib.network.ip.get_address_in_network(network, fallback=None, fatal=False)

Get an IPv4 or IPv6 address within the network from the host.

Parameters:
  • (str) (fallback) – CIDR presentation format. For example, ‘192.168.1.0/24’.
  • (str) – If no address is found, return fallback.
  • (boolean) (fatal) – If no address is found, fallback is not set and fatal is True then exit(1).
charmhelpers.contrib.network.ip.get_bridge_nics(bridge, vnic_dir='/sys/devices/virtual/net')

Return a list of nics comprising a given bridge on the system.

charmhelpers.contrib.network.ip.get_bridges(vnic_dir='/sys/devices/virtual/net')

Return a list of bridges on the system.

charmhelpers.contrib.network.ip.get_host_ip(hostname, fallback=None)

Resolves the IP for a given hostname, or returns the input if it is already an IP.

charmhelpers.contrib.network.ip.get_hostname(address, fqdn=True)

Resolves hostname for given IP, or returns the input if it is already a hostname.

charmhelpers.contrib.network.ip.get_iface_addr(iface='eth0', inet_type='AF_INET', inc_aliases=False, fatal=True, exc_list=None)

Return the assigned IP address for a given interface, if any.

charmhelpers.contrib.network.ip.get_iface_from_addr(addr)

Work out on which interface the provided address is configured.

charmhelpers.contrib.network.ip.get_ipv6_addr(*args, **kwargs)
charmhelpers.contrib.network.ip.is_address_in_network(network, address)

Determine whether the provided address is within a network range.

Parameters:
  • (str) (network) – CIDR presentation format. For example, ‘192.168.1.0/24’.
  • address – An individual IPv4 or IPv6 address without a net mask or subnet prefix. For example, ‘192.168.1.1’.
Returns boolean:
 

Flag indicating whether address is in network.

charmhelpers.contrib.network.ip.is_bridge_member(nic)

Check if a given nic is a member of a bridge.

charmhelpers.contrib.network.ip.is_ip(address)

Returns True if address is a valid IP address.

charmhelpers.contrib.network.ip.is_ipv6(address)

Determine whether provided address is IPv6 or not.

charmhelpers.contrib.network.ip.no_ip_found_error_out(network)
charmhelpers.contrib.network.ip.ns_query(address)
charmhelpers.contrib.network.ip.sniff_iface(f)

Ensure decorated function is called with a value for iface.

If no iface provided, inject net iface inferred from unit private address.