Skip to content

Commit

Permalink
Merge pull request openstack-charmers#87 from gnuoy/issue/81
Browse files Browse the repository at this point in the history
dist upgrade before series upgrade
  • Loading branch information
ryan-beisner committed Oct 10, 2019
2 parents 7c5e26d + 7fd66a7 commit ebc28e6
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def series_upgrade(unit_name, machine_num,
logging.info("Series upgrade {}".format(unit_name))
application = unit_name.split('/')[0]
set_dpkg_non_interactive_on_unit(unit_name)
dist_upgrade(unit_name)
logging.info("Prepare series upgrade on {}".format(machine_num))
model.prepare_series_upgrade(machine_num, to_series=to_series)
logging.info("Waiting for workload status 'blocked' on {}"
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 ebc28e6

Please sign in to comment.