Skip to content

Commit

Permalink
dist upgrade before series upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Young committed Oct 10, 2019
1 parent 1512bcd commit 0080d84
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions unit_tests/utilities/test_zaza_utilities_generic.py
Expand Up @@ -166,6 +166,17 @@ def test_get_yaml_config(self):
_yaml_dict)
self._open.assert_called_once_with(_filename, "r")

def test_dist_upgrade(self):
_unit = "app/2"
generic_utils.dist_upgrade(_unit)
dist_upgrade_cmd = (
"""sudo DEBIAN_FRONTEND=noninteractive apt --assume-yes """
"""-o "Dpkg::Options::=--force-confdef" """
"""-o "Dpkg::Options::=--force-confold" dist-upgrade""")
self.model.run_on_unit.assert_has_calls([
mock.call(_unit, 'sudo apt update'),
mock.call(_unit, dist_upgrade_cmd)])

def test_do_release_upgrade(self):
_unit = "app/2"
generic_utils.do_release_upgrade(_unit)
Expand Down
21 changes: 21 additions & 0 deletions zaza/openstack/utilities/generic.py
Expand Up @@ -374,6 +374,7 @@ def series_upgrade(unit_name, machine_num,
model.block_until_unit_wl_status(unit_name, "blocked")
logging.info("Waiting for model idleness")
model.block_until_all_units_idle()
dist_upgrade(unit_name)
wrap_do_release_upgrade(unit_name, from_series=from_series,
to_series=to_series, files=files,
workaround_script=workaround_script)
Expand Down Expand Up @@ -481,6 +482,26 @@ def run_via_ssh(unit_name, cmd):
logging.warn(e)


def dist_upgrade(unit_name):
"""Run dist-upgrade on unit after update package db.
:param unit_name: Unit Name
:type unit_name: str
:returns: None
:rtype: None
"""
logging.info('Updating package db ' + unit_name)
update_cmd = 'sudo apt update'
model.run_on_unit(unit_name, update_cmd)

logging.info('Updating existing packages ' + unit_name)
dist_upgrade_cmd = (
"""sudo DEBIAN_FRONTEND=noninteractive apt --assume-yes """
"""-o "Dpkg::Options::=--force-confdef" """
"""-o "Dpkg::Options::=--force-confold" dist-upgrade""")
model.run_on_unit(unit_name, dist_upgrade_cmd)


def do_release_upgrade(unit_name):
"""Run do-release-upgrade noninteractive.
Expand Down

0 comments on commit 0080d84

Please sign in to comment.