Add do_openstack_upgrade().
This commit is contained in:
parent
a9fb83be8a
commit
5740434491
hooks
unit_tests
@ -62,6 +62,7 @@ def error_out(msg):
|
||||
|
||||
def get_os_codename_install_source(src):
|
||||
'''Derive OpenStack release codename from a given installation source.'''
|
||||
import ipdb; ipdb.set_trace() ############################## Breakpoint ##############################
|
||||
ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
|
||||
rel = ''
|
||||
if src == 'distro':
|
||||
|
@ -17,8 +17,11 @@ from swift_storage_context import (
|
||||
)
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
apt_install,
|
||||
apt_update,
|
||||
mkdir,
|
||||
mount,
|
||||
service_restart,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
@ -32,7 +35,9 @@ from charmhelpers.contrib.storage.linux.utils import (
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
configure_installation_source,
|
||||
get_host_ip,
|
||||
get_os_codename_install_source,
|
||||
get_os_codename_package,
|
||||
save_script_rc as _save_script_rc,
|
||||
)
|
||||
@ -112,7 +117,21 @@ def swift_init(target, action, fatal=False):
|
||||
|
||||
|
||||
def do_openstack_upgrade(configs):
|
||||
pass
|
||||
new_src = config('openstack-origin')
|
||||
new_os_rel = get_os_codename_install_source(new_src)
|
||||
|
||||
log('Performing OpenStack upgrade to %s.' % (new_os_rel))
|
||||
configure_installation_source(new_src)
|
||||
dpkg_opts = [
|
||||
'--option', 'Dpkg::Options::=--force-confnew',
|
||||
'--option', 'Dpkg::Options::=--force-confdef',
|
||||
]
|
||||
apt_update()
|
||||
apt_install(packages=PACKAGES, options=dpkg_opts, fatal=True)
|
||||
configs.set_release(openstack_release=new_os_rel)
|
||||
configs.write_all()
|
||||
[service_restart(svc) for svc in
|
||||
(ACCOUNT_SVCS + CONTAINER_SVCS + OBJECT_SVCS)]
|
||||
|
||||
|
||||
def find_block_devices():
|
||||
|
@ -6,8 +6,11 @@ import hooks.swift_storage_utils as swift_utils
|
||||
|
||||
|
||||
TO_PATCH = [
|
||||
'apt_update',
|
||||
'apt_install',
|
||||
'log',
|
||||
'config',
|
||||
'configure_installation_source',
|
||||
'mkdir',
|
||||
'mount',
|
||||
'check_call',
|
||||
@ -16,7 +19,9 @@ TO_PATCH = [
|
||||
'clean_storage',
|
||||
'is_block_device',
|
||||
'get_os_codename_package',
|
||||
'get_os_codename_install_source',
|
||||
'get_host_ip',
|
||||
'service_restart',
|
||||
'_save_script_rc',
|
||||
]
|
||||
|
||||
@ -198,3 +203,25 @@ class SwiftStorageUtilsTests(CharmTestCase):
|
||||
call('/etc/swift/container-server.conf', ['swift_context'])
|
||||
]
|
||||
self.assertEquals(ex, configs.register.call_args_list)
|
||||
|
||||
def test_do_upgrade(self):
|
||||
self.test_config.set('openstack-origin', 'cloud:precise-grizzly')
|
||||
self.get_os_codename_install_source.return_value = 'grizzly'
|
||||
swift_utils.do_openstack_upgrade(MagicMock())
|
||||
self.configure_installation_source.assert_called_with(
|
||||
'cloud:precise-grizzly'
|
||||
)
|
||||
dpkg_opts = [
|
||||
'--option', 'Dpkg::Options::=--force-confnew',
|
||||
'--option', 'Dpkg::Options::=--force-confdef',
|
||||
]
|
||||
self.assertTrue(self.apt_update.called)
|
||||
self.apt_install.assert_called_with(
|
||||
packages=swift_utils.PACKAGES,
|
||||
options=dpkg_opts,
|
||||
fatal=True
|
||||
)
|
||||
services = (swift_utils.ACCOUNT_SVCS + swift_utils.CONTAINER_SVCS +
|
||||
swift_utils.OBJECT_SVCS)
|
||||
for service in services:
|
||||
self.assertIn(call(service), self.service_restart.call_args_list)
|
||||
|
Loading…
x
Reference in New Issue
Block a user