From d8cf7fd7c56fecaf43941d815f07e7d77c284aff Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 3 Jun 2014 12:39:17 +0200 Subject: [PATCH] Configure agents using neutron.common.config.init (formerly .parse) After oslo.messaging port is done, we'll need to initialize RPC layer from all RPC agents. We'll put initialization into init() function, so the first step for migration is to make agents use it. The function is renamed to be explicit about the fact that we don't just parse configuration by calling it, but also do other common initializations, like setting RPC layer. blueprint oslo-messaging Change-Id: I71c62f270ac7a1ff1426a3f49a32133b65580e35 --- neutron/agent/dhcp_agent.py | 4 +++- neutron/agent/l3_agent.py | 5 ++++- neutron/agent/metadata/agent.py | 3 ++- neutron/cmd/sanity_check.py | 2 +- neutron/cmd/usage_audit.py | 4 +++- neutron/common/config.py | 2 +- .../plugins/bigswitch/agent/restproxy_agent.py | 2 +- .../plugins/hyperv/agent/hyperv_neutron_agent.py | 7 ++++--- neutron/plugins/ibm/agent/sdnve_neutron_agent.py | 7 ++++--- .../agent/linuxbridge_neutron_agent.py | 6 +++--- .../plugins/mlnx/agent/eswitch_neutron_agent.py | 6 +++--- neutron/plugins/nec/agent/nec_neutron_agent.py | 7 ++++--- .../oneconvergence/agent/nvsd_neutron_agent.py | 7 ++++--- .../openvswitch/agent/ovs_neutron_agent.py | 6 +++--- neutron/plugins/ryu/agent/ryu_neutron_agent.py | 6 +++--- neutron/plugins/vmware/check_nsx_config.py | 2 +- neutron/server/__init__.py | 2 +- .../firewall/agents/varmour/varmour_router.py | 5 ++++- neutron/services/loadbalancer/agent/agent.py | 5 ++++- .../services/metering/agents/metering_agent.py | 4 +++- neutron/tests/base.py | 2 +- .../tests/unit/bigswitch/test_restproxy_agent.py | 3 ++- .../unit/hyperv/test_hyperv_neutron_agent.py | 15 ++++++--------- .../drivers/cisco/apic/test_cisco_apic_common.py | 2 +- neutron/tests/unit/nec/test_nec_agent.py | 6 +++--- .../tests/unit/oneconvergence/test_nvsd_agent.py | 6 +++--- neutron/tests/unit/ryu/test_ryu_agent.py | 6 +++--- neutron/tests/unit/test_debug_commands.py | 3 ++- neutron/tests/unit/test_dhcp_agent.py | 3 ++- 29 files changed, 79 insertions(+), 59 deletions(-) diff --git a/neutron/agent/dhcp_agent.py b/neutron/agent/dhcp_agent.py index 4b62e0dd85..5cdb30d0e6 100644 --- a/neutron/agent/dhcp_agent.py +++ b/neutron/agent/dhcp_agent.py @@ -16,6 +16,7 @@ # under the License. import os +import sys import eventlet eventlet.monkey_patch() @@ -29,6 +30,7 @@ from neutron.agent.linux import external_process from neutron.agent.linux import interface from neutron.agent.linux import ovs_lib # noqa from neutron.agent import rpc as agent_rpc +from neutron.common import config as common_config from neutron.common import constants from neutron.common import exceptions from neutron.common import rpc_compat @@ -610,7 +612,7 @@ def register_options(): def main(): register_options() - cfg.CONF(project='neutron') + common_config.init(sys.argv[1:]) config.setup_logging(cfg.CONF) server = neutron_service.Service.create( binary='neutron-dhcp-agent', diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index 7b3df470ed..7dcb81e3b4 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -13,6 +13,8 @@ # under the License. # +import sys + import eventlet eventlet.monkey_patch() @@ -26,6 +28,7 @@ from neutron.agent.linux import ip_lib from neutron.agent.linux import iptables_manager from neutron.agent.linux import ovs_lib # noqa from neutron.agent import rpc as agent_rpc +from neutron.common import config as common_config from neutron.common import constants as l3_constants from neutron.common import rpc_compat from neutron.common import topics @@ -977,7 +980,7 @@ def main(manager='neutron.agent.l3_agent.L3NATAgentWithStateReport'): config.register_root_helper(conf) conf.register_opts(interface.OPTS) conf.register_opts(external_process.OPTS) - conf(project='neutron') + common_config.init(sys.argv[1:]) config.setup_logging(conf) server = neutron_service.Service.create( binary='neutron-l3-agent', diff --git a/neutron/agent/metadata/agent.py b/neutron/agent/metadata/agent.py index c38e4fe4bf..52ffa91210 100644 --- a/neutron/agent/metadata/agent.py +++ b/neutron/agent/metadata/agent.py @@ -20,6 +20,7 @@ import hashlib import hmac import os import socket +import sys import eventlet eventlet.monkey_patch() @@ -384,7 +385,7 @@ def main(): cache.register_oslo_configs(cfg.CONF) cfg.CONF.set_default(name='cache_url', default='memory://?default_ttl=5') agent_conf.register_agent_state_opts_helper(cfg.CONF) - cfg.CONF(project='neutron') + config.init(sys.argv[1:]) config.setup_logging(cfg.CONF) utils.log_opt_values(LOG) proxy = UnixDomainMetadataProxy(cfg.CONF) diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index aab8d96c07..b068fcb00b 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -85,7 +85,7 @@ def main(): cfg.CONF.register_cli_opts(OPTS) cfg.CONF.set_override('use_stderr', True) config.setup_logging(cfg.CONF) - config.parse(sys.argv[1:], default_config_files=[]) + config.init(sys.argv[1:], default_config_files=[]) if cfg.CONF.config_file: enable_tests_from_config() diff --git a/neutron/cmd/usage_audit.py b/neutron/cmd/usage_audit.py index 01e77c77a2..f48e0c691c 100644 --- a/neutron/cmd/usage_audit.py +++ b/neutron/cmd/usage_audit.py @@ -21,6 +21,8 @@ subnets. """ +import sys + from oslo.config import cfg from neutron.common import config @@ -30,7 +32,7 @@ from neutron.openstack.common.notifier import api as notifier_api def main(): - cfg.CONF(project='neutron') + config.init(sys.argv[1:]) config.setup_logging(cfg.CONF) cxt = context.get_admin_context() diff --git a/neutron/common/config.py b/neutron/common/config.py index 1340ef2aed..a7b7a95594 100644 --- a/neutron/common/config.py +++ b/neutron/common/config.py @@ -134,7 +134,7 @@ db_options.set_defaults(sql_connection=_SQL_CONNECTION_DEFAULT, max_overflow=20, pool_timeout=10) -def parse(args, **kwargs): +def init(args, **kwargs): cfg.CONF(args=args, project='neutron', version='%%prog %s' % version.version_info.release_string(), **kwargs) diff --git a/neutron/plugins/bigswitch/agent/restproxy_agent.py b/neutron/plugins/bigswitch/agent/restproxy_agent.py index 7b95f3554d..a9c1e6653a 100644 --- a/neutron/plugins/bigswitch/agent/restproxy_agent.py +++ b/neutron/plugins/bigswitch/agent/restproxy_agent.py @@ -166,7 +166,7 @@ class RestProxyAgent(rpc_compat.RpcCallback, def main(): - cfg.CONF(project='neutron') + config.init(sys.argv[1:]) config.setup_logging(cfg.CONF) pl_config.register_config() diff --git a/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py b/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py index df9673cd77..3447356257 100644 --- a/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py +++ b/neutron/plugins/hyperv/agent/hyperv_neutron_agent.py @@ -20,6 +20,7 @@ import platform import re +import sys import time import eventlet @@ -30,7 +31,7 @@ from oslo.config import cfg from neutron.agent.common import config from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants as n_const from neutron.common import rpc_compat from neutron.common import topics @@ -472,8 +473,8 @@ class HyperVNeutronAgent(rpc_compat.RpcCallback): def main(): - cfg.CONF(project='neutron') - logging_config.setup_logging(cfg.CONF) + common_config.init(sys.argv[1:]) + common_config.setup_logging(cfg.CONF) plugin = HyperVNeutronAgent() diff --git a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py index e4f296fc4c..1a5190d90e 100644 --- a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py +++ b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py @@ -18,6 +18,7 @@ import socket +import sys import time import eventlet @@ -28,7 +29,7 @@ from oslo.config import cfg from neutron.agent.linux import ip_lib from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants as n_const from neutron.common import rpc_compat from neutron.common import topics @@ -257,8 +258,8 @@ def create_agent_config_map(config): def main(): cfg.CONF.register_opts(ip_lib.OPTS) - cfg.CONF(project='neutron') - logging_config.setup_logging(cfg.CONF) + common_config.init(sys.argv[1:]) + common_config.setup_logging(cfg.CONF) try: agent_config = create_agent_config_map(cfg.CONF) diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index 06357a493b..d586b2eb9e 100755 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -36,7 +36,7 @@ from neutron.agent.linux import ip_lib from neutron.agent.linux import utils from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants from neutron.common import exceptions from neutron.common import rpc_compat @@ -1029,9 +1029,9 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin): def main(): - cfg.CONF(project='neutron') + common_config.init(sys.argv[1:]) - logging_config.setup_logging(cfg.CONF) + common_config.setup_logging(cfg.CONF) try: interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) diff --git a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py index 56366724d9..90a97ce443 100644 --- a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py +++ b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py @@ -27,7 +27,7 @@ from oslo.config import cfg from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants as q_constants from neutron.common import rpc_compat from neutron.common import topics @@ -421,8 +421,8 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin): def main(): - cfg.CONF(project='neutron') - logging_config.setup_logging(cfg.CONF) + common_config.init(sys.argv[1:]) + common_config.setup_logging(cfg.CONF) try: interface_mappings = q_utils.parse_mappings( diff --git a/neutron/plugins/nec/agent/nec_neutron_agent.py b/neutron/plugins/nec/agent/nec_neutron_agent.py index 5a5faff7f9..38b13b5b7c 100755 --- a/neutron/plugins/nec/agent/nec_neutron_agent.py +++ b/neutron/plugins/nec/agent/nec_neutron_agent.py @@ -21,6 +21,7 @@ # @author: Akihiro MOTOKI import socket +import sys import time import eventlet @@ -29,7 +30,7 @@ eventlet.monkey_patch() from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants as q_const from neutron.common import rpc_compat from neutron.common import topics @@ -234,9 +235,9 @@ class NECNeutronAgent(object): def main(): - config.CONF(project='neutron') + common_config.init(sys.argv[1:]) - logging_config.setup_logging(config.CONF) + common_config.setup_logging(config.CONF) # Determine which agent type to use. integ_br = config.OVS.integration_bridge diff --git a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py index d291df508d..d1d3daf6ef 100644 --- a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py +++ b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py @@ -17,6 +17,7 @@ """NVSD agent code for security group events.""" import socket +import sys import time import eventlet @@ -25,7 +26,7 @@ eventlet.monkey_patch() from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import rpc_compat from neutron.common import topics from neutron import context as n_context @@ -164,8 +165,8 @@ class NVSDNeutronAgent(rpc_compat.RpcCallback): def main(): - config.CONF(project='neutron') - logging_config.setup_logging(config.CONF) + common_config.init(sys.argv[1:]) + common_config.setup_logging(config.CONF) integ_br = config.AGENT.integration_bridge root_helper = config.AGENT.root_helper diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 3ee1e4278d..c44fd191d5 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -33,7 +33,7 @@ from neutron.agent.linux import polling from neutron.agent.linux import utils from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import constants as q_const from neutron.common import rpc_compat from neutron.common import topics @@ -1502,8 +1502,8 @@ def create_agent_config_map(config): def main(): cfg.CONF.register_opts(ip_lib.OPTS) - cfg.CONF(project='neutron') - logging_config.setup_logging(cfg.CONF) + common_config.init(sys.argv[1:]) + common_config.setup_logging(cfg.CONF) q_utils.log_opt_values(LOG) try: diff --git a/neutron/plugins/ryu/agent/ryu_neutron_agent.py b/neutron/plugins/ryu/agent/ryu_neutron_agent.py index 092dc8702e..746a0c2f54 100755 --- a/neutron/plugins/ryu/agent/ryu_neutron_agent.py +++ b/neutron/plugins/ryu/agent/ryu_neutron_agent.py @@ -35,7 +35,7 @@ from neutron.agent.linux import ip_lib from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc -from neutron.common import config as logging_config +from neutron.common import config as common_config from neutron.common import exceptions as n_exc from neutron.common import rpc_compat from neutron.common import topics @@ -286,9 +286,9 @@ class OVSNeutronOFPRyuAgent(rpc_compat.RpcCallback, def main(): - cfg.CONF(project='neutron') + common_config.init(sys.argv[1:]) - logging_config.setup_logging(cfg.CONF) + common_config.setup_logging(cfg.CONF) integ_br = cfg.CONF.OVS.integration_bridge polling_interval = cfg.CONF.AGENT.polling_interval diff --git a/neutron/plugins/vmware/check_nsx_config.py b/neutron/plugins/vmware/check_nsx_config.py index 4fdcdc7ecd..14eca41cb3 100644 --- a/neutron/plugins/vmware/check_nsx_config.py +++ b/neutron/plugins/vmware/check_nsx_config.py @@ -90,7 +90,7 @@ def main(): help(sys.argv[0]) args = ['--config-file'] args.append(sys.argv[1]) - config.parse(args) + config.init(args) print("----------------------- Database Options -----------------------") print("\tconnection: %s" % cfg.CONF.database.connection) print("\tretry_interval: %d" % cfg.CONF.database.retry_interval) diff --git a/neutron/server/__init__.py b/neutron/server/__init__.py index fedefa079d..eb34ad8510 100755 --- a/neutron/server/__init__.py +++ b/neutron/server/__init__.py @@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__) def main(): # the configuration will be read into the cfg.CONF global data structure - config.parse(sys.argv[1:]) + config.init(sys.argv[1:]) if not cfg.CONF.config_file: sys.exit(_("ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" diff --git a/neutron/services/firewall/agents/varmour/varmour_router.py b/neutron/services/firewall/agents/varmour/varmour_router.py index 881127b151..952a452b1d 100755 --- a/neutron/services/firewall/agents/varmour/varmour_router.py +++ b/neutron/services/firewall/agents/varmour/varmour_router.py @@ -18,6 +18,8 @@ # @author: Gary Duan, vArmour Networks Inc. # +import sys + import eventlet eventlet.monkey_patch() @@ -29,6 +31,7 @@ from neutron.agent import l3_agent from neutron.agent.linux import external_process from neutron.agent.linux import interface from neutron.agent.linux import ip_lib +from neutron.common import config as common_config from neutron.common import constants as l3_constants from neutron.common import topics from neutron.openstack.common import log as logging @@ -337,7 +340,7 @@ def main(): config.register_root_helper(conf) conf.register_opts(interface.OPTS) conf.register_opts(external_process.OPTS) - conf(project='neutron') + common_config.init(sys.argv[1:]) config.setup_logging(conf) server = neutron_service.Service.create( binary='neutron-l3-agent', diff --git a/neutron/services/loadbalancer/agent/agent.py b/neutron/services/loadbalancer/agent/agent.py index 7a830c6315..84de61b131 100644 --- a/neutron/services/loadbalancer/agent/agent.py +++ b/neutron/services/loadbalancer/agent/agent.py @@ -16,6 +16,8 @@ # # @author: Mark McClain, DreamHost +import sys + import eventlet eventlet.monkey_patch() @@ -23,6 +25,7 @@ from oslo.config import cfg from neutron.agent.common import config from neutron.agent.linux import interface +from neutron.common import config as common_config from neutron.common import rpc_compat from neutron.common import topics from neutron.openstack.common import service @@ -57,7 +60,7 @@ def main(): config.register_agent_state_opts_helper(cfg.CONF) config.register_root_helper(cfg.CONF) - cfg.CONF(project='neutron') + common_config.init(sys.argv[1:]) config.setup_logging(cfg.CONF) mgr = manager.LbaasAgentManager(cfg.CONF) diff --git a/neutron/services/metering/agents/metering_agent.py b/neutron/services/metering/agents/metering_agent.py index d1bd3c965d..ba1fe6bac2 100644 --- a/neutron/services/metering/agents/metering_agent.py +++ b/neutron/services/metering/agents/metering_agent.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import sys import time import eventlet @@ -23,6 +24,7 @@ from oslo.config import cfg from neutron.agent.common import config from neutron.agent import rpc as agent_rpc +from neutron.common import config as common_config from neutron.common import constants as constants from neutron.common import rpc_compat from neutron.common import topics @@ -287,7 +289,7 @@ def main(): conf.register_opts(MeteringAgent.Opts) config.register_agent_state_opts_helper(conf) config.register_root_helper(conf) - conf(project='neutron') + common_config.init(sys.argv[1:]) config.setup_logging(conf) server = neutron_service.Service.create( binary='neutron-metering-agent', diff --git a/neutron/tests/base.py b/neutron/tests/base.py index eb1611af84..87412f9244 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -109,7 +109,7 @@ class BaseTestCase(testtools.TestCase): if args is None: args = ['--config-file', etcdir('neutron.conf.test')] if conf is None: - config.parse(args=args) + config.init(args=args) else: conf(args) diff --git a/neutron/tests/unit/bigswitch/test_restproxy_agent.py b/neutron/tests/unit/bigswitch/test_restproxy_agent.py index 258ab1a0a8..4c961df7df 100644 --- a/neutron/tests/unit/bigswitch/test_restproxy_agent.py +++ b/neutron/tests/unit/bigswitch/test_restproxy_agent.py @@ -166,9 +166,10 @@ class TestRestProxyAgent(BaseAgentTestCase): 'CONF.AGENT.root_helper': 'helper'} with contextlib.nested( mock.patch(AGENTMOD + '.cfg', **cfg_attrs), + mock.patch(AGENTMOD + '.config.init'), mock.patch(NEUTRONCFG), mock.patch(PLCONFIG), - ) as (mock_conf, mock_log_conf, mock_pluginconf): + ) as (mock_conf, mock_init, mock_log_conf, mock_pluginconf): self.mod_agent.main() mock_log_conf.assert_has_calls([ diff --git a/neutron/tests/unit/hyperv/test_hyperv_neutron_agent.py b/neutron/tests/unit/hyperv/test_hyperv_neutron_agent.py index 8b472e8cbc..5d2a24c0d5 100644 --- a/neutron/tests/unit/hyperv/test_hyperv_neutron_agent.py +++ b/neutron/tests/unit/hyperv/test_hyperv_neutron_agent.py @@ -212,13 +212,10 @@ class TestHyperVNeutronAgent(base.BaseTestCase): def test_main(self): with mock.patch.object(hyperv_neutron_agent, 'HyperVNeutronAgent') as plugin: - with mock.patch.object(hyperv_neutron_agent.cfg, 'CONF') as cfg: - with mock.patch.object( - hyperv_neutron_agent, - 'logging_config') as logging_config: + with mock.patch.object(hyperv_neutron_agent, + 'common_config') as common_config: + hyperv_neutron_agent.main() - hyperv_neutron_agent.main() - - self.assertTrue(cfg.called) - self.assertTrue(logging_config.setup_logging.called) - plugin.assert_has_calls([mock.call().daemon_loop()]) + self.assertTrue(common_config.init.called) + self.assertTrue(common_config.setup_logging.called) + plugin.assert_has_calls([mock.call().daemon_loop()]) diff --git a/neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_common.py b/neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_common.py index 7a8f8e9d59..e150c1f093 100644 --- a/neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_common.py +++ b/neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_common.py @@ -170,7 +170,7 @@ class ConfigMixin(object): def set_up_mocks(self): # Mock the configuration file args = ['--config-file', base.etcdir('neutron.conf.test')] - neutron_config.parse(args=args) + neutron_config.init(args=args) # Configure the ML2 mechanism drivers and network types ml2_opts = { diff --git a/neutron/tests/unit/nec/test_nec_agent.py b/neutron/tests/unit/nec/test_nec_agent.py index 16e4031c57..26396aeb9a 100644 --- a/neutron/tests/unit/nec/test_nec_agent.py +++ b/neutron/tests/unit/nec/test_nec_agent.py @@ -350,16 +350,16 @@ class TestNecAgentMain(base.BaseTestCase): def test_main(self): with contextlib.nested( mock.patch.object(nec_neutron_agent, 'NECNeutronAgent'), - mock.patch.object(nec_neutron_agent, 'logging_config'), + mock.patch.object(nec_neutron_agent, 'common_config'), mock.patch.object(nec_neutron_agent, 'config') - ) as (agent, logging_config, cfg): + ) as (agent, common_config, cfg): cfg.OVS.integration_bridge = 'br-int-x' cfg.AGENT.root_helper = 'dummy-helper' cfg.AGENT.polling_interval = 10 nec_neutron_agent.main() - self.assertTrue(logging_config.setup_logging.called) + self.assertTrue(common_config.setup_logging.called) agent.assert_has_calls([ mock.call('br-int-x', 'dummy-helper', 10), mock.call().daemon_loop() diff --git a/neutron/tests/unit/oneconvergence/test_nvsd_agent.py b/neutron/tests/unit/oneconvergence/test_nvsd_agent.py index 1a98c1274c..f04d2fecb1 100644 --- a/neutron/tests/unit/oneconvergence/test_nvsd_agent.py +++ b/neutron/tests/unit/oneconvergence/test_nvsd_agent.py @@ -161,16 +161,16 @@ class TestOneConvergenceAgentMain(base.BaseTestCase): def test_main(self): with contextlib.nested( mock.patch.object(nvsd_neutron_agent, 'NVSDNeutronAgent'), - mock.patch.object(nvsd_neutron_agent, 'logging_config'), + mock.patch.object(nvsd_neutron_agent, 'common_config'), mock.patch.object(nvsd_neutron_agent, 'config') - ) as (agent, logging_config, config): + ) as (agent, common_config, config): config.AGENT.integration_bridge = 'br-int-dummy' config.AGENT.root_helper = 'root-helper' config.AGENT.polling_interval = 5 nvsd_neutron_agent.main() - self.assertTrue(logging_config.setup_logging.called) + self.assertTrue(common_config.setup_logging.called) agent.assert_has_calls([ mock.call('br-int-dummy', 'root-helper', 5), mock.call().daemon_loop() diff --git a/neutron/tests/unit/ryu/test_ryu_agent.py b/neutron/tests/unit/ryu/test_ryu_agent.py index 415e90135c..756b39d045 100644 --- a/neutron/tests/unit/ryu/test_ryu_agent.py +++ b/neutron/tests/unit/ryu/test_ryu_agent.py @@ -610,15 +610,15 @@ class TestRyuNeutronAgent(RyuAgentTestCase): 'CONF.AGENT.root_helper': 'helper'} with contextlib.nested( mock.patch(self._AGENT_NAME + '.cfg', **cfg_attrs), - mock.patch(self._AGENT_NAME + '.logging_config'), + mock.patch(self._AGENT_NAME + '.common_config'), mock.patch(self._AGENT_NAME + '._get_tunnel_ip', return_value='10.0.0.1'), mock.patch(self._AGENT_NAME + '._get_ovsdb_ip', return_value='172.16.0.1'), - ) as (mock_conf, mock_log_conf, _tun, _ovsdb): + ) as (mock_conf, mock_common_conf, _tun, _ovsdb): self.mod_agent.main() - mock_log_conf.assert_has_calls([ + mock_common_conf.assert_has_calls([ mock.call(mock_conf) ]) diff --git a/neutron/tests/unit/test_debug_commands.py b/neutron/tests/unit/test_debug_commands.py index 85f7773560..16b6c8dda3 100644 --- a/neutron/tests/unit/test_debug_commands.py +++ b/neutron/tests/unit/test_debug_commands.py @@ -22,6 +22,7 @@ from oslo.config import cfg from neutron.agent.common import config from neutron.agent.linux import interface +from neutron.common import config as common_config from neutron.debug import commands from neutron.debug import debug_agent from neutron.tests import base @@ -37,7 +38,7 @@ class TestDebugCommands(base.BaseTestCase): super(TestDebugCommands, self).setUp() cfg.CONF.register_opts(interface.OPTS) cfg.CONF.register_opts(debug_agent.NeutronDebugAgent.OPTS) - cfg.CONF(args=[], project='neutron') + common_config.init([]) config.register_interface_driver_opts_helper(cfg.CONF) config.register_use_namespaces_opts_helper(cfg.CONF) config.register_root_helper(cfg.CONF) diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index 0ef431838a..0b0826bb9e 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -28,6 +28,7 @@ from neutron.agent.common import config from neutron.agent import dhcp_agent from neutron.agent.linux import dhcp from neutron.agent.linux import interface +from neutron.common import config as common_config from neutron.common import constants as const from neutron.common import exceptions from neutron.common import rpc_compat @@ -157,7 +158,7 @@ class TestDhcpAgent(base.BaseTestCase): config.register_root_helper(cfg.CONF) cfg.CONF.register_opts(dhcp.OPTS) cfg.CONF.register_opts(interface.OPTS) - cfg.CONF(project='neutron') + common_config.init(sys.argv[1:]) agent_mgr = dhcp_agent.DhcpAgentWithStateReport( 'testhost') eventlet.greenthread.sleep(1)