def test_openstack_upgrade_rocky(self, pkgs, migrate, services, mock_register_configs): pkgs.return_value = ['mypackage'] self.os_release.return_value = 'rocky' self.config.side_effect = None self.config.return_value = 'cloud:bionic-rocky' services.return_value = ['cinder-api', 'cinder-volume'] self.is_elected_leader.return_value = True self.get_os_codename_install_source.return_value = 'rocky' configs = mock_register_configs.return_value self.filter_missing_packages.return_value = [ 'python-cinder', ] cinder_utils.do_openstack_upgrade(configs) self.assertTrue(mock_register_configs.called) self.assertTrue(configs.write_all.called) self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS, fatal=True, dist=True) self.apt_install.assert_called_with(['mypackage'], fatal=True) self.apt_purge.assert_called_with( ['python-cinder'], fatal=True) self.apt_autoremove.assert_called_with(purge=True, fatal=True) configs.set_release.assert_called_with(openstack_release='rocky') self.assertTrue(migrate.called)
def test_openstack_upgrade_rocky(self, pkgs, migrate, services, mock_register_configs, service_enabled): pkgs.return_value = ['mypackage'] self.os_release.return_value = 'rocky' self.config.side_effect = None self.config.return_value = 'cloud:bionic-rocky' services.return_value = ['cinder-api', 'cinder-volume'] self.is_elected_leader.return_value = True self.get_os_codename_install_source.return_value = 'rocky' configs = mock_register_configs.return_value service_enabled.return_value = True self.filter_missing_packages.return_value = [ 'python-cinder', ] cinder_utils.do_openstack_upgrade(configs) self.assertTrue(mock_register_configs.called) self.assertTrue(configs.write_all.called) self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS, fatal=True, dist=True) self.apt_install.assert_called_with(['mypackage'], fatal=True) self.apt_purge.assert_called_with(['python-cinder'], fatal=True) self.apt_autoremove.assert_called_with(purge=True, fatal=True) configs.set_release.assert_called_with(openstack_release='rocky') self.assertTrue(migrate.called)
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 conf = config() if conf['prefer-ipv6']: status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) e_mountpoint = config('ephemeral-unmount') if e_mountpoint and filesystem_mounted(e_mountpoint): umount(e_mountpoint) # configure block devices either local or from juju storage _configure_block_devices() if not config('action-managed-upgrade'): if openstack_upgrade_available('cinder-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(configs=CONFIGS) # NOTE(jamespage) tell any storage-backends we just upgraded for rid in relation_ids('storage-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # NOTE(hopem) tell any backup-backends we just upgraded for rid in relation_ids('backup-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # overwrite config is not in conf file. so We can't use restart_on_change if config_value_changed('overwrite') and not is_unit_paused_set(): service_restart('cinder-volume') CONFIGS.write_all() configure_https() update_nrpe_config() open_port(config('api-listening-port')) for rid in relation_ids('cluster'): cluster_joined(relation_id=rid) for r_id in relation_ids('ha'): ha_joined(relation_id=r_id) # NOTE(jamespage): # ensure any new volume endpoints are created. Note that this # is normally done after an openstack series upgrade, but this # was not performed historically so always execute to ensure # any upgrades where this step was missed are fixed. for rid in relation_ids('identity-service'): identity_joined(rid=rid) # call the policy overrides handler which will install any policy overrides maybe_do_policyd_overrides_on_config_changed( os_release('cinder-common'), 'cinder', restart_handler=lambda: service_restart('cinder-api'))
def test_openstack_upgrade_not_leader(self, pkgs, migrate): pkgs.return_value = ['mypackage'] self.config.side_effect = None self.config.return_value = 'cloud:precise-havana' self.eligible_leader.return_value = False self.get_os_codename_install_source.return_value = 'havana' configs = MagicMock() cinder_utils.do_openstack_upgrade(configs) self.assertTrue(configs.write_all.called) configs.set_release.assert_called_with(openstack_release='havana') self.assertFalse(migrate.called)
def config_changed(): conf = config() if conf['prefer-ipv6']: status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) e_mountpoint = config('ephemeral-unmount') if e_mountpoint and filesystem_mounted(e_mountpoint): umount(e_mountpoint) if (service_enabled('volume') and conf['block-device'] not in [None, 'None', 'none']): status_set('maintenance', 'Configuring lvm storage') block_devices = conf['block-device'].split() configure_lvm_storage(block_devices, conf['volume-group'], conf['overwrite'] in ['true', 'True', True], conf['remove-missing'], conf['remove-missing-force']) if git_install_requested(): if config_value_changed('openstack-origin-git'): status_set('maintenance', 'Running Git install') git_install(config('openstack-origin-git')) elif not config('action-managed-upgrade'): if openstack_upgrade_available('cinder-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(configs=CONFIGS) # NOTE(jamespage) tell any storage-backends we just upgraded for rid in relation_ids('storage-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # NOTE(hopem) tell any backup-backends we just upgraded for rid in relation_ids('backup-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # overwrite config is not in conf file. so We can't use restart_on_change if config_value_changed('overwrite') and not is_unit_paused_set(): service_restart('cinder-volume') CONFIGS.write_all() configure_https() update_nrpe_config() open_port(config('api-listening-port')) for rid in relation_ids('cluster'): cluster_joined(relation_id=rid) for r_id in relation_ids('ha'): ha_joined(relation_id=r_id)
def config_changed(): conf = config() if conf['prefer-ipv6']: status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) e_mountpoint = config('ephemeral-unmount') if e_mountpoint and filesystem_mounted(e_mountpoint): umount(e_mountpoint) if (service_enabled('volume') and conf['block-device'] not in [None, 'None', 'none']): status_set('maintenance', 'Configuring lvm storage') block_devices = conf['block-device'].split() configure_lvm_storage(block_devices, conf['volume-group'], conf['overwrite'] in ['true', 'True', True], conf['remove-missing'], conf['remove-missing-force']) if git_install_requested(): if config_value_changed('openstack-origin-git'): status_set('maintenance', 'Running Git install') git_install(config('openstack-origin-git')) elif not config('action-managed-upgrade'): if openstack_upgrade_available('cinder-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(configs=CONFIGS) # NOTE(jamespage) tell any storage-backends we just upgraded for rid in relation_ids('storage-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # NOTE(hopem) tell any backup-backends we just upgraded for rid in relation_ids('backup-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # overwrite config is not in conf file. so We can't use restart_on_change if config_value_changed('overwrite') and not is_unit_paused_set(): service_restart('cinder-volume') CONFIGS.write_all() configure_https() update_nrpe_config() open_port(config('api-listening-port')) for rid in relation_ids('cluster'): cluster_joined(relation_id=rid) for r_id in relation_ids('ha'): ha_joined(relation_id=r_id)
def test_openstack_upgrade_not_leader(self, pkgs, migrate, services): pkgs.return_value = ['mypackage'] self.config.side_effect = None self.config.return_value = 'cloud:precise-havana' services.return_value = ['cinder-api', 'cinder-volume'] self.is_elected_leader.return_value = False self.get_os_codename_install_source.return_value = 'havana' configs = MagicMock() cinder_utils.do_openstack_upgrade(configs) self.assertTrue(configs.write_all.called) self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS, fatal=True, dist=True) self.apt_install.assert_called_with(['mypackage'], fatal=True) configs.set_release.assert_called_with(openstack_release='havana') self.assertFalse(migrate.called)
def test_openstack_upgrade_not_leader(self, pkgs, migrate, services): pkgs.return_value = ['mypackage'] self.config.side_effect = None self.config.return_value = 'cloud:precise-havana' services.return_value = ['cinder-api', 'cinder-volume'] self.is_elected_leader.return_value = False self.get_os_codename_install_source.return_value = 'havana' configs = MagicMock() cinder_utils.do_openstack_upgrade(configs) self.assertTrue(configs.write_all.called) self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS, fatal=True, dist=True) self.apt_install.assert_called_with(['mypackage'], fatal=True) configs.set_release.assert_called_with(openstack_release='havana') self.assertFalse(migrate.called)
def config_changed(): if openstack_upgrade_available('cinder-common'): do_openstack_upgrade(configs=CONFIGS) CONFIGS.write_all() configure_https()
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 conf = config() if conf['prefer-ipv6']: status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) e_mountpoint = config('ephemeral-unmount') if e_mountpoint and filesystem_mounted(e_mountpoint): umount(e_mountpoint) if (service_enabled('volume') and conf['block-device'] not in [None, 'None', 'none']): status_set('maintenance', 'Configuring lvm storage') block_devices = conf['block-device'].split() configure_lvm_storage(block_devices, conf['volume-group'], conf['overwrite'] in ['true', 'True', True], conf['remove-missing'], conf['remove-missing-force']) if not config('action-managed-upgrade'): if openstack_upgrade_available('cinder-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(configs=CONFIGS) # NOTE(jamespage) tell any storage-backends we just upgraded for rid in relation_ids('storage-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # NOTE(hopem) tell any backup-backends we just upgraded for rid in relation_ids('backup-backend'): relation_set(relation_id=rid, upgrade_nonce=uuid.uuid4()) # overwrite config is not in conf file. so We can't use restart_on_change if config_value_changed('overwrite') and not is_unit_paused_set(): service_restart('cinder-volume') CONFIGS.write_all() configure_https() update_nrpe_config() open_port(config('api-listening-port')) for rid in relation_ids('cluster'): cluster_joined(relation_id=rid) for r_id in relation_ids('ha'): ha_joined(relation_id=r_id) # NOTE(jamespage): # ensure any new volume endpoints are created. Note that this # is normally done after an openstack series upgrade, but this # was not performed historically so always execute to ensure # any upgrades where this step was missed are fixed. for rid in relation_ids('identity-service'): identity_joined(rid=rid)