65
68
from charmhelpers.contrib.openstack.neutron import (
66
69
neutron_plugin_attribute,
71
from charmhelpers.contrib.openstack.ip import (
68
75
from charmhelpers.contrib.network.ip import (
69
76
get_address_in_network,
71
79
get_netmask_for_address,
73
81
is_address_in_network,
75
84
from charmhelpers.contrib.openstack.utils import get_host_ip
730
for cn in self.canonical_names():
739
cns = self.canonical_names()
742
self.configure_cert(cn)
744
# Expect cert/key provided in config (currently assumed that ca
746
cn = resolve_address(endpoint_type=INTERNAL)
731
747
self.configure_cert(cn)
733
749
addresses = self.get_network_addresses()
902
class NeutronPortContext(OSContextGenerator):
903
NIC_PREFIXES = ['eth', 'bond']
905
def resolve_ports(self, ports):
906
"""Resolve NICs not yet bound to bridge(s)
908
If hwaddress provided then returns resolved hwaddress otherwise NIC.
915
for nic in list_nics(self.NIC_PREFIXES):
916
hwaddr = get_nic_hwaddr(nic)
917
hwaddr_to_nic[hwaddr] = nic
918
addresses = get_ipv4_addr(nic, fatal=False)
919
addresses += get_ipv6_addr(iface=nic, fatal=False)
920
hwaddr_to_ip[hwaddr] = addresses
923
mac_regex = re.compile(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', re.I)
925
if re.match(mac_regex, entry):
926
# NIC is in known NICs and does NOT hace an IP address
927
if entry in hwaddr_to_nic and not hwaddr_to_ip[entry]:
928
# If the nic is part of a bridge then don't use it
929
if is_bridge_member(hwaddr_to_nic[entry]):
932
# Entry is a MAC address for a valid interface that doesn't
933
# have an IP address assigned yet.
934
resolved.append(hwaddr_to_nic[entry])
936
# If the passed entry is not a MAC address, assume it's a valid
937
# interface, and that the user put it there on purpose (we can
938
# trust it to be the real external network).
939
resolved.append(entry)
886
944
class OSConfigFlagContext(OSContextGenerator):
887
945
"""Provides support for user-defined config flags.