diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index fd70129c..25a88963 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -28,7 +28,6 @@ from charmhelpers.core.hookenv import ( config, is_relation_made, log, - ERROR, relation_ids, remote_service_name, related_units, @@ -248,32 +247,12 @@ def amqp_changed(): @hooks.hook('shared-db-relation-joined') def db_joined(rid=None): - 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) - relation_set(relation_id=rid, nova_database=config('database'), nova_username=config('database-user'), nova_hostname=get_relation_ip('shared-db')) -@hooks.hook('pgsql-db-relation-joined') -def pgsql_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'), - 'private-address': get_relation_ip('psql-db')}) - - @hooks.hook('shared-db-relation-changed') @restart_on_change(restart_map()) def db_changed(): @@ -283,15 +262,6 @@ def db_changed(): CONFIGS.write(NOVA_CONF) -@hooks.hook('pgsql-db-relation-changed') -@restart_on_change(restart_map()) -def postgresql_db_changed(): - if 'pgsql-db' not in CONFIGS.complete_contexts(): - log('pgsql-db relation incomplete. Peer not ready?') - return - CONFIGS.write(NOVA_CONF) - - @hooks.hook('image-service-relation-changed') @restart_on_change(restart_map()) def image_service_changed(): @@ -421,8 +391,7 @@ def ceph_broken(): @hooks.hook('amqp-relation-broken', 'image-service-relation-broken', - 'shared-db-relation-broken', - 'pgsql-db-relation-broken') + 'shared-db-relation-broken') @restart_on_change(restart_map()) def relation_broken(): CONFIGS.write_all() diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index 5288c4e6..fcccb50f 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -207,7 +207,6 @@ BASE_RESOURCE_MAP = { 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR), context.SharedDBContext( relation_prefix='nova', ssl_dir=NOVA_CONF_DIR), - context.PostgresqlDBContext(), context.ImageServiceContext(), context.OSConfigFlagContext(), CloudComputeContext(), @@ -960,8 +959,8 @@ def get_optional_relations(): optional_interfaces['storage-backend'] = ['ceph'] if relation_ids('neutron-plugin'): optional_interfaces['neutron-plugin'] = ['neutron-plugin'] - if relation_ids('shared-db') or relation_ids('pgsql-db'): - optional_interfaces['database'] = ['shared-db', 'pgsql-db'] + if relation_ids('shared-db'): + optional_interfaces['database'] = ['shared-db'] return optional_interfaces diff --git a/hooks/pgsql-db-relation-broken b/hooks/pgsql-db-relation-broken deleted file mode 120000 index 3ba0bdea..00000000 --- a/hooks/pgsql-db-relation-broken +++ /dev/null @@ -1 +0,0 @@ -nova_compute_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 3ba0bdea..00000000 --- a/hooks/pgsql-db-relation-changed +++ /dev/null @@ -1 +0,0 @@ -nova_compute_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 3ba0bdea..00000000 --- a/hooks/pgsql-db-relation-joined +++ /dev/null @@ -1 +0,0 @@ -nova_compute_hooks.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index 8f222644..93a2b3ee 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -26,8 +26,6 @@ extra-bindings: requires: shared-db: interface: mysql-shared - pgsql-db: - interface: pgsql amqp: interface: rabbitmq image-service: diff --git a/unit_tests/test_nova_compute_hooks.py b/unit_tests/test_nova_compute_hooks.py index a7ced95f..93afb326 100644 --- a/unit_tests/test_nova_compute_hooks.py +++ b/unit_tests/test_nova_compute_hooks.py @@ -368,28 +368,6 @@ class NovaComputeRelationsTests(CharmTestCase): nova_hostname='10.0.0.50') self.get_relation_ip.assert_called_with('shared-db') - def test_postgresql_db_joined(self): - self.is_relation_made.return_value = False - hooks.pgsql_db_joined() - self.relation_set.assert_called_with(**{ - 'database': 'nova', 'private-address': '10.0.0.50'}) - - def test_db_joined_with_postgresql(self): - self.is_relation_made.return_value = True - - msg = ('Attempting to associate a mysql database when there is ' - 'already associated a postgresql one') - - with self.assertRaisesRegexp(Exception, msg): - hooks.db_joined() - - def test_postgresql_joined_with_db(self): - self.is_relation_made.return_value = True - msg = ('Attempting to associate a postgresql database when there is ' - 'already associated a mysql one') - with self.assertRaisesRegexp(Exception, msg): - hooks.pgsql_db_joined() - @patch.object(hooks, 'CONFIGS') def test_db_changed_missing_relation_data(self, configs): configs.complete_contexts = MagicMock() @@ -399,39 +377,18 @@ class NovaComputeRelationsTests(CharmTestCase): 'shared-db relation incomplete. Peer not ready?' ) - @patch.object(hooks, 'CONFIGS') - def test_postgresql_db_changed_missing_relation_data(self, configs): - configs.complete_contexts = MagicMock() - configs.complete_contexts.return_value = [] - hooks.postgresql_db_changed() - self.log.assert_called_with( - 'pgsql-db relation incomplete. Peer not ready?' - ) - def _shared_db_test(self, configs): configs.complete_contexts = MagicMock() configs.complete_contexts.return_value = ['shared-db'] configs.write = MagicMock() hooks.db_changed() - def _postgresql_db_test(self, configs): - configs.complete_contexts = MagicMock() - configs.complete_contexts.return_value = ['pgsql-db'] - configs.write = MagicMock() - hooks.postgresql_db_changed() - @patch.object(hooks, 'CONFIGS') def test_db_changed_with_data(self, configs): self._shared_db_test(configs) self.assertEqual([call('/etc/nova/nova.conf')], configs.write.call_args_list) - @patch.object(hooks, 'CONFIGS') - def test_postgresql_db_changed_with_data(self, configs): - self._postgresql_db_test(configs) - self.assertEqual([call('/etc/nova/nova.conf')], - configs.write.call_args_list) - @patch.object(hooks, 'CONFIGS') def test_image_service_missing_relation_data(self, configs): configs.complete_contexts = MagicMock()