Sync charm-helpers to enable swift 2.15.0
Change-Id: I9bea911955c9f0792884be128849a43581d4ee01
This commit is contained in:
parent
7873139795
commit
698fa90cfa
@ -125,7 +125,7 @@ class CheckException(Exception):
|
||||
|
||||
|
||||
class Check(object):
|
||||
shortname_re = '[A-Za-z0-9-_]+$'
|
||||
shortname_re = '[A-Za-z0-9-_.]+$'
|
||||
service_template = ("""
|
||||
#---------------------------------------------------
|
||||
# This file is Juju managed
|
||||
|
@ -517,7 +517,9 @@ class CephContext(OSContextGenerator):
|
||||
if not ctxt.get('key'):
|
||||
ctxt['key'] = relation_get('key', rid=rid, unit=unit)
|
||||
if not ctxt.get('rbd_features'):
|
||||
ctxt['rbd_features'] = relation_get('rbd-features', rid=rid, unit=unit)
|
||||
default_features = relation_get('rbd-features', rid=rid, unit=unit)
|
||||
if default_features is not None:
|
||||
ctxt['rbd_features'] = default_features
|
||||
|
||||
ceph_addrs = relation_get('ceph-public-address', rid=rid,
|
||||
unit=unit)
|
||||
@ -734,11 +736,17 @@ class ApacheSSLContext(OSContextGenerator):
|
||||
return sorted(list(set(cns)))
|
||||
|
||||
def get_network_addresses(self):
|
||||
"""For each network configured, return corresponding address and vip
|
||||
(if available).
|
||||
"""For each network configured, return corresponding address and
|
||||
hostnamr or vip (if available).
|
||||
|
||||
Returns a list of tuples of the form:
|
||||
|
||||
[(address_in_net_a, hostname_in_net_a),
|
||||
(address_in_net_b, hostname_in_net_b),
|
||||
...]
|
||||
|
||||
or, if no hostnames(s) available:
|
||||
|
||||
[(address_in_net_a, vip_in_net_a),
|
||||
(address_in_net_b, vip_in_net_b),
|
||||
...]
|
||||
@ -755,18 +763,22 @@ class ApacheSSLContext(OSContextGenerator):
|
||||
else:
|
||||
vips = []
|
||||
|
||||
for net_type in ['os-internal-network', 'os-admin-network',
|
||||
'os-public-network']:
|
||||
addr = get_address_in_network(config(net_type),
|
||||
for net_type in ['internal', 'admin', 'public']:
|
||||
net_config = config('os-{}-network'.format(net_type))
|
||||
addr = get_address_in_network(net_config,
|
||||
unit_get('private-address'))
|
||||
if len(vips) > 1 and is_clustered():
|
||||
if not config(net_type):
|
||||
|
||||
hostname_config = config('os-{}-hostname'.format(net_type))
|
||||
if hostname_config:
|
||||
addresses.append((addr, hostname_config))
|
||||
elif len(vips) > 1 and is_clustered():
|
||||
if not net_config:
|
||||
log("Multiple networks configured but net_type "
|
||||
"is None (%s)." % net_type, level=WARNING)
|
||||
continue
|
||||
|
||||
for vip in vips:
|
||||
if is_address_in_network(config(net_type), vip):
|
||||
if is_address_in_network(net_config, vip):
|
||||
addresses.append((addr, vip))
|
||||
break
|
||||
|
||||
@ -1417,14 +1429,26 @@ class NeutronAPIContext(OSContextGenerator):
|
||||
'rel_key': 'report-interval',
|
||||
'default': 30,
|
||||
},
|
||||
'enable_qos': {
|
||||
'rel_key': 'enable-qos',
|
||||
'default': False,
|
||||
},
|
||||
}
|
||||
ctxt = self.get_neutron_options({})
|
||||
for rid in relation_ids('neutron-plugin-api'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
# The l2-population key is used by the context as a way of
|
||||
# checking if the api service on the other end is sending data
|
||||
# in a recent format.
|
||||
if 'l2-population' in rdata:
|
||||
ctxt.update(self.get_neutron_options(rdata))
|
||||
|
||||
if ctxt['enable_qos']:
|
||||
ctxt['extension_drivers'] = 'qos'
|
||||
else:
|
||||
ctxt['extension_drivers'] = ''
|
||||
|
||||
return ctxt
|
||||
|
||||
def get_neutron_options(self, rdata):
|
||||
|
@ -0,0 +1,8 @@
|
||||
{% if transport_url -%}
|
||||
[oslo_messaging_notifications]
|
||||
driver = messagingv2
|
||||
transport_url = {{ transport_url }}
|
||||
{% if notification_topics -%}
|
||||
topics = {{ notification_topics }}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
@ -186,7 +186,7 @@ SWIFT_CODENAMES = OrderedDict([
|
||||
('ocata',
|
||||
['2.11.0', '2.12.0', '2.13.0']),
|
||||
('pike',
|
||||
['2.13.0']),
|
||||
['2.13.0', '2.15.0']),
|
||||
])
|
||||
|
||||
# >= Liberty version->codename mapping
|
||||
@ -2051,7 +2051,7 @@ def snap_install_requested():
|
||||
If openstack-origin is of the form snap:channel-series-release
|
||||
and channel is in SNAPS_CHANNELS return True.
|
||||
"""
|
||||
origin = config('openstack-origin')
|
||||
origin = config('openstack-origin') or ""
|
||||
if not origin.startswith('snap:'):
|
||||
return False
|
||||
|
||||
|
@ -202,6 +202,27 @@ def service_name():
|
||||
return local_unit().split('/')[0]
|
||||
|
||||
|
||||
def principal_unit():
|
||||
"""Returns the principal unit of this unit, otherwise None"""
|
||||
# Juju 2.2 and above provides JUJU_PRINCIPAL_UNIT
|
||||
principal_unit = os.environ.get('JUJU_PRINCIPAL_UNIT', None)
|
||||
# If it's empty, then this unit is the principal
|
||||
if principal_unit == '':
|
||||
return os.environ['JUJU_UNIT_NAME']
|
||||
elif principal_unit is not None:
|
||||
return principal_unit
|
||||
# For Juju 2.1 and below, let's try work out the principle unit by
|
||||
# the various charms' metadata.yaml.
|
||||
for reltype in relation_types():
|
||||
for rid in relation_ids(reltype):
|
||||
for unit in related_units(rid):
|
||||
md = _metadata_unit(unit)
|
||||
subordinate = md.pop('subordinate', None)
|
||||
if not subordinate:
|
||||
return unit
|
||||
return None
|
||||
|
||||
|
||||
@cached
|
||||
def remote_service_name(relid=None):
|
||||
"""The remote service name for a given relation-id (or the current relation)"""
|
||||
@ -478,6 +499,21 @@ def metadata():
|
||||
return yaml.safe_load(md)
|
||||
|
||||
|
||||
def _metadata_unit(unit):
|
||||
"""Given the name of a unit (e.g. apache2/0), get the unit charm's
|
||||
metadata.yaml. Very similar to metadata() but allows us to inspect
|
||||
other units. Unit needs to be co-located, such as a subordinate or
|
||||
principal/primary.
|
||||
|
||||
:returns: metadata.yaml as a python object.
|
||||
|
||||
"""
|
||||
basedir = os.sep.join(charm_dir().split(os.sep)[:-2])
|
||||
unitdir = 'unit-{}'.format(unit.replace(os.sep, '-'))
|
||||
with open(os.path.join(basedir, unitdir, 'charm', 'metadata.yaml')) as md:
|
||||
return yaml.safe_load(md)
|
||||
|
||||
|
||||
@cached
|
||||
def relation_types():
|
||||
"""Get a list of relation types supported by this charm"""
|
||||
@ -753,6 +789,9 @@ class Hooks(object):
|
||||
|
||||
def charm_dir():
|
||||
"""Return the root directory of the current charm"""
|
||||
d = os.environ.get('JUJU_CHARM_DIR')
|
||||
if d is not None:
|
||||
return d
|
||||
return os.environ.get('CHARM_DIR')
|
||||
|
||||
|
||||
|
@ -202,6 +202,27 @@ def service_name():
|
||||
return local_unit().split('/')[0]
|
||||
|
||||
|
||||
def principal_unit():
|
||||
"""Returns the principal unit of this unit, otherwise None"""
|
||||
# Juju 2.2 and above provides JUJU_PRINCIPAL_UNIT
|
||||
principal_unit = os.environ.get('JUJU_PRINCIPAL_UNIT', None)
|
||||
# If it's empty, then this unit is the principal
|
||||
if principal_unit == '':
|
||||
return os.environ['JUJU_UNIT_NAME']
|
||||
elif principal_unit is not None:
|
||||
return principal_unit
|
||||
# For Juju 2.1 and below, let's try work out the principle unit by
|
||||
# the various charms' metadata.yaml.
|
||||
for reltype in relation_types():
|
||||
for rid in relation_ids(reltype):
|
||||
for unit in related_units(rid):
|
||||
md = _metadata_unit(unit)
|
||||
subordinate = md.pop('subordinate', None)
|
||||
if not subordinate:
|
||||
return unit
|
||||
return None
|
||||
|
||||
|
||||
@cached
|
||||
def remote_service_name(relid=None):
|
||||
"""The remote service name for a given relation-id (or the current relation)"""
|
||||
@ -478,6 +499,21 @@ def metadata():
|
||||
return yaml.safe_load(md)
|
||||
|
||||
|
||||
def _metadata_unit(unit):
|
||||
"""Given the name of a unit (e.g. apache2/0), get the unit charm's
|
||||
metadata.yaml. Very similar to metadata() but allows us to inspect
|
||||
other units. Unit needs to be co-located, such as a subordinate or
|
||||
principal/primary.
|
||||
|
||||
:returns: metadata.yaml as a python object.
|
||||
|
||||
"""
|
||||
basedir = os.sep.join(charm_dir().split(os.sep)[:-2])
|
||||
unitdir = 'unit-{}'.format(unit.replace(os.sep, '-'))
|
||||
with open(os.path.join(basedir, unitdir, 'charm', 'metadata.yaml')) as md:
|
||||
return yaml.safe_load(md)
|
||||
|
||||
|
||||
@cached
|
||||
def relation_types():
|
||||
"""Get a list of relation types supported by this charm"""
|
||||
@ -753,6 +789,9 @@ class Hooks(object):
|
||||
|
||||
def charm_dir():
|
||||
"""Return the root directory of the current charm"""
|
||||
d = os.environ.get('JUJU_CHARM_DIR')
|
||||
if d is not None:
|
||||
return d
|
||||
return os.environ.get('CHARM_DIR')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user