def config_changed():
    configure_deferred_restarts(deferrable_services())
    if not config('action-managed-upgrade'):
        if openstack_upgrade_available(NEUTRON_COMMON):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    module_settings = config('kernel-modules')
    if module_settings:
        if is_container():
            log("Cannot load modules inside of a container", level=WARNING)
        else:
            for module in module_settings.split():
                try:
                    modprobe(module)
                except Exception:
                    message = "Failed to load kernel module '%s'" % module
                    log(message, level=WARNING)

    sysctl_settings = config('sysctl')
    if sysctl_settings:
        if is_container():
            log("Cannot create sysctls inside of a container", level=WARNING)
        else:
            create_sysctl(sysctl_settings,
                          '/etc/sysctl.d/50-quantum-gateway.conf')

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
        configure_apparmor()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if config('enable-l3-agent'):
            status_set('maintenance', 'Installing apt packages')
            apt_install(filter_installed_packages('neutron-l3-agent'))
        else:
            apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()
    # Disable nova metadata if possible,
    if disable_nova_metadata():
        remove_legacy_nova_metadata()
    if disable_neutron_lbaas():
        remove_legacy_neutron_lbaas()
 def test_configure_ovs_enable_ipfix(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.test_config.set('ipfix-target', '127.0.0.1:80')
     neutron_utils.configure_ovs()
     self.enable_ipfix.assert_has_calls([
         call('br-int', '127.0.0.1:80'),
         call('br-ex', '127.0.0.1:80'),
         call('br-data', '127.0.0.1:80'),
     ])
Exemplo n.º 3
0
 def test_configure_ovs_enable_ipfix(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.test_config.set('ipfix-target', '127.0.0.1:80')
     neutron_utils.configure_ovs()
     self.enable_ipfix.assert_has_calls([
         call('br-int', '127.0.0.1:80'),
         call('br-ex', '127.0.0.1:80'),
         call('br-data', '127.0.0.1:80'),
     ])
Exemplo n.º 4
0
 def test_configure_ovs_ovs_ext_port(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.test_config.set('ext-port', 'eth0')
     self.ExternalPortContext.return_value = \
         DummyExternalPortContext(return_value={'ext_port': 'eth0'})
     neutron_utils.configure_ovs()
     self.add_bridge.assert_has_calls(
         [call('br-int'), call('br-ex'),
          call('br-data')])
     self.add_bridge_port.assert_called_with('br-ex', 'eth0')
Exemplo n.º 5
0
 def test_configure_ovs_ovs_ext_port(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.test_config.set('ext-port', 'eth0')
     self.ExternalPortContext.return_value = \
         DummyExternalPortContext(return_value={'ext_port': 'eth0'})
     neutron_utils.configure_ovs()
     self.add_bridge.assert_has_calls([
         call('br-int'),
         call('br-ex'),
         call('br-data')
     ])
     self.add_bridge_port.assert_called_with('br-ex', 'eth0')
def config_changed():
    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'))
            CONFIGS.write_all()

    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available(NEUTRON_COMMON):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if not git_install_requested():
            if config('enable-l3-agent'):
                status_set('maintenance', 'Installing apt packages')
                apt_install(filter_installed_packages('neutron-l3-agent'))
            else:
                apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()

    # Remove legacy MTU & network configs
    remove_file('/etc/init/os-charm-phy-nic-mtu.conf')

    # Trigger udev update for MTU
    subprocess.check_call(["udevadm", "trigger", "--subsystem-match=net"])
Exemplo n.º 7
0
def config_changed():
    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'))
            CONFIGS.write_all()

    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available(NEUTRON_COMMON):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if not git_install_requested():
            if config('enable-l3-agent'):
                status_set('maintenance', 'Installing apt packages')
                apt_install(filter_installed_packages('neutron-l3-agent'))
            else:
                apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()

    # Remove legacy MTU & network configs
    remove_file('/etc/init/os-charm-phy-nic-mtu.conf')

    # Trigger udev update for MTU
    subprocess.check_call(["udevadm", "trigger", "--subsystem-match=net"])
Exemplo n.º 8
0
def config_changed():
    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'))
            CONFIGS.write_all()

    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available(get_common_package()):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('shared-db'):
        db_joined(relation_id=r_id)
    for r_id in relation_ids('pgsql-db'):
        pgsql_db_joined(relation_id=r_id)
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if not git_install_requested():
            if config('enable-l3-agent'):
                status_set('maintenance', 'Installing apt packages')
                apt_install(filter_installed_packages('neutron-l3-agent'))
            else:
                apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()
Exemplo n.º 9
0
def config_changed():
    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'))
            CONFIGS.write_all()

    elif not config('action-managed-upgrade'):
        if openstack_upgrade_available(get_common_package()):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('shared-db'):
        db_joined(relation_id=r_id)
    for r_id in relation_ids('pgsql-db'):
        pgsql_db_joined(relation_id=r_id)
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    for rid in relation_ids('zeromq-configuration'):
        zeromq_configuration_relation_joined(rid)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if not git_install_requested():
            if config('enable-l3-agent'):
                status_set('maintenance', 'Installing apt packages')
                apt_install(filter_installed_packages('neutron-l3-agent'))
            else:
                apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()
Exemplo n.º 10
0
 def test_configure_ovs_ovs_data_port_bridge(self, mock_config):
     self.is_linuxbridge_interface.return_value = True
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.ExternalPortContext.return_value = \
         DummyExternalPortContext(return_value=None)
     # Test back-compatibility i.e. port but no bridge (so br-data is
     # assumed)
     self.test_config.set('data-port', 'br-eth0')
     neutron_utils.configure_ovs()
     self.add_bridge.assert_has_calls(
         [call('br-int'), call('br-ex'),
          call('br-data')])
     calls = [call('br-data', 'br-eth0')]
     self.add_ovsbridge_linuxbridge.assert_has_calls(calls)
 def test_configure_ovs_ovs_data_port_bridge(self, mock_config):
     self.is_linuxbridge_interface.return_value = True
     mock_config.side_effect = self.test_config.get
     self.config.side_effect = self.test_config.get
     self.test_config.set('plugin', 'ovs')
     self.ExternalPortContext.return_value = \
         DummyExternalPortContext(return_value=None)
     # Test back-compatibility i.e. port but no bridge (so br-data is
     # assumed)
     self.test_config.set('data-port', 'br-eth0')
     neutron_utils.configure_ovs()
     self.add_bridge.assert_has_calls([
         call('br-int'),
         call('br-ex'),
         call('br-data')
     ])
     calls = [call('br-data', 'br-eth0')]
     self.add_ovsbridge_linuxbridge.assert_has_calls(calls)
def config_changed():
    global CONFIGS
    if not config('action-managed-upgrade'):
        if openstack_upgrade_available(NEUTRON_COMMON):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_settings = config('sysctl')
    if sysctl_settings:
        create_sysctl(sysctl_settings,
                      '/etc/sysctl.d/50-quantum-gateway.conf')

    if config('vendor-data'):
        write_vendordata(config('vendor-data'))

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
        configure_apparmor()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if config('enable-l3-agent'):
            status_set('maintenance', 'Installing apt packages')
            apt_install(filter_installed_packages('neutron-l3-agent'))
        else:
            apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()
    # Disable nova metadata if possible,
    if disable_nova_metadata():
        remove_legacy_nova_metadata()
Exemplo n.º 13
0
def config_changed():
    global CONFIGS
    if not config('action-managed-upgrade'):
        if openstack_upgrade_available(NEUTRON_COMMON):
            status_set('maintenance', 'Running openstack upgrade')
            do_openstack_upgrade(CONFIGS)

    update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

    if config('vendor-data'):
        write_vendordata(config('vendor-data'))

    # Re-run joined hooks as config might have changed
    for r_id in relation_ids('amqp'):
        amqp_joined(relation_id=r_id)
    for r_id in relation_ids('amqp-nova'):
        amqp_nova_joined(relation_id=r_id)
    if valid_plugin():
        CONFIGS.write_all()
        configure_ovs()
        configure_apparmor()
    else:
        message = 'Please provide a valid plugin config'
        log(message, level=ERROR)
        status_set('blocked', message)
        sys.exit(1)
    if config('plugin') == 'n1kv':
        if config('enable-l3-agent'):
            status_set('maintenance', 'Installing apt packages')
            apt_install(filter_installed_packages('neutron-l3-agent'))
        else:
            apt_purge('neutron-l3-agent')

    # Setup legacy ha configurations
    update_legacy_ha_files()
    def test_configure_ovs_ovs_data_port(self, mock_config):
        self.is_linuxbridge_interface.return_value = False
        mock_config.side_effect = self.test_config.get
        self.config.side_effect = self.test_config.get
        self.test_config.set('plugin', 'ovs')
        self.ExternalPortContext.return_value = \
            DummyExternalPortContext(return_value=None)
        # Test back-compatibility i.e. port but no bridge (so br-data is
        # assumed)
        self.test_config.set('data-port', 'eth0')
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br-data')
        ])
        calls = [call('br-data', 'eth0', promisc=True)]
        self.add_bridge_port.assert_has_calls(calls)

        # Now test with bridge:port format and bogus bridge
        self.test_config.set('data-port', 'br-foo:eth0')
        self.add_bridge.reset_mock()
        self.add_bridge_port.reset_mock()
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br-data')
        ])
        # Not called since we have a bogus bridge in data-ports
        self.assertFalse(self.add_bridge_port.called)

        # Now test with bridge:port format
        self.test_config.set('bridge-mappings', 'net1:br1')
        self.test_config.set('data-port', 'br1:eth0.100 br1:eth0.200')
        self.add_bridge.reset_mock()
        self.add_bridge_port.reset_mock()
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br1')
        ])
        calls = [call('br1', 'eth0.100', promisc=True),
                 call('br1', 'eth0.200', promisc=True)]
        self.add_bridge_port.assert_has_calls(calls, any_order=True)
Exemplo n.º 15
0
    def test_configure_ovs_ovs_data_port(self, mock_config, _nics):
        self.is_linuxbridge_interface.return_value = False
        mock_config.side_effect = self.test_config.get
        self.config.side_effect = self.test_config.get
        self.test_config.set('plugin', 'ovs')
        self.ExternalPortContext.return_value = \
            DummyExternalPortContext(return_value=None)
        # Test back-compatibility i.e. port but no bridge (so br-data is
        # assumed)
        self.test_config.set('data-port', 'eth0')
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br-data')
        ])
        calls = [call('br-data', 'eth0', promisc=True)]
        self.add_bridge_port.assert_has_calls(calls)

        # Now test with bridge:port format and bogus bridge
        self.test_config.set('data-port', 'br-foo:eth0')
        self.add_bridge.reset_mock()
        self.add_bridge_port.reset_mock()
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br-data')
        ])
        # Not called since we have a bogus bridge in data-ports
        self.assertFalse(self.add_bridge_port.called)

        # Now test with bridge:port format
        self.test_config.set('bridge-mappings', 'net1:br1')
        self.test_config.set('data-port', 'br1:eth0.100 br1:eth0.200')
        self.add_bridge.reset_mock()
        self.add_bridge_port.reset_mock()
        neutron_utils.configure_ovs()
        self.add_bridge.assert_has_calls([
            call('br-int'),
            call('br-ex'),
            call('br1')
        ])
        calls = [call('br1', 'eth0.100', promisc=True),
                 call('br1', 'eth0.200', promisc=True)]
        self.add_bridge_port.assert_has_calls(calls, any_order=True)
Exemplo n.º 16
0
 def test_configure_ovs_doesnt_restart_service(self):
     self.service_running.return_value = True
     neutron_utils.configure_ovs()
     self.assertFalse(self.full_restart.called)
Exemplo n.º 17
0
 def test_configure_ovs_doesnt_restart_service(self):
     self.service_running.return_value = True
     neutron_utils.configure_ovs()
     self.assertFalse(self.full_restart.called)
Exemplo n.º 18
0
 def test_configure_ovs_starts_service_if_required(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.return_value = 'ovs'
     self.service_running.return_value = False
     neutron_utils.configure_ovs()
     self.assertTrue(self.full_restart.called)
Exemplo n.º 19
0
 def test_configure_ovs_starts_service_if_required(self, mock_config):
     mock_config.side_effect = self.test_config.get
     self.config.return_value = 'ovs'
     self.service_running.return_value = False
     neutron_utils.configure_ovs()
     self.assertTrue(self.full_restart.called)