diff --git a/neutron/agent/dhcp_agent.py b/neutron/agent/dhcp_agent.py index b6da1d31f77..371d37c3e03 100644 --- a/neutron/agent/dhcp_agent.py +++ b/neutron/agent/dhcp_agent.py @@ -30,6 +30,7 @@ from neutron import service as neutron_service def register_options(conf): + common_config.register_common_config_options() config.register_interface_driver_opts_helper(conf) config.register_agent_state_opts_helper(conf) config.register_availability_zone_opts_helper(conf) diff --git a/neutron/agent/l3/keepalived_state_change.py b/neutron/agent/l3/keepalived_state_change.py index eb0650b6cf5..9bb97696fea 100644 --- a/neutron/agent/l3/keepalived_state_change.py +++ b/neutron/agent/l3/keepalived_state_change.py @@ -166,6 +166,7 @@ class MonitorDaemon(daemon.Daemon): def configure(conf): + config.register_common_config_options() config.init(sys.argv[1:]) conf.set_override('log_dir', cfg.CONF.conf_dir) conf.set_override('debug', True) diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index d79e8cc6e48..0b8b704698e 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -31,6 +31,7 @@ from neutron import service as neutron_service def register_opts(conf): + common_config.register_common_config_options() l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf) ha_conf.register_l3_agent_ha_opts(conf) meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf) diff --git a/neutron/agent/metadata_agent.py b/neutron/agent/metadata_agent.py index e6265b42e1b..feee9917340 100644 --- a/neutron/agent/metadata_agent.py +++ b/neutron/agent/metadata_agent.py @@ -29,6 +29,7 @@ LOG = logging.getLogger(__name__) def main(): + config.register_common_config_options() meta.register_meta_conf_opts(meta.SHARED_OPTS) meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS) meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS) diff --git a/neutron/agent/ovn/metadata_agent.py b/neutron/agent/ovn/metadata_agent.py index 3b0656368d0..8afaf0cef5b 100644 --- a/neutron/agent/ovn/metadata_agent.py +++ b/neutron/agent/ovn/metadata_agent.py @@ -26,6 +26,7 @@ LOG = logging.getLogger(__name__) def main(): + config.register_common_config_options() ovn_meta.register_meta_conf_opts(meta.SHARED_OPTS) ovn_meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS) ovn_meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS) diff --git a/neutron/cmd/destroy_patch_ports.py b/neutron/cmd/destroy_patch_ports.py index 81dd7bef023..2fa6dc4acda 100644 --- a/neutron/cmd/destroy_patch_ports.py +++ b/neutron/cmd/destroy_patch_ports.py @@ -78,6 +78,7 @@ class PatchPortCleaner(object): def main(): + common_config.register_common_config_options() common_config.init(sys.argv[1:]) ovs_conf.register_ovs_agent_opts() common_config.setup_logging() diff --git a/neutron/cmd/eventlet/usage_audit.py b/neutron/cmd/eventlet/usage_audit.py index 4d1435af4c6..010134c4fe4 100644 --- a/neutron/cmd/eventlet/usage_audit.py +++ b/neutron/cmd/eventlet/usage_audit.py @@ -29,6 +29,7 @@ from neutron import manager def main(): + config.register_common_config_options() config.init(sys.argv[1:]) config.setup_logging() diff --git a/neutron/cmd/ipset_cleanup.py b/neutron/cmd/ipset_cleanup.py index 7f09b8d9c57..2ee65a8d867 100644 --- a/neutron/cmd/ipset_cleanup.py +++ b/neutron/cmd/ipset_cleanup.py @@ -32,6 +32,7 @@ def setup_conf(): from the main config that do not apply during clean-up. """ conf = cfg.CONF + config.register_common_config_options() agent_config.register_root_helper(conf=conf) agent_config.setup_privsep() command.register_cmd_opts(command.ip_opts, conf) diff --git a/neutron/cmd/linuxbridge_cleanup.py b/neutron/cmd/linuxbridge_cleanup.py index 34e22ce3847..5338b0984d1 100644 --- a/neutron/cmd/linuxbridge_cleanup.py +++ b/neutron/cmd/linuxbridge_cleanup.py @@ -16,6 +16,7 @@ from neutron_lib.utils import helpers from oslo_config import cfg from oslo_log import log as logging +from neutron.common import config as common_config from neutron.conf.agent import common as config from neutron.plugins.ml2.drivers.linuxbridge.agent \ import linuxbridge_neutron_agent @@ -67,6 +68,7 @@ def main(): This tool should not be called during an instance create, migrate, etc. as it can delete a linux bridge about to be used by nova. """ + common_config.register_common_config_options() cfg.CONF(sys.argv[1:]) config.setup_logging() config.setup_privsep() diff --git a/neutron/cmd/netns_cleanup.py b/neutron/cmd/netns_cleanup.py index a12987228a1..ac5ddfddd25 100644 --- a/neutron/cmd/netns_cleanup.py +++ b/neutron/cmd/netns_cleanup.py @@ -66,6 +66,7 @@ def setup_conf(): """ conf = cfg.CONF + config.register_common_config_options() cmd.register_cmd_opts(cmd.netns_opts, conf) agent_config.register_interface_driver_opts_helper(conf) dhcp_config.register_agent_dhcp_opts(conf) diff --git a/neutron/cmd/ovn/neutron_ovn_db_sync_util.py b/neutron/cmd/ovn/neutron_ovn_db_sync_util.py index 274eb29ab34..9370cabe4fd 100644 --- a/neutron/cmd/ovn/neutron_ovn_db_sync_util.py +++ b/neutron/cmd/ovn/neutron_ovn_db_sync_util.py @@ -20,6 +20,7 @@ from oslo_config import cfg from oslo_db import options as db_options from oslo_log import log as logging +from neutron.common import config as common_config from neutron.conf.agent import securitygroups_rpc from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf from neutron import manager @@ -137,6 +138,7 @@ class AgentNotifierApi(object): def setup_conf(): conf = cfg.CONF + common_config.register_common_config_options() ml2_group, ml2_opts = neutron_options.list_ml2_conf_opts()[0] cfg.CONF.register_cli_opts(ml2_opts, ml2_group) cfg.CONF.register_cli_opts(securitygroups_rpc.security_group_opts, diff --git a/neutron/cmd/ovs_cleanup.py b/neutron/cmd/ovs_cleanup.py index 8e75317e08f..8c6e1dd2cbc 100644 --- a/neutron/cmd/ovs_cleanup.py +++ b/neutron/cmd/ovs_cleanup.py @@ -39,6 +39,7 @@ def setup_conf(): """ conf = cfg.CONF + config.register_common_config_options() cmd.register_cmd_opts(cmd.ovs_opts, conf) l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf) agent_config.register_interface_driver_opts_helper(conf) diff --git a/neutron/cmd/sanitize_port_binding_profile_allocation.py b/neutron/cmd/sanitize_port_binding_profile_allocation.py index 87077ef7a82..c482301d90f 100644 --- a/neutron/cmd/sanitize_port_binding_profile_allocation.py +++ b/neutron/cmd/sanitize_port_binding_profile_allocation.py @@ -19,6 +19,7 @@ from oslo_db import options as db_options from oslo_log import log as logging from neutron.api import converters as n_converters +from neutron.common import config as common_config from neutron.objects import ports as port_obj from neutron.objects.qos import binding as qos_binding_obj from neutron.objects.qos import rule as qos_rule_obj @@ -29,6 +30,7 @@ LOG = logging.getLogger(__name__) def setup_conf(): conf = cfg.CONF + common_config.register_common_config_options() db_group, neutron_db_opts = db_options.list_opts()[0] cfg.CONF.register_cli_opts(neutron_db_opts, db_group) conf() diff --git a/neutron/cmd/sanitize_port_mac_addresses.py b/neutron/cmd/sanitize_port_mac_addresses.py index 61762e5350e..20af0a605e3 100644 --- a/neutron/cmd/sanitize_port_mac_addresses.py +++ b/neutron/cmd/sanitize_port_mac_addresses.py @@ -17,6 +17,7 @@ from oslo_config import cfg from oslo_db import options as db_options from oslo_log import log as logging +from neutron.common import config as common_config from neutron.db import models_v2 @@ -25,6 +26,7 @@ LOG = logging.getLogger(__name__) def setup_conf(): conf = cfg.CONF + common_config.register_common_config_options() db_group, neutron_db_opts = db_options.list_opts()[0] cfg.CONF.register_cli_opts(neutron_db_opts, db_group) conf() diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index db19f15cdee..69af3f5a501 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -37,6 +37,7 @@ LOG = logging.getLogger(__name__) def setup_conf(): + config.register_common_config_options() ovs_conf.register_ovs_agent_opts(cfg.CONF) lb_conf.register_linuxbridge_opts(cfg.CONF) sriov_conf.register_agent_sriov_nic_opts(cfg.CONF) diff --git a/neutron/cmd/status.py b/neutron/cmd/status.py index b25435a2d18..4941b6b589b 100644 --- a/neutron/cmd/status.py +++ b/neutron/cmd/status.py @@ -18,6 +18,7 @@ from oslo_db import options as db_options from oslo_log import log as logging from oslo_upgradecheck import upgradecheck +from neutron.common import config as common_config from neutron.conf import common as neutron_conf_base from neutron.conf import service as neutron_conf_service @@ -50,7 +51,7 @@ def setup_conf(conf=cfg.CONF): Use separate setup_conf for the utility because there are many options from the main config that do not apply during checks. """ - + common_config.register_common_config_options() neutron_conf_base.register_core_common_config_opts(conf) neutron_conf_service.register_service_opts( neutron_conf_service.SERVICE_OPTS, cfg.CONF) diff --git a/neutron/common/config.py b/neutron/common/config.py index 5eaae86ed64..bd2f0e037f6 100644 --- a/neutron/common/config.py +++ b/neutron/common/config.py @@ -37,6 +37,8 @@ from neutron import version LOG = logging.getLogger(__name__) +_COMMON_OPTIONS_ALREADY_REGISTERED = False + # Jam here any extra log level default you care about. This helps keep # Neutron logs lean. EXTRA_LOG_LEVEL_DEFAULTS = [ @@ -46,40 +48,46 @@ EXTRA_LOG_LEVEL_DEFAULTS = [ 'os_ken.controller.controller=INFO', ] -# Register the configuration options -common_config.register_core_common_config_opts() -# Ensure that the control exchange is set correctly -oslo_messaging.set_transport_defaults(control_exchange='neutron') +def register_common_config_options(): + global _COMMON_OPTIONS_ALREADY_REGISTERED + if _COMMON_OPTIONS_ALREADY_REGISTERED: + return + # Register the configuration options + common_config.register_core_common_config_opts() -NOVA_CONF_SECTION = 'nova' + # Ensure that the control exchange is set correctly + oslo_messaging.set_transport_defaults(control_exchange='neutron') -ks_loading.register_auth_conf_options(cfg.CONF, NOVA_CONF_SECTION) -ks_loading.register_session_conf_options(cfg.CONF, NOVA_CONF_SECTION) + ks_loading.register_auth_conf_options( + cfg.CONF, common_config.NOVA_CONF_SECTION) + ks_loading.register_session_conf_options( + cfg.CONF, common_config.NOVA_CONF_SECTION) + # Register the nova configuration options + common_config.register_nova_opts() -# Register the nova configuration options -common_config.register_nova_opts() + ks_loading.register_auth_conf_options(cfg.CONF, + common_config.PLACEMENT_CONF_SECTION) + ks_loading.register_session_conf_options( + cfg.CONF, common_config.PLACEMENT_CONF_SECTION) -ks_loading.register_auth_conf_options(cfg.CONF, - common_config.PLACEMENT_CONF_SECTION) -ks_loading.register_session_conf_options(cfg.CONF, - common_config.PLACEMENT_CONF_SECTION) + # Register the placement configuration options + common_config.register_placement_opts() -# Register the placement configuration options -common_config.register_placement_opts() + logging.register_options(cfg.CONF) -logging.register_options(cfg.CONF) + # Register the ironic configuration options + ks_loading.register_auth_conf_options(cfg.CONF, + common_config.IRONIC_CONF_SECTION) + ks_loading.register_session_conf_options(cfg.CONF, + common_config.IRONIC_CONF_SECTION) + ks_loading.register_adapter_conf_options(cfg.CONF, + common_config.IRONIC_CONF_SECTION) + common_config.register_ironic_opts() -# Register the ironic configuration options -ks_loading.register_auth_conf_options(cfg.CONF, - common_config.IRONIC_CONF_SECTION) -ks_loading.register_session_conf_options(cfg.CONF, - common_config.IRONIC_CONF_SECTION) -ks_loading.register_adapter_conf_options(cfg.CONF, - common_config.IRONIC_CONF_SECTION) -common_config.register_ironic_opts() + _COMMON_OPTIONS_ALREADY_REGISTERED = True def init(args, default_config_files=None, **kwargs): diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index 4948e902a48..7ec867349e3 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -27,6 +27,7 @@ from oslo_utils import fileutils from oslo_utils import importutils from neutron._i18n import _ +from neutron.common import config as common_config from neutron.conf.db import migration_cli from neutron.db import migration from neutron.db.migration.connection import DBConnection @@ -651,6 +652,7 @@ def get_engine_config(): def main(): + common_config.register_common_config_options() # Interpret the config file for Python logging. # This line sets up loggers basically. logging_config.fileConfig(neutron_alembic_ini) diff --git a/neutron/debug/shell.py b/neutron/debug/shell.py index 37b5a7e65ae..25715ac0841 100644 --- a/neutron/debug/shell.py +++ b/neutron/debug/shell.py @@ -20,6 +20,7 @@ from oslo_utils import importutils from neutron._i18n import _ from neutron.agent.common import utils +from neutron.common import config as common_config from neutron.conf.agent import common as config from neutron.conf.plugins.ml2.drivers import ovs_conf from neutron.debug import debug_agent @@ -86,5 +87,6 @@ class NeutronDebugShell(shell.NeutronShell): def main(argv=None): + common_config.register_common_config_options() return NeutronDebugShell(shell.NEUTRON_API_VERSION).run( argv or sys.argv[1:]) diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py index 39d8d879967..1c11f0c82fc 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -1012,6 +1012,7 @@ class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin, def main(): + common_config.register_common_config_options() common_config.init(sys.argv[1:]) common_config.setup_logging() diff --git a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py index af1f5d586d2..8255d1eb067 100644 --- a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py @@ -206,6 +206,7 @@ def validate_firewall_driver(): def main(): + common_config.register_common_config_options() common_config.init(sys.argv[1:]) common_config.setup_logging() diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py index e0e0b30291a..e552aba48a1 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py @@ -537,6 +537,7 @@ class SriovNicAgentConfigParser(object): def main(): + common_config.register_common_config_options() common_config.init(sys.argv[1:]) common_config.setup_logging() diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/main.py b/neutron/plugins/ml2/drivers/openvswitch/agent/main.py index 59709f3638f..9d5911e21d3 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/main.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/main.py @@ -30,6 +30,7 @@ cfg.CONF.import_group('OVS', 'neutron.plugins.ml2.drivers.openvswitch.agent.' def main(): + common_config.register_common_config_options() common_config.init(sys.argv[1:]) of_main.init_config() common_config.setup_logging() diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 1b52efd187d..29bfd4a5128 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -646,7 +646,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, def _add_port_to_updated_smartnic_ports(self, mac, vif_name, iface_id, vif_type, vm_uuid='', - mtu=plugin_utils.get_deployment_physnet_mtu()): + mtu=None): + if mtu is None: + mtu = plugin_utils.get_deployment_physnet_mtu() self.updated_smartnic_ports.append({ 'mac': mac, 'vm_uuid': vm_uuid, diff --git a/neutron/server/__init__.py b/neutron/server/__init__.py index f3cbe17c2c5..db729626ec1 100644 --- a/neutron/server/__init__.py +++ b/neutron/server/__init__.py @@ -52,7 +52,7 @@ def _get_config_files(env=None): def _init_configuration(): # the configuration will be read into the cfg.CONF global data structure conf_files = _get_config_files() - + config.register_common_config_options() config.init(sys.argv[1:], default_config_files=conf_files) config.setup_logging() config.set_config_defaults() diff --git a/neutron/services/metering/agents/metering_agent.py b/neutron/services/metering/agents/metering_agent.py index 1bc950d2ffd..36600202e4c 100644 --- a/neutron/services/metering/agents/metering_agent.py +++ b/neutron/services/metering/agents/metering_agent.py @@ -395,6 +395,7 @@ class MeteringAgentWithStateReport(MeteringAgent): def main(): conf = cfg.CONF + common_config.register_common_config_options() metering_agent.register_metering_agent_opts() config.register_agent_state_opts_helper(conf) common_config.init(sys.argv[1:]) diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 14aa07a77ff..7e5d9bb7c71 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -62,7 +62,6 @@ from neutron.tests import post_mortem_debug CONF = cfg.CONF -CONF.import_opt('state_path', 'neutron.conf.common') ROOTDIR = os.path.dirname(__file__) ETCDIR = os.path.join(ROOTDIR, 'etc') @@ -383,6 +382,7 @@ class BaseTestCase(DietTestCase): self.useFixture(lockutils.ExternalLockFixture()) self.useFixture(fixture.APIDefinitionFixture()) + config.register_common_config_options() cfg.CONF.set_override('state_path', self.get_default_temp_dir().path) self.addCleanup(CONF.reset) diff --git a/neutron/tests/fullstack/agents/dhcp_agent.py b/neutron/tests/fullstack/agents/dhcp_agent.py index dc1ea5fb70d..d4159f5fd99 100755 --- a/neutron/tests/fullstack/agents/dhcp_agent.py +++ b/neutron/tests/fullstack/agents/dhcp_agent.py @@ -22,6 +22,7 @@ from oslo_utils import uuidutils from neutron.agent.linux import dhcp as linux_dhcp from neutron.cmd.eventlet.agents import dhcp as dhcp_agent +from neutron.common import config OPTS = [ @@ -76,6 +77,7 @@ def monkeypatch_linux_dhcp(): def main(): + config.register_common_config_options() cfg.CONF.register_opts(OPTS) monkeypatch_linux_dhcp() dhcp_agent.main() diff --git a/neutron/tests/fullstack/agents/l3_agent.py b/neutron/tests/fullstack/agents/l3_agent.py index ebc50399f7a..d685d893a21 100755 --- a/neutron/tests/fullstack/agents/l3_agent.py +++ b/neutron/tests/fullstack/agents/l3_agent.py @@ -17,10 +17,12 @@ import sys from oslo_config import cfg # noqa +from neutron.common import config from neutron.common import eventlet_utils from neutron.tests.common.agents import l3_agent eventlet_utils.monkey_patch() if __name__ == "__main__": + config.register_common_config_options() sys.exit(l3_agent.main()) diff --git a/neutron/tests/fullstack/agents/ovs_agent.py b/neutron/tests/fullstack/agents/ovs_agent.py index f10559ba963..6f73ca78c8e 100755 --- a/neutron/tests/fullstack/agents/ovs_agent.py +++ b/neutron/tests/fullstack/agents/ovs_agent.py @@ -21,6 +21,7 @@ from oslo_config import cfg from neutron.agent.common import ovs_lib from neutron.agent.common import polling from neutron.agent.l2.extensions import qos as qos_extension +from neutron.common import config from neutron.services.trunk.drivers.openvswitch.agent \ import driver as trunk_driver from neutron.tests.common.agents import ovs_agent @@ -61,6 +62,7 @@ def main(): # https://review.opendev.org/#/c/506722/ will be merged and ovsdb-server # ovs-vswitchd processes for each test will be isolated in separate # namespace + config.register_common_config_options() monkeypatch_init_handler() monkeypatch_qos() monkeypatch_event_filtering() diff --git a/neutron/tests/fullstack/servers/placement.py b/neutron/tests/fullstack/servers/placement.py index c19eab327f9..fce770b707c 100755 --- a/neutron/tests/fullstack/servers/placement.py +++ b/neutron/tests/fullstack/servers/placement.py @@ -135,6 +135,7 @@ class FakePlacement(object): if __name__ == "__main__": + common_config.register_common_config_options() common_config.init(sys.argv[1:]) common_config.setup_logging() placement_port = cfg.CONF.placement_port diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 037b6fdc811..34c4e1fea84 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -27,6 +27,7 @@ import sqlalchemy from sqlalchemy import event # noqa from sqlalchemy.sql import ddl as sqla_ddl +from neutron.common import config from neutron.db import migration as migration_root from neutron.db.migration.alembic_migrations import external from neutron.db.migration import cli as migration @@ -35,7 +36,6 @@ from neutron.tests import base as test_base from neutron.tests.functional import base as functional_base from neutron.tests.unit import testlib_api -cfg.CONF.import_opt('core_plugin', 'neutron.conf.common') CREATION_OPERATIONS = { 'sqla': (sqla_ddl.CreateIndex, @@ -143,6 +143,7 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): TIMEOUT_SCALING_FACTOR = 4 def setUp(self): + config.register_common_config_options() super(_TestModelsMigrations, self).setUp() self.cfg = self.useFixture(config_fixture.Config()) self.cfg.config(core_plugin='ml2')