[hopem,r=wolsen,gnuoy]

Ensure apache2 reloaded/restarted when https configured

Closes-Bug: #1410568
This commit is contained in:
Edward Hope-Morley 2015-03-31 09:37:26 +01:00
commit 3b54638cd0
2 changed files with 27 additions and 14 deletions

View File

@ -1,10 +1,11 @@
#!/usr/bin/python
from subprocess import (
check_call,
call
)
import sys
from subprocess import (
call,
check_call,
)
from glance_utils import (
do_openstack_upgrade,
migrate_database,
@ -41,6 +42,7 @@ from charmhelpers.core.hookenv import (
)
from charmhelpers.core.host import (
restart_on_change,
service_reload,
service_stop,
)
from charmhelpers.fetch import (
@ -164,7 +166,8 @@ def db_changed():
status = call(['glance-manage', 'db_version'])
if status != 0:
juju_log('Setting version_control to 0')
check_call(["glance-manage", "version_control", "0"])
cmd = ["glance-manage", "version_control", "0"]
check_call(cmd)
juju_log('Cluster leader, performing db sync')
migrate_database()
@ -189,7 +192,8 @@ def pgsql_db_changed():
status = call(['glance-manage', 'db_version'])
if status != 0:
juju_log('Setting version_control to 0')
check_call(["glance-manage", "version_control", "0"])
cmd = ["glance-manage", "version_control", "0"]
check_call(cmd)
juju_log('Cluster leader, performing db sync')
migrate_database()
@ -462,6 +466,10 @@ def configure_https():
cmd = ['a2dissite', 'openstack_https_frontend']
check_call(cmd)
# TODO: improve this by checking if local CN certs are available
# first then checking reload status (see LP #1433114).
service_reload('apache2', restart_on_failure=True)
for r_id in relation_ids('identity-service'):
keystone_joined(relation_id=r_id)
for r_id in relation_ids('image-service'):

View File

@ -38,6 +38,7 @@ TO_PATCH = [
'apt_install',
'apt_update',
'restart_on_change',
'service_reload',
'service_stop',
# charmhelpers.contrib.openstack.utils
'configure_installation_source',
@ -604,8 +605,9 @@ class GlanceRelationTests(CharmTestCase):
configs.write = MagicMock()
self.relation_ids.return_value = ['identity-service:0']
relations.configure_https()
cmd = ['a2ensite', 'openstack_https_frontend']
self.check_call.assert_called_with(cmd)
calls = [call('a2dissite', 'openstack_https_frontend'),
call('service', 'apache2', 'reload')]
self.check_call.assert_called_has_calls(calls)
keystone_joined.assert_called_with(relation_id='identity-service:0')
@patch.object(relations, 'keystone_joined')
@ -617,8 +619,9 @@ class GlanceRelationTests(CharmTestCase):
configs.write = MagicMock()
self.relation_ids.return_value = ['identity-service:0']
relations.configure_https()
cmd = ['a2dissite', 'openstack_https_frontend']
self.check_call.assert_called_with(cmd)
calls = [call('a2dissite', 'openstack_https_frontend'),
call('service', 'apache2', 'reload')]
self.check_call.assert_called_has_calls(calls)
keystone_joined.assert_called_with(relation_id='identity-service:0')
@patch.object(relations, 'image_service_joined')
@ -630,8 +633,9 @@ class GlanceRelationTests(CharmTestCase):
configs.write = MagicMock()
self.relation_ids.return_value = ['image-service:0']
relations.configure_https()
cmd = ['a2ensite', 'openstack_https_frontend']
self.check_call.assert_called_with(cmd)
calls = [call('a2dissite', 'openstack_https_frontend'),
call('service', 'apache2', 'reload')]
self.check_call.assert_called_has_calls(calls)
image_service_joined.assert_called_with(relation_id='image-service:0')
@patch.object(relations, 'image_service_joined')
@ -643,8 +647,9 @@ class GlanceRelationTests(CharmTestCase):
configs.write = MagicMock()
self.relation_ids.return_value = ['image-service:0']
relations.configure_https()
cmd = ['a2dissite', 'openstack_https_frontend']
self.check_call.assert_called_with(cmd)
calls = [call('a2dissite', 'openstack_https_frontend'),
call('service', 'apache2', 'reload')]
self.check_call.assert_called_has_calls(calls)
image_service_joined.assert_called_with(relation_id='image-service:0')
def test_amqp_joined(self):