def test_upgrade_havana_icehouse_source(self, _do_openstack_upgrade):
     "Verify get_step_upgrade_source() for havana->icehouse"
     self.config.side_effect = None
     self.config.return_value = 'cloud:precise-icehouse'
     with patch_open() as (_open, _file):
         _file.read = MagicMock()
         _file.readline.return_value = "deb url precise-updates/havana main"
         utils.do_openstack_upgrade(self.register_configs())
         expected = [call('cloud:precise-icehouse')]
         self.assertEquals(_do_openstack_upgrade.call_args_list, expected)
def config_changed():
    # neutron-server runs if < juno. Neutron-server creates mysql tables
    # which will subsequently cause db migratoins to fail if >= juno.
    # Disable neutron-server if >= juno
    if os_release('nova-common') >= 'juno':
        with open('/etc/init/neutron-server.override', 'wb') as out:
            out.write('manual\n')
    if config('prefer-ipv6'):
        status_set('maintenance', 'configuring ipv6')
        setup_ipv6()
        sync_db_with_multi_ipv6_addresses(config('database'),
                                          config('database-user'),
                                          relation_prefix='nova')

    global CONFIGS
    if git_install_requested():
        status_set('maintenance', 'Running Git install')
        if config_value_changed('openstack-origin-git'):
            git_install(config('openstack-origin-git'))
    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available('nova-common'):
            status_set('maintenance', 'Running openstack upgrade')
            CONFIGS = do_openstack_upgrade(CONFIGS)
            [neutron_api_relation_joined(rid=rid, remote_restart=True)
                for rid in relation_ids('neutron-api')]
            # NOTE(jamespage): Force re-fire of shared-db joined hook
            # to ensure that nova_api database is setup if required.
            [db_joined(relation_id=r_id)
                for r_id in relation_ids('shared-db')]

    save_script_rc()
    configure_https()
    CONFIGS.write_all()
    if console_attributes('protocol'):
        if not git_install_requested():
            status_set('maintenance', 'Configuring guest console access')
            apt_update()
            packages = console_attributes('packages') or []
            filtered = filter_installed_packages(packages)
            if filtered:
                apt_install(filtered, fatal=True)

        [compute_joined(rid=rid)
            for rid in relation_ids('cloud-compute')]

    for r_id in relation_ids('identity-service'):
        identity_joined(rid=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    [cluster_joined(rid) for rid in relation_ids('cluster')]
    update_nrpe_config()

    # If the region value has changed, notify the cloud-compute relations
    # to ensure the value is propagated to the compute nodes.
    if config_value_changed('region'):
        for rid in relation_ids('cloud-compute'):
            for unit in related_units(rid):
                compute_changed(rid, unit)

    update_nova_consoleauth_config()
 def test_upgrade_juno_kilo(self, determine_packages,
                            migrate_nova_database,
                            get_step_upgrade_source):
     "Simulate a call to do_openstack_upgrade() for juno->kilo"
     self.test_config.set('openstack-origin', 'cloud:trusty-kilo')
     get_step_upgrade_source.return_value = None
     self.os_release.return_value = 'juno'
     self.get_os_codename_install_source.return_value = 'kilo'
     self.is_elected_leader.return_value = True
     self.relation_ids.return_value = []
     utils.do_openstack_upgrade(self.register_configs())
     self.apt_update.assert_called_with(fatal=True)
     self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
                                         dist=True)
     self.apt_install.assert_called_with(determine_packages(), fatal=True)
     self.register_configs.assert_called_with(release='kilo')
     self.assertTrue(migrate_nova_database.call_count, 1)
 def test_upgrade_havana_icehouse(self, determine_packages,
                                  migrate_nova_database,
                                  get_step_upgrade_source):
     "Simulate a call to do_openstack_upgrade() for havana->icehouse"
     self.test_config.set('openstack-origin', 'cloud:precise-icehouse')
     get_step_upgrade_source.return_value = None
     self.os_release.return_value = 'havana'
     self.get_os_codename_install_source.return_value = 'icehouse'
     self.is_elected_leader.return_value = True
     self.relation_ids.return_value = []
     utils.do_openstack_upgrade(self.register_configs())
     self.neutron_db_manage.assert_called_with(['upgrade', 'head'])
     self.apt_update.assert_called_with(fatal=True)
     self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
                                         dist=True)
     self.apt_install.assert_called_with(determine_packages(), fatal=True)
     self.register_configs.assert_called_with(release='icehouse')
     self.assertEquals(self.ml2_migration.call_count, 1)
     self.assertTrue(migrate_nova_database.call_count, 1)
 def test_upgrade_liberty_mitaka(self, determine_packages,
                                 migrate_nova_database,
                                 get_step_upgrade_source,
                                 database_setup):
     "Simulate a call to do_openstack_upgrade() for liberty->mitaka"
     self.test_config.set('openstack-origin', 'cloud:trusty-kilo')
     get_step_upgrade_source.return_value = None
     self.os_release.return_value = 'liberty'
     self.get_os_codename_install_source.return_value = 'mitaka'
     self.is_elected_leader.return_value = True
     self.relation_ids.return_value = []
     database_setup.return_value = False
     utils.do_openstack_upgrade(self.register_configs())
     self.apt_update.assert_called_with(fatal=True)
     self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
                                         dist=True)
     self.apt_install.assert_called_with(determine_packages(), fatal=True)
     self.register_configs.assert_called_with(release='mitaka')
     self.assertFalse(migrate_nova_database.called)
     database_setup.assert_called_with(prefix='novaapi')
 def test_upgrade_icehouse_juno(self, determine_packages,
                                migrate_nova_database,
                                get_step_upgrade_source):
     "Simulate a call to do_openstack_upgrade() for icehouse->juno"
     self.test_config.set('openstack-origin', 'cloud:trusty-juno')
     get_step_upgrade_source.return_value = None
     self.os_release.return_value = 'icehouse'
     self.get_os_codename_install_source.return_value = 'juno'
     self.is_elected_leader.return_value = True
     self.relation_ids.return_value = []
     utils.do_openstack_upgrade(self.register_configs())
     neutron_db_calls = [call(['stamp', 'icehouse']),
                         call(['upgrade', 'head'])]
     self.neutron_db_manage.assert_has_calls(neutron_db_calls,
                                             any_order=False)
     self.apt_update.assert_called_with(fatal=True)
     self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
                                         dist=True)
     self.apt_install.assert_called_with(determine_packages(), fatal=True)
     self.register_configs.assert_called_with(release='juno')
     self.assertEquals(self.ml2_migration.call_count, 0)
     self.assertTrue(migrate_nova_database.call_count, 1)
 def test_upgrade_grizzly_icehouse(self, determine_packages,
                                   migrate_nova_database,
                                   get_step_upgrade_source):
     "Simulate a call to do_openstack_upgrade() for grizzly->icehouse"
     self.test_config.set('openstack-origin', 'cloud:precise-icehouse')
     get_step_upgrade_source.return_value = 'cloud:precise-havana'
     self.os_release.side_effect = ['grizzly', 'havana']
     self.get_os_codename_install_source.side_effect = [
         'havana',
         'icehouse']
     self.is_elected_leader.return_value = True
     self.relation_ids.return_value = []
     utils.do_openstack_upgrade(self.register_configs())
     expected = [call(['stamp', 'grizzly']), call(['upgrade', 'head']),
                 call(['stamp', 'havana']), call(['upgrade', 'head'])]
     self.assertEquals(self.neutron_db_manage.call_args_list, expected)
     self.apt_update.assert_called_with(fatal=True)
     self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
                                         dist=True)
     self.apt_install.assert_called_with(determine_packages(), fatal=True)
     expected = [call(), call(release='havana'), call(release='icehouse')]
     self.assertEquals(self.register_configs.call_args_list, expected)
     self.assertEquals(self.ml2_migration.call_count, 1)
     self.assertTrue(migrate_nova_database.call_count, 2)
Example #8
0
def config_changed():
    if config('prefer-ipv6'):
        status_set('maintenance', 'configuring ipv6')
        setup_ipv6()
        sync_db_with_multi_ipv6_addresses(config('database'),
                                          config('database-user'),
                                          relation_prefix='nova')

    global CONFIGS
    if git_install_requested():
        status_set('maintenance', 'Running Git install')
        if config_value_changed('openstack-origin-git'):
            git_install(config('openstack-origin-git'))
    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available('nova-common'):
            status_set('maintenance', 'Running openstack upgrade')
            CONFIGS = do_openstack_upgrade(CONFIGS)
            [neutron_api_relation_joined(rid=rid, remote_restart=True)
                for rid in relation_ids('neutron-api')]
    save_script_rc()
    configure_https()
    CONFIGS.write_all()
    if console_attributes('protocol'):
        if not git_install_requested():
            status_set('maintenance', 'Configuring guest console access')
            apt_update()
            packages = console_attributes('packages') or []
            filtered = filter_installed_packages(packages)
            if filtered:
                apt_install(filtered, fatal=True)

        [compute_joined(rid=rid)
            for rid in relation_ids('cloud-compute')]

    for r_id in relation_ids('identity-service'):
        identity_joined(rid=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    [cluster_joined(rid) for rid in relation_ids('cluster')]
    update_nrpe_config()

    update_nova_consoleauth_config()
def config_changed():
    if openstack_upgrade_available('nova-common'):
        do_openstack_upgrade(configs=CONFIGS)
    save_script_rc()
    configure_https()
    CONFIGS.write_all()