Series Upgrade
Implement the series-upgrade feature allowing to move between Ubuntu series. Change-Id: Iccffccec390495b72750fe1fac81d06c96fa7dd4
This commit is contained in:
parent
c6e5780f13
commit
2bfa6c0605
@ -1736,7 +1736,12 @@ def is_unit_upgrading_set():
|
|||||||
|
|
||||||
|
|
||||||
def series_upgrade_prepare(pause_unit_helper=None, configs=None):
|
def series_upgrade_prepare(pause_unit_helper=None, configs=None):
|
||||||
""" Run common series upgrade prepare tasks."""
|
""" Run common series upgrade prepare tasks.
|
||||||
|
|
||||||
|
:param pause_unit_helper: function: Function to pause unit
|
||||||
|
:param configs: OSConfigRenderer object: Configurations
|
||||||
|
:returns None:
|
||||||
|
"""
|
||||||
set_unit_upgrading()
|
set_unit_upgrading()
|
||||||
if pause_unit_helper and configs:
|
if pause_unit_helper and configs:
|
||||||
if not is_unit_paused_set():
|
if not is_unit_paused_set():
|
||||||
@ -1744,8 +1749,15 @@ def series_upgrade_prepare(pause_unit_helper=None, configs=None):
|
|||||||
|
|
||||||
|
|
||||||
def series_upgrade_complete(resume_unit_helper=None, configs=None):
|
def series_upgrade_complete(resume_unit_helper=None, configs=None):
|
||||||
""" Run common series upgrade complete tasks."""
|
""" Run common series upgrade complete tasks.
|
||||||
|
|
||||||
|
:param resume_unit_helper: function: Function to resume unit
|
||||||
|
:param configs: OSConfigRenderer object: Configurations
|
||||||
|
:returns None:
|
||||||
|
"""
|
||||||
clear_unit_paused()
|
clear_unit_paused()
|
||||||
clear_unit_upgrading()
|
clear_unit_upgrading()
|
||||||
if resume_unit_helper and configs:
|
if configs:
|
||||||
resume_unit_helper(configs)
|
configs.write_all()
|
||||||
|
if resume_unit_helper:
|
||||||
|
resume_unit_helper(configs)
|
||||||
|
@ -84,6 +84,7 @@ module = "charmhelpers.fetch.%s" % __platform__
|
|||||||
fetch = importlib.import_module(module)
|
fetch = importlib.import_module(module)
|
||||||
|
|
||||||
filter_installed_packages = fetch.filter_installed_packages
|
filter_installed_packages = fetch.filter_installed_packages
|
||||||
|
filter_missing_packages = fetch.filter_missing_packages
|
||||||
install = fetch.apt_install
|
install = fetch.apt_install
|
||||||
upgrade = fetch.apt_upgrade
|
upgrade = fetch.apt_upgrade
|
||||||
update = _fetch_update = fetch.apt_update
|
update = _fetch_update = fetch.apt_update
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from subprocess import check_call
|
from subprocess import STDOUT, check_output
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
BaseFetchHandler,
|
BaseFetchHandler,
|
||||||
UnhandledSource,
|
UnhandledSource,
|
||||||
@ -55,7 +55,7 @@ class BzrUrlFetchHandler(BaseFetchHandler):
|
|||||||
cmd = ['bzr', 'branch']
|
cmd = ['bzr', 'branch']
|
||||||
cmd += cmd_opts
|
cmd += cmd_opts
|
||||||
cmd += [source, dest]
|
cmd += [source, dest]
|
||||||
check_call(cmd)
|
check_output(cmd, stderr=STDOUT)
|
||||||
|
|
||||||
def install(self, source, dest=None, revno=None):
|
def install(self, source, dest=None, revno=None):
|
||||||
url_parts = self.parse_url(source)
|
url_parts = self.parse_url(source)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from subprocess import check_call, CalledProcessError
|
from subprocess import check_output, CalledProcessError, STDOUT
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
BaseFetchHandler,
|
BaseFetchHandler,
|
||||||
UnhandledSource,
|
UnhandledSource,
|
||||||
@ -50,7 +50,7 @@ class GitUrlFetchHandler(BaseFetchHandler):
|
|||||||
cmd = ['git', 'clone', source, dest, '--branch', branch]
|
cmd = ['git', 'clone', source, dest, '--branch', branch]
|
||||||
if depth:
|
if depth:
|
||||||
cmd.extend(['--depth', depth])
|
cmd.extend(['--depth', depth])
|
||||||
check_call(cmd)
|
check_output(cmd, stderr=STDOUT)
|
||||||
|
|
||||||
def install(self, source, branch="master", dest=None, depth=None):
|
def install(self, source, branch="master", dest=None, depth=None):
|
||||||
url_parts = self.parse_url(source)
|
url_parts = self.parse_url(source)
|
||||||
|
@ -189,6 +189,18 @@ def filter_installed_packages(packages):
|
|||||||
return _pkgs
|
return _pkgs
|
||||||
|
|
||||||
|
|
||||||
|
def filter_missing_packages(packages):
|
||||||
|
"""Return a list of packages that are installed.
|
||||||
|
|
||||||
|
:param packages: list of packages to evaluate.
|
||||||
|
:returns list: Packages that are installed.
|
||||||
|
"""
|
||||||
|
return list(
|
||||||
|
set(packages) -
|
||||||
|
set(filter_installed_packages(packages))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def apt_cache(in_memory=True, progress=None):
|
def apt_cache(in_memory=True, progress=None):
|
||||||
"""Build and return an apt cache."""
|
"""Build and return an apt cache."""
|
||||||
from apt import apt_pkg
|
from apt import apt_pkg
|
||||||
|
@ -20,6 +20,9 @@ from copy import deepcopy
|
|||||||
|
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
pausable_restart_on_change as restart_on_change,
|
pausable_restart_on_change as restart_on_change,
|
||||||
|
series_upgrade_prepare,
|
||||||
|
series_upgrade_complete,
|
||||||
|
is_unit_paused_set,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
@ -48,6 +51,8 @@ from neutron_ovs_utils import (
|
|||||||
purge_packages,
|
purge_packages,
|
||||||
assess_status,
|
assess_status,
|
||||||
install_tmpfilesd,
|
install_tmpfilesd,
|
||||||
|
pause_unit_helper,
|
||||||
|
resume_unit_helper,
|
||||||
)
|
)
|
||||||
|
|
||||||
hooks = Hooks()
|
hooks = Hooks()
|
||||||
@ -88,6 +93,12 @@ def upgrade_charm():
|
|||||||
@hooks.hook('config-changed')
|
@hooks.hook('config-changed')
|
||||||
@restart_on_change(restart_map())
|
@restart_on_change(restart_map())
|
||||||
def config_changed():
|
def config_changed():
|
||||||
|
# if we are paused, delay doing any config changed hooks.
|
||||||
|
# It is forced on the resume.
|
||||||
|
if is_unit_paused_set():
|
||||||
|
log("Unit is pause or upgrading. Skipping config_changed", "WARN")
|
||||||
|
return
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
install_tmpfilesd()
|
install_tmpfilesd()
|
||||||
|
|
||||||
@ -156,6 +167,20 @@ def restart_check():
|
|||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('pre-series-upgrade')
|
||||||
|
def pre_series_upgrade():
|
||||||
|
log("Running prepare series upgrade hook", "INFO")
|
||||||
|
series_upgrade_prepare(
|
||||||
|
pause_unit_helper, CONFIGS)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('post-series-upgrade')
|
||||||
|
def post_series_upgrade():
|
||||||
|
log("Running complete series upgrade hook", "INFO")
|
||||||
|
series_upgrade_complete(
|
||||||
|
resume_unit_helper, CONFIGS)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
hooks.execute(sys.argv)
|
hooks.execute(sys.argv)
|
||||||
|
1
hooks/post-series-upgrade
Symbolic link
1
hooks/post-series-upgrade
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
neutron_ovs_hooks.py
|
1
hooks/pre-series-upgrade
Symbolic link
1
hooks/pre-series-upgrade
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
neutron_ovs_hooks.py
|
Loading…
x
Reference in New Issue
Block a user