From 11bb8503d191ef9d74ee4d853df45da3a9e59607 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 21 Dec 2017 12:04:34 +0000 Subject: [PATCH] Drop postgresql support Remove postgresql DB support; This feature is untested as part of the charms, is not in use and was deprecated as part of the 1708 charms release. Change-Id: I5ebd4af9da38c03ca9952b8eed02fe5783692445 --- hooks/neutron_api_hooks.py | 33 +-------------------------- hooks/neutron_api_utils.py | 7 +----- hooks/pgsql-db-relation-broken | 1 - hooks/pgsql-db-relation-changed | 1 - hooks/pgsql-db-relation-joined | 1 - metadata.yaml | 2 -- unit_tests/test_neutron_api_hooks.py | 34 ---------------------------- 7 files changed, 2 insertions(+), 77 deletions(-) delete mode 120000 hooks/pgsql-db-relation-broken delete mode 120000 hooks/pgsql-db-relation-changed delete mode 120000 hooks/pgsql-db-relation-joined diff --git a/hooks/neutron_api_hooks.py b/hooks/neutron_api_hooks.py index e6ef5a85..e7573fae 100755 --- a/hooks/neutron_api_hooks.py +++ b/hooks/neutron_api_hooks.py @@ -24,7 +24,6 @@ from charmhelpers.core.hookenv import ( Hooks, UnregisteredHookError, config, - is_relation_made, local_unit, log, DEBUG, @@ -323,13 +322,6 @@ def amqp_changed(): @hooks.hook('shared-db-relation-joined') def db_joined(): - if is_relation_made('pgsql-db'): - # error, postgresql is used - e = ('Attempting to associate a mysql database when there is already ' - 'associated a postgresql one') - log(e, level=ERROR) - raise Exception(e) - if config('prefer-ipv6'): sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) @@ -348,18 +340,6 @@ def db_joined(): hostname=host) -@hooks.hook('pgsql-db-relation-joined') -def pgsql_neutron_db_joined(): - if is_relation_made('shared-db'): - # raise error - e = ('Attempting to associate a postgresql database' - ' when there is already associated a mysql one') - log(e, level=ERROR) - raise Exception(e) - - relation_set(database=config('database')) - - @hooks.hook('shared-db-relation-changed') @restart_on_change(restart_map()) def db_changed(): @@ -373,20 +353,9 @@ def db_changed(): neutron_plugin_api_subordinate_relation_joined(relid=r_id) -@hooks.hook('pgsql-db-relation-changed') -@restart_on_change(restart_map()) -def postgresql_neutron_db_changed(): - CONFIGS.write(NEUTRON_CONF) - conditional_neutron_migration() - - for r_id in relation_ids('neutron-plugin-api-subordinate'): - neutron_plugin_api_subordinate_relation_joined(relid=r_id) - - @hooks.hook('amqp-relation-broken', 'identity-service-relation-broken', - 'shared-db-relation-broken', - 'pgsql-db-relation-broken') + 'shared-db-relation-broken') def relation_broken(): CONFIGS.write_all() diff --git a/hooks/neutron_api_utils.py b/hooks/neutron_api_utils.py index 06a7166f..125a5902 100755 --- a/hooks/neutron_api_utils.py +++ b/hooks/neutron_api_utils.py @@ -182,7 +182,6 @@ BASE_RESOURCE_MAP = OrderedDict([ user=config('database-user'), database=config('database'), ssl_dir=NEUTRON_CONF_DIR), - context.PostgresqlDBContext(database=config('database')), neutron_api_context.IdentityServiceContext( service='neutron', service_user='neutron'), @@ -222,7 +221,7 @@ BASE_RESOURCE_MAP = OrderedDict([ # The interface is said to be satisfied if anyone of the interfaces in the # list has a complete context. REQUIRED_INTERFACES = { - 'database': ['shared-db', 'pgsql-db'], + 'database': ['shared-db'], 'messaging': ['amqp'], 'identity': ['identity-service'], } @@ -486,10 +485,6 @@ def resource_map(release=None): resource_map[conf]['contexts'].append( neutron_api_context.NeutronCCContext()) - # update for postgres - resource_map[conf]['contexts'].append( - context.PostgresqlDBContext(database=config('database'))) - if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and config('enable-sriov')): resource_map[ML2_SRIOV_INI] = {} diff --git a/hooks/pgsql-db-relation-broken b/hooks/pgsql-db-relation-broken deleted file mode 120000 index 1fb10fd5..00000000 --- a/hooks/pgsql-db-relation-broken +++ /dev/null @@ -1 +0,0 @@ -neutron_api_hooks.py \ No newline at end of file diff --git a/hooks/pgsql-db-relation-changed b/hooks/pgsql-db-relation-changed deleted file mode 120000 index 1fb10fd5..00000000 --- a/hooks/pgsql-db-relation-changed +++ /dev/null @@ -1 +0,0 @@ -neutron_api_hooks.py \ No newline at end of file diff --git a/hooks/pgsql-db-relation-joined b/hooks/pgsql-db-relation-joined deleted file mode 120000 index 1fb10fd5..00000000 --- a/hooks/pgsql-db-relation-joined +++ /dev/null @@ -1 +0,0 @@ -neutron_api_hooks.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index f65e6397..f7e99999 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -34,8 +34,6 @@ provides: requires: shared-db: interface: mysql-shared - pgsql-db: - interface: pgsql amqp: interface: rabbitmq identity-service: diff --git a/unit_tests/test_neutron_api_hooks.py b/unit_tests/test_neutron_api_hooks.py index 50c68e7c..a0008a68 100644 --- a/unit_tests/test_neutron_api_hooks.py +++ b/unit_tests/test_neutron_api_hooks.py @@ -69,7 +69,6 @@ TO_PATCH = [ 'is_clustered', 'is_elected_leader', 'is_qos_requested_and_valid', - 'is_relation_made', 'log', 'migrate_neutron_database', 'neutron_ready', @@ -339,7 +338,6 @@ class NeutronAPIHooksTests(CharmTestCase): self.assertTrue(self.CONFIGS.write.called_with(NEUTRON_CONF)) def test_db_joined(self): - self.is_relation_made.return_value = False self.get_relation_ip.return_value = '10.0.0.1' self._call_hook('shared-db-relation-joined') self.relation_set.assert_called_with( @@ -350,7 +348,6 @@ class NeutronAPIHooksTests(CharmTestCase): def test_db_joined_spaces(self): self.get_relation_ip.return_value = '192.168.20.1' - self.is_relation_made.return_value = False self.unit_get.return_value = 'myhostname' self._call_hook('shared-db-relation-joined') self.relation_set.assert_called_with( @@ -359,24 +356,6 @@ class NeutronAPIHooksTests(CharmTestCase): hostname='192.168.20.1', ) - def test_db_joined_with_postgresql(self): - self.is_relation_made.return_value = True - with self.assertRaises(Exception): - hooks.db_joined() - - def test_postgresql_db_joined(self): - self.unit_get.return_value = 'myhostname' - self.is_relation_made.return_value = False - self._call_hook('pgsql-db-relation-joined') - self.relation_set.assert_called_with( - database='neutron', - ) - - def test_postgresql_joined_with_db(self): - self.is_relation_made.return_value = True - with self.assertRaises(Exception): - hooks.pgsql_neutron_db_joined() - @patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined') @patch.object(hooks, 'conditional_neutron_migration') def test_shared_db_changed(self, cond_neutron_mig, plugin_joined): @@ -394,17 +373,6 @@ class NeutronAPIHooksTests(CharmTestCase): self._call_hook('shared-db-relation-changed') self.assertFalse(self.CONFIGS.write_all.called) - @patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined') - @patch.object(hooks, 'conditional_neutron_migration') - def test_pgsql_db_changed(self, cond_neutron_mig, plugin_joined): - self.relation_ids.return_value = ['neutron-plugin-api-subordinate:1'] - self._call_hook('pgsql-db-relation-changed') - self.assertTrue(self.CONFIGS.write.called) - cond_neutron_mig.assert_called_with() - self.relation_ids.assert_called_with('neutron-plugin-api-subordinate') - plugin_joined.assert_called_with( - relid='neutron-plugin-api-subordinate:1') - def test_amqp_broken(self): self._call_hook('amqp-relation-broken') self.assertTrue(self.CONFIGS.write_all.called) @@ -496,7 +464,6 @@ class NeutronAPIHooksTests(CharmTestCase): self.relation_ids.side_effect = self._fake_relids _canonical_url.return_value = host self.api_port.return_value = port - self.is_relation_made = False neutron_url = '%s:%s' % (host, port) _relation_data = { 'enable-sriov': False, @@ -528,7 +495,6 @@ class NeutronAPIHooksTests(CharmTestCase): _canonical_url.return_value = host self.api_port.return_value = port self.get_dns_domain.return_value = "" - self.is_relation_made = True neutron_url = '%s:%s' % (host, port) _relation_data = { 'enable-sriov': False,