Sync charm-helpers

Change-Id: Icc23f15476b51da75c1cc2f970a4cfdd398e1c98
This commit is contained in:
Corey Bryant 2019-01-08 15:18:48 +00:00
parent 14cf03c9a2
commit 5b38cf05cb
8 changed files with 78 additions and 33 deletions

View File

@ -305,7 +305,7 @@ class NRPE(object):
# update-status hooks are configured to firing every 5 minutes by # update-status hooks are configured to firing every 5 minutes by
# default. When nagios-nrpe-server is restarted, the nagios server # default. When nagios-nrpe-server is restarted, the nagios server
# reports checks failing causing unneccessary alerts. Let's not restart # reports checks failing causing unnecessary alerts. Let's not restart
# on update-status hooks. # on update-status hooks.
if not hook_name() == 'update-status': if not hook_name() == 'update-status':
service('restart', 'nagios-nrpe-server') service('restart', 'nagios-nrpe-server')

View File

@ -293,7 +293,9 @@ class OpenStackAmuletDeployment(AmuletDeployment):
('artful', None): self.artful_pike, ('artful', None): self.artful_pike,
('bionic', None): self.bionic_queens, ('bionic', None): self.bionic_queens,
('bionic', 'cloud:bionic-rocky'): self.bionic_rocky, ('bionic', 'cloud:bionic-rocky'): self.bionic_rocky,
('bionic', 'cloud:bionic-stein'): self.bionic_stein,
('cosmic', None): self.cosmic_rocky, ('cosmic', None): self.cosmic_rocky,
('disco', None): self.disco_stein,
} }
return releases[(self.series, self.openstack)] return releases[(self.series, self.openstack)]

View File

@ -57,7 +57,8 @@ OPENSTACK_RELEASES_PAIRS = [
'trusty_mitaka', 'xenial_mitaka', 'xenial_newton', 'trusty_mitaka', 'xenial_mitaka', 'xenial_newton',
'yakkety_newton', 'xenial_ocata', 'zesty_ocata', 'yakkety_newton', 'xenial_ocata', 'zesty_ocata',
'xenial_pike', 'artful_pike', 'xenial_queens', 'xenial_pike', 'artful_pike', 'xenial_queens',
'bionic_queens', 'bionic_rocky', 'cosmic_rocky'] 'bionic_queens', 'bionic_rocky', 'cosmic_rocky',
'bionic_stein', 'disco_stein']
class OpenStackAmuletUtils(AmuletUtils): class OpenStackAmuletUtils(AmuletUtils):

View File

@ -195,7 +195,7 @@ def install_certs(ssl_dir, certs, chain=None):
if chain: if chain:
# Append chain file so that clients that trust the root CA will # Append chain file so that clients that trust the root CA will
# trust certs signed by an intermediate in the chain # trust certs signed by an intermediate in the chain
cert_data = cert_data + chain cert_data = cert_data + os.linesep + chain
write_file( write_file(
path=os.path.join(ssl_dir, cert_filename), path=os.path.join(ssl_dir, cert_filename),
content=cert_data, perms=0o640) content=cert_data, perms=0o640)

View File

@ -98,7 +98,6 @@ from charmhelpers.contrib.network.ip import (
from charmhelpers.contrib.openstack.utils import ( from charmhelpers.contrib.openstack.utils import (
config_flags_parser, config_flags_parser,
enable_memcache, enable_memcache,
snap_install_requested,
CompareOpenStackReleases, CompareOpenStackReleases,
os_release, os_release,
) )
@ -252,13 +251,8 @@ class SharedDBContext(OSContextGenerator):
'database': self.database, 'database': self.database,
'database_user': self.user, 'database_user': self.user,
'database_password': rdata.get(password_setting), 'database_password': rdata.get(password_setting),
'database_type': 'mysql' 'database_type': 'mysql+pymysql'
} }
# Note(coreycb): We can drop mysql+pymysql if we want when the
# following review lands, though it seems mysql+pymysql would
# be preferred. https://review.openstack.org/#/c/462190/
if snap_install_requested():
ctxt['database_type'] = 'mysql+pymysql'
if self.context_complete(ctxt): if self.context_complete(ctxt):
db_ssl(rdata, ctxt, self.ssl_dir) db_ssl(rdata, ctxt, self.ssl_dir)
return ctxt return ctxt

View File

@ -63,6 +63,9 @@ JSON_ENCODE_OPTIONS = dict(
separators=(',', ':'), separators=(',', ':'),
) )
VIP_GROUP_NAME = 'grp_{service}_vips'
DNSHA_GROUP_NAME = 'grp_{service}_hostnames'
class DNSHAException(Exception): class DNSHAException(Exception):
"""Raised when an error occurs setting up DNS HA """Raised when an error occurs setting up DNS HA
@ -239,7 +242,7 @@ def update_hacluster_dns_ha(service, relation_data,
'Informing the ha relation'.format(' '.join(hostname_group)), 'Informing the ha relation'.format(' '.join(hostname_group)),
DEBUG) DEBUG)
relation_data['groups'] = { relation_data['groups'] = {
'grp_{}_hostnames'.format(service): ' '.join(hostname_group) DNSHA_GROUP_NAME.format(service=service): ' '.join(hostname_group)
} }
else: else:
msg = 'DNS HA: Hostname group has no members.' msg = 'DNS HA: Hostname group has no members.'
@ -247,6 +250,27 @@ def update_hacluster_dns_ha(service, relation_data,
raise DNSHAException(msg) raise DNSHAException(msg)
def get_vip_settings(vip):
"""Calculate which nic is on the correct network for the given vip.
If nic or netmask discovery fail then fallback to using charm supplied
config. If fallback is used this is indicated via the fallback variable.
@param vip: VIP to lookup nic and cidr for.
@returns (str, str, bool): eg (iface, netmask, fallback)
"""
iface = get_iface_for_address(vip)
netmask = get_netmask_for_address(vip)
fallback = False
if iface is None:
iface = config('vip_iface')
fallback = True
if netmask is None:
netmask = config('vip_cidr')
fallback = True
return iface, netmask, fallback
def update_hacluster_vip(service, relation_data): def update_hacluster_vip(service, relation_data):
""" Configure VIP resources based on provided configuration """ Configure VIP resources based on provided configuration
@ -264,17 +288,9 @@ def update_hacluster_vip(service, relation_data):
res_vip = 'ocf:heartbeat:IPaddr2' res_vip = 'ocf:heartbeat:IPaddr2'
vip_params = 'ip' vip_params = 'ip'
iface = get_iface_for_address(vip) iface, netmask, fallback = get_vip_settings(vip)
netmask = get_netmask_for_address(vip)
fallback_params = False
if iface is None:
iface = config('vip_iface')
fallback_params = True
if netmask is None:
netmask = config('vip_cidr')
fallback_params = True
vip_monitoring = 'op monitor depth="0" timeout="20s" interval="10s"'
if iface is not None: if iface is not None:
# NOTE(jamespage): Delete old VIP resources # NOTE(jamespage): Delete old VIP resources
# Old style naming encoding iface in name # Old style naming encoding iface in name
@ -293,14 +309,15 @@ def update_hacluster_vip(service, relation_data):
# NOTE(jamespage): # NOTE(jamespage):
# Use option provided vip params if these where used # Use option provided vip params if these where used
# instead of auto-detected values # instead of auto-detected values
if fallback_params: if fallback:
relation_data['resource_params'][vip_key] = ( relation_data['resource_params'][vip_key] = (
'params {ip}="{vip}" cidr_netmask="{netmask}" ' 'params {ip}="{vip}" cidr_netmask="{netmask}" '
'nic="{iface}"'.format(ip=vip_params, 'nic="{iface}" {vip_monitoring}'.format(
vip=vip, ip=vip_params,
iface=iface, vip=vip,
netmask=netmask) iface=iface,
) netmask=netmask,
vip_monitoring=vip_monitoring))
else: else:
# NOTE(jamespage): # NOTE(jamespage):
# let heartbeat figure out which interface and # let heartbeat figure out which interface and
@ -308,15 +325,24 @@ def update_hacluster_vip(service, relation_data):
# when network interface naming is not # when network interface naming is not
# consistent across units. # consistent across units.
relation_data['resource_params'][vip_key] = ( relation_data['resource_params'][vip_key] = (
'params {ip}="{vip}"'.format(ip=vip_params, 'params {ip}="{vip}" {vip_monitoring}'.format(
vip=vip)) ip=vip_params,
vip=vip,
vip_monitoring=vip_monitoring))
vip_group.append(vip_key) vip_group.append(vip_key)
if vips_to_delete: if vips_to_delete:
relation_data['delete_resources'] = vips_to_delete try:
relation_data['delete_resources'].extend(vips_to_delete)
except KeyError:
relation_data['delete_resources'] = vips_to_delete
if len(vip_group) >= 1: if len(vip_group) >= 1:
relation_data['groups'] = { key = VIP_GROUP_NAME.format(service=service)
'grp_{}_vips'.format(service): ' '.join(vip_group) try:
} relation_data['groups'][key] = ' '.join(vip_group)
except KeyError:
relation_data['groups'] = {
key: ' '.join(vip_group)
}

View File

@ -118,6 +118,7 @@ OPENSTACK_RELEASES = (
'pike', 'pike',
'queens', 'queens',
'rocky', 'rocky',
'stein',
) )
UBUNTU_OPENSTACK_RELEASE = OrderedDict([ UBUNTU_OPENSTACK_RELEASE = OrderedDict([
@ -136,6 +137,7 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([
('artful', 'pike'), ('artful', 'pike'),
('bionic', 'queens'), ('bionic', 'queens'),
('cosmic', 'rocky'), ('cosmic', 'rocky'),
('disco', 'stein'),
]) ])
@ -155,6 +157,7 @@ OPENSTACK_CODENAMES = OrderedDict([
('2017.2', 'pike'), ('2017.2', 'pike'),
('2018.1', 'queens'), ('2018.1', 'queens'),
('2018.2', 'rocky'), ('2018.2', 'rocky'),
('2019.1', 'stein'),
]) ])
# The ugly duckling - must list releases oldest to newest # The ugly duckling - must list releases oldest to newest
@ -189,6 +192,8 @@ SWIFT_CODENAMES = OrderedDict([
['2.16.0', '2.17.0']), ['2.16.0', '2.17.0']),
('rocky', ('rocky',
['2.18.0', '2.19.0']), ['2.18.0', '2.19.0']),
('stein',
['2.19.0']),
]) ])
# >= Liberty version->codename mapping # >= Liberty version->codename mapping
@ -201,6 +206,7 @@ PACKAGE_CODENAMES = {
('16', 'pike'), ('16', 'pike'),
('17', 'queens'), ('17', 'queens'),
('18', 'rocky'), ('18', 'rocky'),
('19', 'stein'),
]), ]),
'neutron-common': OrderedDict([ 'neutron-common': OrderedDict([
('7', 'liberty'), ('7', 'liberty'),
@ -210,6 +216,7 @@ PACKAGE_CODENAMES = {
('11', 'pike'), ('11', 'pike'),
('12', 'queens'), ('12', 'queens'),
('13', 'rocky'), ('13', 'rocky'),
('14', 'stein'),
]), ]),
'cinder-common': OrderedDict([ 'cinder-common': OrderedDict([
('7', 'liberty'), ('7', 'liberty'),
@ -219,6 +226,7 @@ PACKAGE_CODENAMES = {
('11', 'pike'), ('11', 'pike'),
('12', 'queens'), ('12', 'queens'),
('13', 'rocky'), ('13', 'rocky'),
('14', 'stein'),
]), ]),
'keystone': OrderedDict([ 'keystone': OrderedDict([
('8', 'liberty'), ('8', 'liberty'),
@ -228,6 +236,7 @@ PACKAGE_CODENAMES = {
('12', 'pike'), ('12', 'pike'),
('13', 'queens'), ('13', 'queens'),
('14', 'rocky'), ('14', 'rocky'),
('15', 'stein'),
]), ]),
'horizon-common': OrderedDict([ 'horizon-common': OrderedDict([
('8', 'liberty'), ('8', 'liberty'),
@ -237,6 +246,7 @@ PACKAGE_CODENAMES = {
('12', 'pike'), ('12', 'pike'),
('13', 'queens'), ('13', 'queens'),
('14', 'rocky'), ('14', 'rocky'),
('15', 'stein'),
]), ]),
'ceilometer-common': OrderedDict([ 'ceilometer-common': OrderedDict([
('5', 'liberty'), ('5', 'liberty'),
@ -246,6 +256,7 @@ PACKAGE_CODENAMES = {
('9', 'pike'), ('9', 'pike'),
('10', 'queens'), ('10', 'queens'),
('11', 'rocky'), ('11', 'rocky'),
('12', 'stein'),
]), ]),
'heat-common': OrderedDict([ 'heat-common': OrderedDict([
('5', 'liberty'), ('5', 'liberty'),
@ -255,6 +266,7 @@ PACKAGE_CODENAMES = {
('9', 'pike'), ('9', 'pike'),
('10', 'queens'), ('10', 'queens'),
('11', 'rocky'), ('11', 'rocky'),
('12', 'stein'),
]), ]),
'glance-common': OrderedDict([ 'glance-common': OrderedDict([
('11', 'liberty'), ('11', 'liberty'),
@ -264,6 +276,7 @@ PACKAGE_CODENAMES = {
('15', 'pike'), ('15', 'pike'),
('16', 'queens'), ('16', 'queens'),
('17', 'rocky'), ('17', 'rocky'),
('18', 'stein'),
]), ]),
'openstack-dashboard': OrderedDict([ 'openstack-dashboard': OrderedDict([
('8', 'liberty'), ('8', 'liberty'),
@ -273,6 +286,7 @@ PACKAGE_CODENAMES = {
('12', 'pike'), ('12', 'pike'),
('13', 'queens'), ('13', 'queens'),
('14', 'rocky'), ('14', 'rocky'),
('15', 'stein'),
]), ]),
} }

View File

@ -166,6 +166,14 @@ CLOUD_ARCHIVE_POCKETS = {
'rocky/proposed': 'bionic-proposed/rocky', 'rocky/proposed': 'bionic-proposed/rocky',
'bionic-rocky/proposed': 'bionic-proposed/rocky', 'bionic-rocky/proposed': 'bionic-proposed/rocky',
'bionic-proposed/rocky': 'bionic-proposed/rocky', 'bionic-proposed/rocky': 'bionic-proposed/rocky',
# Stein
'stein': 'bionic-updates/stein',
'bionic-stein': 'bionic-updates/stein',
'bionic-stein/updates': 'bionic-updates/stein',
'bionic-updates/stein': 'bionic-updates/stein',
'stein/proposed': 'bionic-proposed/stein',
'bionic-stein/proposed': 'bionic-proposed/stein',
'bionic-proposed/stein': 'bionic-proposed/stein',
} }