From 3facb32aff05f4b3048d1ac6c951e345aa80ecf5 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 15 May 2017 12:42:05 +0200 Subject: [PATCH] Correctly quote all MySQL syntax Resync charm-helpers to ensure that MySQL syntax is correctly quoted with single quotes, supporting use of the db-{admin} relation with services containing a dash. Change-Id: I859133263a8200e82e73d74837bcb91a18b3e0ff Closes-Bug: 1675220 --- charmhelpers/contrib/database/mysql.py | 4 +- charmhelpers/contrib/openstack/utils.py | 39 +++++++++++++++++++ charmhelpers/core/host_factory/ubuntu.py | 1 + charmhelpers/fetch/ubuntu.py | 16 ++++++++ .../contrib/openstack/amulet/deployment.py | 6 ++- 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/charmhelpers/contrib/database/mysql.py b/charmhelpers/contrib/database/mysql.py index 8aac183..3f91237 100644 --- a/charmhelpers/contrib/database/mysql.py +++ b/charmhelpers/contrib/database/mysql.py @@ -89,7 +89,7 @@ class MySQLHelper(object): def create_database(self, db_name): cursor = self.connection.cursor() try: - cursor.execute("CREATE DATABASE {} CHARACTER SET UTF8" + cursor.execute("CREATE DATABASE `{}` CHARACTER SET UTF8" .format(db_name)) finally: cursor.close() @@ -114,7 +114,7 @@ class MySQLHelper(object): cursor = self.connection.cursor() try: # TODO: review for different grants - cursor.execute("GRANT ALL PRIVILEGES ON {}.* TO '{}'@'{}' " + cursor.execute("GRANT ALL PRIVILEGES ON `{}`.* TO '{}'@'{}' " "IDENTIFIED BY '{}'".format(db_name, db_user, remote_ip, diff --git a/charmhelpers/contrib/openstack/utils.py b/charmhelpers/contrib/openstack/utils.py index e13450c..161c786 100644 --- a/charmhelpers/contrib/openstack/utils.py +++ b/charmhelpers/contrib/openstack/utils.py @@ -111,6 +111,8 @@ OPENSTACK_RELEASES = ( 'newton', 'ocata', 'pike', + 'queens', + 'rocky', ) UBUNTU_OPENSTACK_RELEASE = OrderedDict([ @@ -126,6 +128,7 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([ ('xenial', 'mitaka'), ('yakkety', 'newton'), ('zesty', 'ocata'), + ('artful', 'pike'), ]) @@ -142,6 +145,7 @@ OPENSTACK_CODENAMES = OrderedDict([ ('2016.1', 'mitaka'), ('2016.2', 'newton'), ('2017.1', 'ocata'), + ('2017.2', 'pike'), ]) # The ugly duckling - must list releases oldest to newest @@ -170,6 +174,8 @@ SWIFT_CODENAMES = OrderedDict([ ['2.8.0', '2.9.0', '2.10.0']), ('ocata', ['2.11.0', '2.12.0', '2.13.0']), + ('pike', + ['2.13.0']), ]) # >= Liberty version->codename mapping @@ -179,54 +185,81 @@ PACKAGE_CODENAMES = { ('13', 'mitaka'), ('14', 'newton'), ('15', 'ocata'), + ('16', 'pike'), + ('17', 'queens'), + ('18', 'rocky'), ]), 'neutron-common': OrderedDict([ ('7', 'liberty'), ('8', 'mitaka'), ('9', 'newton'), ('10', 'ocata'), + ('11', 'pike'), + ('12', 'queens'), + ('13', 'rocky'), ]), 'cinder-common': OrderedDict([ ('7', 'liberty'), ('8', 'mitaka'), ('9', 'newton'), ('10', 'ocata'), + ('11', 'pike'), + ('12', 'queens'), + ('13', 'rocky'), ]), 'keystone': OrderedDict([ ('8', 'liberty'), ('9', 'mitaka'), ('10', 'newton'), ('11', 'ocata'), + ('12', 'pike'), + ('13', 'queens'), + ('14', 'rocky'), ]), 'horizon-common': OrderedDict([ ('8', 'liberty'), ('9', 'mitaka'), ('10', 'newton'), ('11', 'ocata'), + ('12', 'pike'), + ('13', 'queens'), + ('14', 'rocky'), ]), 'ceilometer-common': OrderedDict([ ('5', 'liberty'), ('6', 'mitaka'), ('7', 'newton'), ('8', 'ocata'), + ('9', 'pike'), + ('10', 'queens'), + ('11', 'rocky'), ]), 'heat-common': OrderedDict([ ('5', 'liberty'), ('6', 'mitaka'), ('7', 'newton'), ('8', 'ocata'), + ('9', 'pike'), + ('10', 'queens'), + ('11', 'rocky'), ]), 'glance-common': OrderedDict([ ('11', 'liberty'), ('12', 'mitaka'), ('13', 'newton'), ('14', 'ocata'), + ('15', 'pike'), + ('16', 'queens'), + ('17', 'rocky'), ]), 'openstack-dashboard': OrderedDict([ ('8', 'liberty'), ('9', 'mitaka'), ('10', 'newton'), ('11', 'ocata'), + ('12', 'pike'), + ('13', 'queens'), + ('14', 'rocky'), ]), } @@ -579,6 +612,12 @@ def configure_installation_source(rel): 'ocata': 'xenial-updates/ocata', 'ocata/updates': 'xenial-updates/ocata', 'ocata/proposed': 'xenial-proposed/ocata', + 'pike': 'xenial-updates/pike', + 'pike/updates': 'xenial-updates/pike', + 'pike/proposed': 'xenial-proposed/pike', + 'queens': 'xenial-updates/queens', + 'queens/updates': 'xenial-updates/queens', + 'queens/proposed': 'xenial-proposed/queens', } try: diff --git a/charmhelpers/core/host_factory/ubuntu.py b/charmhelpers/core/host_factory/ubuntu.py index 0448288..d8dc378 100644 --- a/charmhelpers/core/host_factory/ubuntu.py +++ b/charmhelpers/core/host_factory/ubuntu.py @@ -19,6 +19,7 @@ UBUNTU_RELEASES = ( 'xenial', 'yakkety', 'zesty', + 'artful', ) diff --git a/charmhelpers/fetch/ubuntu.py b/charmhelpers/fetch/ubuntu.py index 82ac80f..7bc6cc7 100644 --- a/charmhelpers/fetch/ubuntu.py +++ b/charmhelpers/fetch/ubuntu.py @@ -113,6 +113,22 @@ CLOUD_ARCHIVE_POCKETS = { 'ocata/proposed': 'xenial-proposed/ocata', 'xenial-ocata/proposed': 'xenial-proposed/ocata', 'xenial-ocata/newton': 'xenial-proposed/ocata', + # Pike + 'pike': 'xenial-updates/pike', + 'xenial-pike': 'xenial-updates/pike', + 'xenial-pike/updates': 'xenial-updates/pike', + 'xenial-updates/pike': 'xenial-updates/pike', + 'pike/proposed': 'xenial-proposed/pike', + 'xenial-pike/proposed': 'xenial-proposed/pike', + 'xenial-pike/newton': 'xenial-proposed/pike', + # Queens + 'queens': 'xenial-updates/queens', + 'xenial-queens': 'xenial-updates/queens', + 'xenial-queens/updates': 'xenial-updates/queens', + 'xenial-updates/queens': 'xenial-updates/queens', + 'queens/proposed': 'xenial-proposed/queens', + 'xenial-queens/proposed': 'xenial-proposed/queens', + 'xenial-queens/newton': 'xenial-proposed/queens', } APT_NO_LOCK = 100 # The return code for "couldn't acquire lock" in APT. diff --git a/tests/charmhelpers/contrib/openstack/amulet/deployment.py b/tests/charmhelpers/contrib/openstack/amulet/deployment.py index 5c1ce45..5c041d2 100644 --- a/tests/charmhelpers/contrib/openstack/amulet/deployment.py +++ b/tests/charmhelpers/contrib/openstack/amulet/deployment.py @@ -262,7 +262,8 @@ class OpenStackAmuletDeployment(AmuletDeployment): # Must be ordered by OpenStack release (not by Ubuntu release): (self.trusty_icehouse, self.trusty_kilo, self.trusty_liberty, self.trusty_mitaka, self.xenial_mitaka, self.xenial_newton, - self.yakkety_newton, self.xenial_ocata, self.zesty_ocata) = range(9) + self.yakkety_newton, self.xenial_ocata, self.zesty_ocata, + self.xenial_pike, self.artful_pike) = range(11) releases = { ('trusty', None): self.trusty_icehouse, @@ -272,8 +273,10 @@ class OpenStackAmuletDeployment(AmuletDeployment): ('xenial', None): self.xenial_mitaka, ('xenial', 'cloud:xenial-newton'): self.xenial_newton, ('xenial', 'cloud:xenial-ocata'): self.xenial_ocata, + ('xenial', 'cloud:xenial-pike'): self.xenial_pike, ('yakkety', None): self.yakkety_newton, ('zesty', None): self.zesty_ocata, + ('artful', None): self.artful_pike, } return releases[(self.series, self.openstack)] @@ -287,6 +290,7 @@ class OpenStackAmuletDeployment(AmuletDeployment): ('xenial', 'mitaka'), ('yakkety', 'newton'), ('zesty', 'ocata'), + ('artful', 'pike'), ]) if self.openstack: os_origin = self.openstack.split(':')[1]