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 # If neutron is ready to be queried then check for incompatability between # existing neutron objects and charm settings if neutron_ready(): if l3ha_router_present() and not get_l3ha(): e = ('Cannot disable Router HA while ha enabled routers exist.' ' Please remove any ha routers') status_set('blocked', e) raise Exception(e) if dvr_router_present() and not get_dvr(): e = ('Cannot disable dvr while dvr enabled routers exist. Please' ' remove any distributed routers') log(e, level=ERROR) status_set('blocked', e) raise Exception(e) if config('prefer-ipv6'): status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) global CONFIGS if not config('action-managed-upgrade'): if openstack_upgrade_available('neutron-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(CONFIGS) additional_install_locations( config('neutron-plugin'), config('openstack-origin') ) status_set('maintenance', 'Installing apt packages') apt_install(filter_installed_packages( determine_packages(config('openstack-origin'))), fatal=True) packages_removed = remove_old_packages() configure_https() update_nrpe_config() CONFIGS.write_all() if packages_removed and not is_unit_paused_set(): log("Package purge detected, restarting services", "INFO") for s in services(): service_restart(s) for r_id in relation_ids('neutron-api'): neutron_api_relation_joined(rid=r_id) for r_id in relation_ids('neutron-plugin-api'): neutron_plugin_api_relation_joined(rid=r_id) for r_id in relation_ids('amqp'): amqp_joined(relation_id=r_id) for r_id in relation_ids('identity-service'): identity_joined(rid=r_id) for r_id in relation_ids('ha'): ha_joined(relation_id=r_id) [cluster_joined(rid) for rid in relation_ids('cluster')]
def test_determine_packages_noplugin(self, git_requested): git_requested.return_value = False self.test_config.set('manage-neutron-plugin-legacy-mode', False) pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server']) self.assertItemsEqual(pkg_list, expect)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) for port in determine_ports(): open_port(port) if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False) # call the policy overrides handler which will install any policy overrides maybe_do_policyd_overrides( os_release('neutron-server'), 'neutron', restart_handler=lambda: service_restart('neutron-server'))
def test_determine_packages(self): self.os_release.return_value = 'havana' self.get_os_codename_install_source.return_value = 'havana' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-ml2']) self.assertEqual(sorted(pkg_list), sorted(expect))
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False) etcd_package_url = config('etcd-package-url') if etcd_package_url and etcd_package_url.startswith('http'): check_call([ "wget", etcd_package_url ]) check_call([ "dpkg", "-i", etcd_package_url.split('/')[-1] ])
def test_do_openstack_upgrade_kilo_notleader(self, git_requested, stamp_neutron_db, migrate_neutron_db, gsrc): git_requested.return_value = False self.is_elected_leader.return_value = False self.os_release.return_value = 'juno' self.config.side_effect = self.test_config.get self.test_config.set('openstack-origin', 'cloud:trusty-kilo') gsrc.return_value = 'kilo' self.get_os_codename_install_source.return_value = 'kilo' configs = MagicMock() nutils.do_openstack_upgrade(configs) self.os_release.assert_called_with('neutron-common') self.assertTrue(self.log.called) self.configure_installation_source.assert_called_with( 'cloud:trusty-kilo' ) self.apt_update.assert_called_with(fatal=True) dpkg_opts = [ '--option', 'Dpkg::Options::=--force-confnew', '--option', 'Dpkg::Options::=--force-confdef', ] self.apt_upgrade.assert_called_with(options=dpkg_opts, fatal=True, dist=True) pkgs = nutils.determine_packages() pkgs.sort() self.apt_install.assert_called_with(packages=pkgs, options=dpkg_opts, fatal=True) configs.set_release.assert_called_with(openstack_release='kilo') self.assertFalse(stamp_neutron_db.called) self.assertFalse(migrate_neutron_db.called)
def test_do_openstack_upgrade_notleader(self, stamp_neutron_db, migrate_neutron_db, gsrc): self.is_elected_leader.return_value = False self.os_release.return_value = 'icehouse' self.config.side_effect = self.test_config.get self.test_config.set('openstack-origin', 'cloud:trusty-juno') gsrc.return_value = 'juno' self.get_os_codename_install_source.return_value = 'juno' configs = MagicMock() nutils.do_openstack_upgrade(configs) self.os_release.assert_called_with('neutron-common') self.assertTrue(self.log.called) self.configure_installation_source.assert_called_with( 'cloud:trusty-juno') self.apt_update.assert_called_with(fatal=True) dpkg_opts = [ '--option', 'Dpkg::Options::=--force-confnew', '--option', 'Dpkg::Options::=--force-confdef', ] self.apt_upgrade.assert_called_with(options=dpkg_opts, fatal=True, dist=True) pkgs = nutils.determine_packages() pkgs.sort() self.apt_install.assert_called_with(packages=pkgs, options=dpkg_opts, fatal=True) configs.set_release.assert_called_with(openstack_release='juno') self.assertFalse(stamp_neutron_db.called) self.assertFalse(migrate_neutron_db.called)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def test_determine_packages_kilo(self, git_requested): git_requested.return_value = False self.get_os_codename_install_source.return_value = 'kilo' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-ml2']) expect.extend(nutils.KILO_PACKAGES) self.assertItemsEqual(pkg_list, expect)
def test_determine_packages_noplugin(self): self.os_release.return_value = 'havana' self.get_os_codename_install_source.return_value = 'havana' self.test_config.set('manage-neutron-plugin-legacy-mode', False) pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server']) self.assertEqual(sorted(pkg_list), sorted(expect))
def config_changed(): # If neutron is ready to be queried then check for incompatability between # existing neutron objects and charm settings codename = get_os_codename_install_source(config('openstack-origin')) if codename >= 'kilo': branch = "stable/%s" % codename pip_install("git+https://github.com/openstack/networking-hyperv.git@%s" % branch) if neutron_ready(): if l3ha_router_present() and not get_l3ha(): e = ('Cannot disable Router HA while ha enabled routers exist.' ' Please remove any ha routers') status_set('blocked', e) raise Exception(e) if dvr_router_present() and not get_dvr(): e = ('Cannot disable dvr while dvr enabled routers exist. Please' ' remove any distributed routers') log(e, level=ERROR) status_set('blocked', e) raise Exception(e) if config('prefer-ipv6'): status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) global CONFIGS 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('neutron-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(CONFIGS) additional_install_locations( config('neutron-plugin'), config('openstack-origin') ) status_set('maintenance', 'Installing apt packages') apt_install(filter_installed_packages( determine_packages(config('openstack-origin'))), fatal=True) configure_https() update_nrpe_config() CONFIGS.write_all() for r_id in relation_ids('neutron-api'): neutron_api_relation_joined(rid=r_id) for r_id in relation_ids('neutron-plugin-api'): neutron_plugin_api_relation_joined(rid=r_id) for r_id in relation_ids('amqp'): amqp_joined(relation_id=r_id) 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')]
def test_determine_packages_noplugin(self, _NeutronApiSDNContext, mock_manage_plugin): self.os_release.return_value = 'havana' self.get_os_codename_install_source.return_value = 'havana' mock_manage_plugin.return_value = False pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server']) self.assertEqual(sorted(pkg_list), sorted(expect))
def test_determine_packages_kilo(self, mock_manage_plugin): self.os_release.return_value = 'havana' self.get_os_codename_install_source.return_value = 'kilo' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-ml2', 'python-networking-hyperv']) expect.extend(nutils.KILO_PACKAGES) self.assertEqual(sorted(pkg_list), sorted(expect))
def test_determine_vsp_packages(self): self.os_release.return_value = 'havana' self.test_config.set('nuage-packages', 'python-nuagenetlib nuage-neutron') self.test_config.set('neutron-plugin', 'vsp') self.get_os_codename_install_source.return_value = 'juno' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-nuage', 'python-nuagenetlib', 'nuage-neutron']) self.assertEqual(sorted(pkg_list), sorted(expect))
def test_determine_vsp_packages(self, git_requested): git_requested.return_value = False self.test_config.set('nuage-packages', 'python-nuagenetlib nuage-neutron') self.test_config.set('neutron-plugin', 'vsp') self.get_os_codename_install_source.return_value = 'juno' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-nuage', 'python-nuagenetlib', 'nuage-neutron']) self.assertItemsEqual(pkg_list, expect)
def config_changed(): # If neutron is ready to be queried then check for incompatability between # existing neutron objects and charm settings if neutron_ready(): if l3ha_router_present() and not get_l3ha(): e = ('Cannot disable Router HA while ha enabled routers exist.' ' Please remove any ha routers') status_set('blocked', e) raise Exception(e) if dvr_router_present() and not get_dvr(): e = ('Cannot disable dvr while dvr enabled routers exist. Please' ' remove any distributed routers') log(e, level=ERROR) status_set('blocked', e) raise Exception(e) if config('prefer-ipv6'): status_set('maintenance', 'configuring ipv6') setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) global CONFIGS 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('neutron-common'): status_set('maintenance', 'Running openstack upgrade') do_openstack_upgrade(CONFIGS) additional_install_locations( config('neutron-plugin'), config('openstack-origin') ) status_set('maintenance', 'Installing apt packages') apt_install(filter_installed_packages( determine_packages(config('openstack-origin'))), fatal=True) configure_https() update_nrpe_config() CONFIGS.write_all() for r_id in relation_ids('neutron-api'): neutron_api_relation_joined(rid=r_id) for r_id in relation_ids('neutron-plugin-api'): neutron_plugin_api_relation_joined(rid=r_id) for r_id in relation_ids('amqp'): amqp_joined(relation_id=r_id) 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')]
def test_determine_packages_train(self, mock_manage_plugin): self.os_release.return_value = 'train' self.get_os_codename_install_source.return_value = 'train' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend([ 'memcached', 'neutron-server', 'neutron-plugin-ml2', 'python-networking-hyperv' ]) expect.extend(nutils.KILO_PACKAGES) expect = [p for p in expect if not p.startswith('python-')] expect.extend(nutils.PY3_PACKAGES + ['python3-neutron-fwaas']) expect.remove('python3-neutron-lbaas') self.assertEqual(sorted(pkg_list), sorted(expect))
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() configure_installation_source(config('openstack-origin')) additional_install_locations(config('neutron-plugin'), config('openstack-origin')) status_set('maintenance', 'Installing apt packages') apt_update() apt_install(determine_packages(config('openstack-origin')), fatal=True) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()]
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) if neutron_plugin == 'vsp': source = config('nuage-tarball-url') if source is not None: try: handler = ArchiveUrlFetchHandler() packages = ['nuage-neutron'] path = handler.install(source) for package in packages: package_path = os.path.join(path, package) if os.path.exists(package_path): log('install {0} from: {1}'.format( package, package_path)) check_output([ 'bash', '-c', 'cd {}; sudo python setup.py install'.format( package_path) ]) except Exception as e: log('install failed with error: {}'.format(e.message)) raise Exception(e) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() configure_installation_source(config('openstack-origin')) additional_install_locations( config('neutron-plugin'), config('openstack-origin') ) status_set('maintenance', 'Installing apt packages') apt_update() apt_install(determine_packages(config('openstack-origin')), fatal=True) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()]
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) if neutron_plugin == 'vsp': source = config('nuage-tarball-url') if source is not None: try: handler = ArchiveUrlFetchHandler() packages = ['nuage-neutron'] path = handler.install(source) for package in packages: package_path = os.path.join(path, package) if os.path.exists(package_path): log('install {0} from: {1}'.format(package, package_path)) check_output( [ 'bash', '-c', 'cd {}; sudo python setup.py install'.format( package_path) ] ) except Exception as e: log('install failed with error: {}'.format(e.message)) raise Exception(e) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def config_changed(): apt_install(filter_installed_packages(determine_packages()), fatal=True) if config('prefer-ipv6'): setup_ipv6() sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) global CONFIGS if openstack_upgrade_available('neutron-server'): do_openstack_upgrade(CONFIGS) configure_https() update_nrpe_config() CONFIGS.write_all() for r_id in relation_ids('neutron-api'): neutron_api_relation_joined(rid=r_id) for r_id in relation_ids('neutron-plugin-api'): neutron_plugin_api_relation_joined(rid=r_id) for r_id in relation_ids('amqp'): amqp_joined(relation_id=r_id) for r_id in relation_ids('identity-service'): identity_joined(rid=r_id) [cluster_joined(rid) for rid in relation_ids('cluster')]
def test_determine_packages(self): pkg_list = nutils.determine_packages() expect = nutils.BASE_PACKAGES expect.extend(['neutron-server', 'neutron-plugin-ml2']) self.assertItemsEqual(pkg_list, expect)
def test_determine_packages(self, git_requested): git_requested.return_value = False pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) expect.extend(['neutron-server', 'neutron-plugin-ml2']) self.assertItemsEqual(pkg_list, expect)
def install(): execd_preinstall() configure_installation_source(config('openstack-origin')) apt_update() apt_install(determine_packages(), fatal=True) [open_port(port) for port in determine_ports()]