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: I327a686a35edf9b6ff5c1c3cbc4165f8faeef688
This commit is contained in:
James Page 2017-12-21 11:43:50 +00:00
parent 7ae5ab6a28
commit 7b9feea400
7 changed files with 3 additions and 83 deletions

View File

@ -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()

View File

@ -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

View File

@ -1 +0,0 @@
nova_compute_hooks.py

View File

@ -1 +0,0 @@
nova_compute_hooks.py

View File

@ -1 +0,0 @@
nova_compute_hooks.py

View File

@ -26,8 +26,6 @@ extra-bindings:
requires:
shared-db:
interface: mysql-shared
pgsql-db:
interface: pgsql
amqp:
interface: rabbitmq
image-service:

View File

@ -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()