Migrate heat database on upgrade and work around juno python-swiftclient upgrade issue.

This commit is contained in:
Corey Bryant 2015-09-22 19:53:18 +00:00
parent a1f2428e97
commit a77f97c13d
4 changed files with 22 additions and 6 deletions

View File

@ -12,8 +12,6 @@ import shutil
import subprocess
import sys
from subprocess import check_call
from charmhelpers.core.hookenv import (
Hooks,
UnregisteredHookError,
@ -52,6 +50,7 @@ from heat_utils import (
do_openstack_upgrade,
restart_map,
determine_packages,
migrate_database,
register_configs,
HEAT_CONF,
)
@ -123,7 +122,7 @@ def db_changed():
log('shared-db relation incomplete. Peer not ready?')
return
CONFIGS.write(HEAT_CONF)
check_call(['heat-manage', 'db_sync'])
migrate_database()
def configure_https():

View File

@ -7,6 +7,7 @@
import os
from collections import OrderedDict
from subprocess import check_call
from charmhelpers.contrib.openstack import context, templating
@ -37,6 +38,7 @@ TEMPLATES = 'templates/'
BASE_PACKAGES = [
'python-keystoneclient',
'python-swiftclient', # work-around missing epoch in juno heat package
'python-six',
'uuid',
'apache2',
@ -147,6 +149,8 @@ def do_openstack_upgrade(configs):
configs.set_release(openstack_release=new_os_rel)
configs.write_all()
migrate_database()
def restart_map():
"""Restarts on config change.
@ -165,3 +169,9 @@ def restart_map():
if svcs:
_map.append((f, svcs))
return OrderedDict(_map)
def migrate_database():
"""Runs heat-manage to initialize a new database or migrate existing"""
log('Migrating the heat database.')
check_call(['heat-manage', 'db_sync'])

View File

@ -37,9 +37,9 @@ TO_PATCH = [
'register_configs',
'do_openstack_upgrade',
# other
'check_call',
'execd_preinstall',
'log'
'log',
'migrate_database',
]
@ -99,6 +99,7 @@ class HeatRelationTests(CharmTestCase):
configs.complete_contexts.return_value = ['shared-db']
configs.write = MagicMock()
relations.db_changed()
self.assertTrue(self.migrate_database.called)
@patch.object(relations, 'CONFIGS')
def test_db_changed(self, configs):

View File

@ -18,7 +18,8 @@ TO_PATCH = [
'get_os_codename_install_source',
'configure_installation_source',
'apt_install',
'apt_update'
'apt_update',
'check_call',
]
@ -64,3 +65,8 @@ class HeatUtilsTests(CharmTestCase):
self.assertEquals(cfn, 8000)
cfn = utils.api_port('heat-api')
self.assertEquals(cfn, 8004)
def test_migrate_database(self):
utils.migrate_database()
self.assertTrue(self.log.called)
self.check_call.assert_called_with(['heat-manage', 'db_sync'])