def series_upgrade(unit_name, machine_num, from_series="trusty", to_series="xenial", origin='openstack-origin', files=None, workaround_script=None): """Perform series upgrade on a unit. :param unit_name: Unit Name :type unit_name: str :param machine_num: Machine number :type machine_num: str :param from_series: The series from which to upgrade :type from_series: str :param to_series: The series to which to upgrade :type to_series: str :param origin: The configuration setting variable name for changing origin source. (openstack-origin or source) :type origin: str :param files: Workaround files to scp to unit under upgrade :type files: list :param workaround_script: Workaround script to run during series upgrade :type workaround_script: str :returns: None :rtype: None """ logging.info("Series upgrade {}".format(unit_name)) application = unit_name.split('/')[0] set_dpkg_non_interactive_on_unit(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 {}" .format(unit_name)) model.block_until_unit_wl_status(unit_name, "blocked") logging.info("Waiting for model idleness") model.block_until_all_units_idle() wrap_do_release_upgrade(unit_name, from_series=from_series, to_series=to_series, files=files, workaround_script=workaround_script) logging.info("Reboot {}".format(unit_name)) reboot(unit_name) logging.info("Waiting for workload status 'blocked' on {}" .format(unit_name)) model.block_until_unit_wl_status(unit_name, "blocked") logging.info("Waiting for model idleness") model.block_until_all_units_idle() logging.info("Set origin on {}".format(application)) # Allow for charms which have neither source nor openstack-origin if origin: set_origin(application, origin) model.block_until_all_units_idle() logging.info("Complete series upgrade on {}".format(machine_num)) model.complete_series_upgrade(machine_num) model.block_until_all_units_idle() logging.info("Waiting for workload status 'active' on {}" .format(unit_name)) model.block_until_unit_wl_status(unit_name, "active") model.block_until_all_units_idle() # This step may be performed by juju in the future logging.info("Set series on {} to {}".format(application, to_series)) model.set_series(application, to_series)
def test_complete_series_upgrade(self): self.patch_object(model, 'get_juju_model', return_value=self.model_name) self.patch_object(model, 'subprocess') _machine_num = "1" model.complete_series_upgrade(_machine_num) self.subprocess.check_call.assert_called_once_with( ["juju", "upgrade-series", "-m", self.model_name, _machine_num, "complete"])