Sync charm-helpers to get fix for PR 320
Allows the charm to filter out interfaces from data-port that don't exist on the local host. Change-Id: I3a8ee204facf68753c564a297825666900c1b835 Closes-Bug: #1822558
This commit is contained in:
parent
18e251b4b1
commit
f7cfbe8bd3
@ -220,6 +220,8 @@ def process_certificates(service_name, relation_id, unit,
|
|||||||
:type user: str
|
:type user: str
|
||||||
:param group: (Optional) Group of certificate files. Defaults to 'root'
|
:param group: (Optional) Group of certificate files. Defaults to 'root'
|
||||||
:type group: str
|
:type group: str
|
||||||
|
:returns: True if certificates processed for local unit or False
|
||||||
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
data = relation_get(rid=relation_id, unit=unit)
|
data = relation_get(rid=relation_id, unit=unit)
|
||||||
ssl_dir = os.path.join('/etc/apache2/ssl/', service_name)
|
ssl_dir = os.path.join('/etc/apache2/ssl/', service_name)
|
||||||
@ -235,6 +237,8 @@ def process_certificates(service_name, relation_id, unit,
|
|||||||
create_ip_cert_links(
|
create_ip_cert_links(
|
||||||
ssl_dir,
|
ssl_dir,
|
||||||
custom_hostname_link=custom_hostname_link)
|
custom_hostname_link=custom_hostname_link)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_requests_for_local_unit(relation_name=None):
|
def get_requests_for_local_unit(relation_name=None):
|
||||||
|
@ -117,6 +117,7 @@ except ImportError:
|
|||||||
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
|
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
|
||||||
ADDRESS_TYPES = ['admin', 'internal', 'public']
|
ADDRESS_TYPES = ['admin', 'internal', 'public']
|
||||||
HAPROXY_RUN_DIR = '/var/run/haproxy/'
|
HAPROXY_RUN_DIR = '/var/run/haproxy/'
|
||||||
|
DEFAULT_OSLO_MESSAGING_DRIVER = "messagingv2"
|
||||||
|
|
||||||
|
|
||||||
def ensure_packages(packages):
|
def ensure_packages(packages):
|
||||||
@ -351,10 +352,70 @@ class IdentityServiceContext(OSContextGenerator):
|
|||||||
return cachedir
|
return cachedir
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _get_pkg_name(self, python_name='keystonemiddleware'):
|
||||||
|
"""Get corresponding distro installed package for python
|
||||||
|
package name.
|
||||||
|
|
||||||
|
:param python_name: nameof the python package
|
||||||
|
:type: string
|
||||||
|
"""
|
||||||
|
pkg_names = map(lambda x: x + python_name, ('python3-', 'python-'))
|
||||||
|
|
||||||
|
for pkg in pkg_names:
|
||||||
|
if not filter_installed_packages((pkg,)):
|
||||||
|
return pkg
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _get_keystone_authtoken_ctxt(self, ctxt, keystonemiddleware_os_rel):
|
||||||
|
"""Build Jinja2 context for full rendering of [keystone_authtoken]
|
||||||
|
section with variable names included. Re-constructed from former
|
||||||
|
template 'section-keystone-auth-mitaka'.
|
||||||
|
|
||||||
|
:param ctxt: Jinja2 context returned from self.__call__()
|
||||||
|
:type: dict
|
||||||
|
:param keystonemiddleware_os_rel: OpenStack release name of
|
||||||
|
keystonemiddleware package installed
|
||||||
|
"""
|
||||||
|
c = collections.OrderedDict((('auth_type', 'password'),))
|
||||||
|
|
||||||
|
# 'www_authenticate_uri' replaced 'auth_uri' since Stein,
|
||||||
|
# see keystonemiddleware upstream sources for more info
|
||||||
|
if CompareOpenStackReleases(keystonemiddleware_os_rel) >= 'stein':
|
||||||
|
c.update((
|
||||||
|
('www_authenticate_uri', "{}://{}:{}/v3".format(
|
||||||
|
ctxt.get('service_protocol', ''),
|
||||||
|
ctxt.get('service_host', ''),
|
||||||
|
ctxt.get('service_port', ''))),))
|
||||||
|
else:
|
||||||
|
c.update((
|
||||||
|
('auth_uri', "{}://{}:{}/v3".format(
|
||||||
|
ctxt.get('service_protocol', ''),
|
||||||
|
ctxt.get('service_host', ''),
|
||||||
|
ctxt.get('service_port', ''))),))
|
||||||
|
|
||||||
|
c.update((
|
||||||
|
('auth_url', "{}://{}:{}/v3".format(
|
||||||
|
ctxt.get('auth_protocol', ''),
|
||||||
|
ctxt.get('auth_host', ''),
|
||||||
|
ctxt.get('auth_port', ''))),
|
||||||
|
('project_domain_name', ctxt.get('admin_domain_name', '')),
|
||||||
|
('user_domain_name', ctxt.get('admin_domain_name', '')),
|
||||||
|
('project_name', ctxt.get('admin_tenant_name', '')),
|
||||||
|
('username', ctxt.get('admin_user', '')),
|
||||||
|
('password', ctxt.get('admin_password', '')),
|
||||||
|
('signing_dir', ctxt.get('signing_dir', '')),))
|
||||||
|
|
||||||
|
return c
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
log('Generating template context for ' + self.rel_name, level=DEBUG)
|
log('Generating template context for ' + self.rel_name, level=DEBUG)
|
||||||
ctxt = {}
|
ctxt = {}
|
||||||
|
|
||||||
|
keystonemiddleware_os_release = None
|
||||||
|
if self._get_pkg_name():
|
||||||
|
keystonemiddleware_os_release = os_release(self._get_pkg_name())
|
||||||
|
|
||||||
cachedir = self._setup_pki_cache()
|
cachedir = self._setup_pki_cache()
|
||||||
if cachedir:
|
if cachedir:
|
||||||
ctxt['signing_dir'] = cachedir
|
ctxt['signing_dir'] = cachedir
|
||||||
@ -385,6 +446,14 @@ class IdentityServiceContext(OSContextGenerator):
|
|||||||
ctxt.update({'admin_domain_name':
|
ctxt.update({'admin_domain_name':
|
||||||
rdata.get('service_domain')})
|
rdata.get('service_domain')})
|
||||||
|
|
||||||
|
# we keep all veriables in ctxt for compatibility and
|
||||||
|
# add nested dictionary for keystone_authtoken generic
|
||||||
|
# templating
|
||||||
|
if keystonemiddleware_os_release:
|
||||||
|
ctxt['keystone_authtoken'] = \
|
||||||
|
self._get_keystone_authtoken_ctxt(
|
||||||
|
ctxt, keystonemiddleware_os_release)
|
||||||
|
|
||||||
if self.context_complete(ctxt):
|
if self.context_complete(ctxt):
|
||||||
# NOTE(jamespage) this is required for >= icehouse
|
# NOTE(jamespage) this is required for >= icehouse
|
||||||
# so a missing value just indicates keystone needs
|
# so a missing value just indicates keystone needs
|
||||||
@ -569,6 +638,15 @@ class AMQPContext(OSContextGenerator):
|
|||||||
ctxt['oslo_messaging_flags'] = config_flags_parser(
|
ctxt['oslo_messaging_flags'] = config_flags_parser(
|
||||||
oslo_messaging_flags)
|
oslo_messaging_flags)
|
||||||
|
|
||||||
|
oslo_messaging_driver = conf.get(
|
||||||
|
'oslo-messaging-driver', DEFAULT_OSLO_MESSAGING_DRIVER)
|
||||||
|
if oslo_messaging_driver:
|
||||||
|
ctxt['oslo_messaging_driver'] = oslo_messaging_driver
|
||||||
|
|
||||||
|
notification_format = conf.get('notification-format', None)
|
||||||
|
if notification_format:
|
||||||
|
ctxt['notification_format'] = notification_format
|
||||||
|
|
||||||
if not self.complete:
|
if not self.complete:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@ -1110,7 +1188,9 @@ class NeutronPortContext(OSContextGenerator):
|
|||||||
|
|
||||||
hwaddr_to_nic = {}
|
hwaddr_to_nic = {}
|
||||||
hwaddr_to_ip = {}
|
hwaddr_to_ip = {}
|
||||||
for nic in list_nics():
|
extant_nics = list_nics()
|
||||||
|
|
||||||
|
for nic in extant_nics:
|
||||||
# Ignore virtual interfaces (bond masters will be identified from
|
# Ignore virtual interfaces (bond masters will be identified from
|
||||||
# their slaves)
|
# their slaves)
|
||||||
if not is_phy_iface(nic):
|
if not is_phy_iface(nic):
|
||||||
@ -1141,10 +1221,11 @@ class NeutronPortContext(OSContextGenerator):
|
|||||||
# Entry is a MAC address for a valid interface that doesn't
|
# Entry is a MAC address for a valid interface that doesn't
|
||||||
# have an IP address assigned yet.
|
# have an IP address assigned yet.
|
||||||
resolved.append(hwaddr_to_nic[entry])
|
resolved.append(hwaddr_to_nic[entry])
|
||||||
else:
|
elif entry in extant_nics:
|
||||||
# If the passed entry is not a MAC address, assume it's a valid
|
# If the passed entry is not a MAC address and the interface
|
||||||
# interface, and that the user put it there on purpose (we can
|
# exists, assume it's a valid interface, and that the user put
|
||||||
# trust it to be the real external network).
|
# it there on purpose (we can trust it to be the real external
|
||||||
|
# network).
|
||||||
resolved.append(entry)
|
resolved.append(entry)
|
||||||
|
|
||||||
# Ensure no duplicates
|
# Ensure no duplicates
|
||||||
@ -1526,6 +1607,14 @@ class NeutronAPIContext(OSContextGenerator):
|
|||||||
'rel_key': 'enable-nsg-logging',
|
'rel_key': 'enable-nsg-logging',
|
||||||
'default': False,
|
'default': False,
|
||||||
},
|
},
|
||||||
|
'global_physnet_mtu': {
|
||||||
|
'rel_key': 'global-physnet-mtu',
|
||||||
|
'default': 1500,
|
||||||
|
},
|
||||||
|
'physical_network_mtus': {
|
||||||
|
'rel_key': 'physical-network-mtus',
|
||||||
|
'default': None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctxt = self.get_neutron_options({})
|
ctxt = self.get_neutron_options({})
|
||||||
for rid in relation_ids('neutron-plugin-api'):
|
for rid in relation_ids('neutron-plugin-api'):
|
||||||
@ -1587,13 +1676,13 @@ class DataPortContext(NeutronPortContext):
|
|||||||
def __call__(self):
|
def __call__(self):
|
||||||
ports = config('data-port')
|
ports = config('data-port')
|
||||||
if ports:
|
if ports:
|
||||||
# Map of {port/mac:bridge}
|
# Map of {bridge:port/mac}
|
||||||
portmap = parse_data_port_mappings(ports)
|
portmap = parse_data_port_mappings(ports)
|
||||||
ports = portmap.keys()
|
ports = portmap.keys()
|
||||||
# Resolve provided ports or mac addresses and filter out those
|
# Resolve provided ports or mac addresses and filter out those
|
||||||
# already attached to a bridge.
|
# already attached to a bridge.
|
||||||
resolved = self.resolve_ports(ports)
|
resolved = self.resolve_ports(ports)
|
||||||
# FIXME: is this necessary?
|
# Rebuild port index using resolved and filtered ports.
|
||||||
normalized = {get_nic_hwaddr(port): port for port in resolved
|
normalized = {get_nic_hwaddr(port): port for port in resolved
|
||||||
if port not in ports}
|
if port not in ports}
|
||||||
normalized.update({port: port for port in resolved
|
normalized.update({port: port for port in resolved
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
{% if transport_url -%}
|
{% if transport_url -%}
|
||||||
[oslo_messaging_notifications]
|
[oslo_messaging_notifications]
|
||||||
driver = messagingv2
|
driver = {{ oslo_messaging_driver }}
|
||||||
transport_url = {{ transport_url }}
|
transport_url = {{ transport_url }}
|
||||||
{% if notification_topics -%}
|
{% if notification_topics -%}
|
||||||
topics = {{ notification_topics }}
|
topics = {{ notification_topics }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if notification_format -%}
|
{% if notification_format -%}
|
||||||
|
[notifications]
|
||||||
notification_format = {{ notification_format }}
|
notification_format = {{ notification_format }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
@ -194,7 +194,7 @@ SWIFT_CODENAMES = OrderedDict([
|
|||||||
('rocky',
|
('rocky',
|
||||||
['2.18.0', '2.19.0']),
|
['2.18.0', '2.19.0']),
|
||||||
('stein',
|
('stein',
|
||||||
['2.20.0']),
|
['2.20.0', '2.21.0']),
|
||||||
])
|
])
|
||||||
|
|
||||||
# >= Liberty version->codename mapping
|
# >= Liberty version->codename mapping
|
||||||
|
@ -513,6 +513,7 @@ class TestNeutronOVSUtils(CharmTestCase):
|
|||||||
self.is_linuxbridge_interface.return_value = False
|
self.is_linuxbridge_interface.return_value = False
|
||||||
mock_config.side_effect = self.test_config.get
|
mock_config.side_effect = self.test_config.get
|
||||||
self.config.side_effect = self.test_config.get
|
self.config.side_effect = self.test_config.get
|
||||||
|
_nics.return_value = ['eth0']
|
||||||
self.ExternalPortContext.return_value = \
|
self.ExternalPortContext.return_value = \
|
||||||
DummyContext(return_value=None)
|
DummyContext(return_value=None)
|
||||||
# Test back-compatibility i.e. port but no bridge (so br-data is
|
# Test back-compatibility i.e. port but no bridge (so br-data is
|
||||||
@ -555,6 +556,7 @@ class TestNeutronOVSUtils(CharmTestCase):
|
|||||||
# Now test with bridge:bridge format
|
# Now test with bridge:bridge format
|
||||||
self.test_config.set('bridge-mappings', 'physnet1:br-foo')
|
self.test_config.set('bridge-mappings', 'physnet1:br-foo')
|
||||||
self.test_config.set('data-port', 'br-foo:br-juju')
|
self.test_config.set('data-port', 'br-foo:br-juju')
|
||||||
|
_nics.return_value = ['br-juju']
|
||||||
self.add_bridge.reset_mock()
|
self.add_bridge.reset_mock()
|
||||||
self.add_bridge_port.reset_mock()
|
self.add_bridge_port.reset_mock()
|
||||||
nutils.configure_ovs()
|
nutils.configure_ovs()
|
||||||
|
Loading…
Reference in New Issue
Block a user