From 1573b2794c2fd5105e09fa232732c5cbb218541f Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Sat, 17 Nov 2012 22:50:17 +0000 Subject: [PATCH] Remove nova.config.CONF Modules import nova.config for two reasons right now - firstly, to reference nova.config.CONF and, secondly, if they use one of the options defined in nova.config. Often modules import nova.openstack.common.cfg and nova.config which is a bit pointless since they could just use cfg.CONF if they just want to nova.config in order to reference CONF. Let's just use cfg.CONF everywhere and we can explicitly state where we actually require options defined in nova.config. Change-Id: Ie4184a74e3e78c99658becb18dce1c2087e450bb --- bin/nova-all | 3 ++- bin/nova-api | 3 ++- bin/nova-cert | 3 ++- bin/nova-clear-rabbit-queues | 2 +- bin/nova-compute | 3 ++- bin/nova-conductor | 3 ++- bin/nova-console | 3 ++- bin/nova-consoleauth | 3 ++- bin/nova-dhcpbridge | 3 ++- bin/nova-manage | 2 +- bin/nova-network | 3 ++- bin/nova-novncproxy | 2 +- bin/nova-rpc-zmq-receiver | 3 ++- bin/nova-scheduler | 3 ++- nova/scheduler/multi.py | 3 +-- nova/scheduler/rpcapi.py | 3 ++- nova/tests/baremetal/db/base.py | 4 ++-- nova/tests/declare_flags.py | 3 +-- nova/tests/fake_flags.py | 3 ++- nova/tests/runtime_flags.py | 3 +-- nova/tests/scheduler/test_least_cost.py | 3 +-- nova/tests/scheduler/test_rpcapi.py | 3 ++- nova/tests/test_api.py | 1 - nova/tests/test_db_api.py | 4 ++-- nova/tests/test_flags.py | 2 +- nova/tests/test_hypervapi.py | 4 ++-- nova/tests/test_imagebackend.py | 4 ++-- nova/tests/test_imagecache.py | 3 ++- nova/tests/test_instance_types.py | 1 - nova/tests/test_libvirt.py | 3 ++- nova/tests/test_libvirt_vif.py | 4 ++-- nova/tests/test_powervm.py | 1 - nova/tests/test_virt.py | 1 - nova/tests/test_vmwareapi.py | 1 - nova/tests/test_xenapi.py | 3 ++- 35 files changed, 52 insertions(+), 44 deletions(-) diff --git a/bin/nova-all b/bin/nova-all index dbbd5088..42c8ffbf 100755 --- a/bin/nova-all +++ b/bin/nova-all @@ -42,13 +42,14 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): from nova import config from nova.objectstore import s3server +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils from nova.vnc import xvp_proxy -CONF = config.CONF +CONF = cfg.CONF LOG = logging.getLogger('nova.all') if __name__ == '__main__': diff --git a/bin/nova-api b/bin/nova-api index 5bb7f31b..6d3304a9 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -37,11 +37,12 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/bin/nova-cert b/bin/nova-cert index ffda0e54..68d22305 100755 --- a/bin/nova-cert +++ b/bin/nova-cert @@ -33,11 +33,12 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/bin/nova-clear-rabbit-queues b/bin/nova-clear-rabbit-queues index 90e9128f..cf595fec 100755 --- a/bin/nova-clear-rabbit-queues +++ b/bin/nova-clear-rabbit-queues @@ -52,7 +52,7 @@ delete_exchange_opt = cfg.BoolOpt('delete_exchange', default=False, help='delete nova exchange too.') -CONF = config.CONF +CONF = cfg.CONF CONF.register_cli_opt(delete_exchange_opt) diff --git a/bin/nova-compute b/bin/nova-compute index 78f4efd2..c0064142 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -42,11 +42,12 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/bin/nova-conductor b/bin/nova-conductor index 2dba8ee1..5d9e355d 100755 --- a/bin/nova-conductor +++ b/bin/nova-conductor @@ -33,11 +33,12 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('topic', 'nova.conductor.api', group='conductor') if __name__ == '__main__': diff --git a/bin/nova-console b/bin/nova-console index 6a363c1e..6b5b8434 100755 --- a/bin/nova-console +++ b/bin/nova-console @@ -34,10 +34,11 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/bin/nova-consoleauth b/bin/nova-consoleauth index 791ac2de..9a601632 100755 --- a/bin/nova-consoleauth +++ b/bin/nova-consoleauth @@ -33,10 +33,11 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config from nova.consoleauth import manager +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service -CONF = config.CONF +CONF = cfg.CONF if __name__ == "__main__": config.parse_args(sys.argv) diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 21cd5db0..b1081937 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -40,12 +40,13 @@ from nova import context from nova import db from nova.network import linux_net from nova.network import rpcapi as network_rpcapi +from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.openstack.common import rpc from nova import utils -CONF = config.CONF +CONF = cfg.CONF LOG = logging.getLogger('nova.dhcpbridge') diff --git a/bin/nova-manage b/bin/nova-manage index cca67398..565c22a1 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -88,7 +88,7 @@ from nova.scheduler import rpcapi as scheduler_rpcapi from nova import utils from nova import version -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('flat_network_bridge', 'nova.network.manager') CONF.import_opt('num_networks', 'nova.network.manager') CONF.import_opt('multi_host', 'nova.network.manager') diff --git a/bin/nova-network b/bin/nova-network index fe90e4cc..7682b8d0 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -35,11 +35,12 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/bin/nova-novncproxy b/bin/nova-novncproxy index ad901656..e774c01e 100755 --- a/bin/nova-novncproxy +++ b/bin/nova-novncproxy @@ -67,7 +67,7 @@ opts = [ help='Port on which to listen for incoming requests'), ] -CONF = config.CONF +CONF = cfg.CONF CONF.register_cli_opts(opts) LOG = logging.getLogger(__name__) diff --git a/bin/nova-rpc-zmq-receiver b/bin/nova-rpc-zmq-receiver index e9093f1a..f89b0b3b 100755 --- a/bin/nova-rpc-zmq-receiver +++ b/bin/nova-rpc-zmq-receiver @@ -34,12 +34,13 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config from nova import exception +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.openstack.common import rpc from nova.openstack.common.rpc import impl_zmq from nova import utils -CONF = config.CONF +CONF = cfg.CONF CONF.register_opts(rpc.rpc_opts) CONF.register_opts(impl_zmq.zmq_opts) diff --git a/bin/nova-scheduler b/bin/nova-scheduler index 7730c5cb..e623b5fc 100755 --- a/bin/nova-scheduler +++ b/bin/nova-scheduler @@ -37,11 +37,12 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): gettext.install('nova', unicode=1) from nova import config +from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils -CONF = config.CONF +CONF = cfg.CONF if __name__ == '__main__': config.parse_args(sys.argv) diff --git a/nova/scheduler/multi.py b/nova/scheduler/multi.py index 98888163..a92e0955 100644 --- a/nova/scheduler/multi.py +++ b/nova/scheduler/multi.py @@ -27,7 +27,6 @@ schedule requests to compute nodes but provide their own manager and topic. https://bugs.launchpad.net/nova/+bug/1009681 """ -from nova import config from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.scheduler import driver @@ -43,7 +42,7 @@ multi_scheduler_opts = [ help='Default driver to use for scheduling calls'), ] -CONF = config.CONF +CONF = cfg.CONF CONF.register_opts(multi_scheduler_opts) diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py index b0c83d69..5ddc65c5 100644 --- a/nova/scheduler/rpcapi.py +++ b/nova/scheduler/rpcapi.py @@ -19,10 +19,11 @@ Client side of the scheduler manager RPC API. """ from nova import config +from nova.openstack.common import cfg from nova.openstack.common import jsonutils import nova.openstack.common.rpc.proxy -CONF = config.CONF +CONF = cfg.CONF class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy): diff --git a/nova/tests/baremetal/db/base.py b/nova/tests/baremetal/db/base.py index 83abcb58..ea5a3b42 100644 --- a/nova/tests/baremetal/db/base.py +++ b/nova/tests/baremetal/db/base.py @@ -15,15 +15,15 @@ """Bare-metal DB test base class.""" -from nova import config from nova import context as nova_context +from nova.openstack.common import cfg from nova import test from nova.virt.baremetal.db import migration as bm_migration from nova.virt.baremetal.db.sqlalchemy import session as bm_session _DB = None -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('baremetal_sql_connection', 'nova.virt.baremetal.db.sqlalchemy.session') diff --git a/nova/tests/declare_flags.py b/nova/tests/declare_flags.py index 615ee35b..47639726 100644 --- a/nova/tests/declare_flags.py +++ b/nova/tests/declare_flags.py @@ -16,8 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. -from nova import config from nova.openstack.common import cfg -CONF = config.CONF +CONF = cfg.CONF CONF.register_opt(cfg.IntOpt('answer', default=42, help='test flag')) diff --git a/nova/tests/fake_flags.py b/nova/tests/fake_flags.py index 65191641..e6ef3f7d 100644 --- a/nova/tests/fake_flags.py +++ b/nova/tests/fake_flags.py @@ -17,8 +17,9 @@ # under the License. from nova import config +from nova.openstack.common import cfg -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('scheduler_driver', 'nova.scheduler.manager') CONF.import_opt('fake_network', 'nova.network.manager') diff --git a/nova/tests/runtime_flags.py b/nova/tests/runtime_flags.py index 33d265cf..fe5fed1e 100644 --- a/nova/tests/runtime_flags.py +++ b/nova/tests/runtime_flags.py @@ -16,8 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. -from nova import config from nova.openstack.common import cfg -CONF = config.CONF +CONF = cfg.CONF CONF.register_opt(cfg.IntOpt('runtime_answer', default=54, help='test flag')) diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py index f8ed20b4..d159d8f4 100644 --- a/nova/tests/scheduler/test_least_cost.py +++ b/nova/tests/scheduler/test_least_cost.py @@ -15,7 +15,6 @@ """ Tests For Least Cost functions. """ -from nova import config from nova import context from nova.openstack.common import cfg from nova.scheduler import weights @@ -33,7 +32,7 @@ test_least_cost_opts = [ help='How much weight to give the fake_weigher2 function'), ] -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('least_cost_functions', 'nova.scheduler.weights.least_cost') CONF.import_opt('compute_fill_first_cost_fn_weight', 'nova.scheduler.weights.least_cost') diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py index 05a792a5..bb6465d3 100644 --- a/nova/tests/scheduler/test_rpcapi.py +++ b/nova/tests/scheduler/test_rpcapi.py @@ -20,11 +20,12 @@ Unit Tests for nova.scheduler.rpcapi from nova import config from nova import context +from nova.openstack.common import cfg from nova.openstack.common import rpc from nova.scheduler import rpcapi as scheduler_rpcapi from nova import test -CONF = config.CONF +CONF = cfg.CONF class SchedulerRpcAPITestCase(test.TestCase): diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index 63630325..cf6e1de9 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -36,7 +36,6 @@ from nova.api import ec2 from nova.api.ec2 import apirequest from nova.api.ec2 import ec2utils from nova import block_device -from nova import config from nova import context from nova import exception from nova.openstack.common import timeutils diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 19337855..8308315d 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -22,16 +22,16 @@ import datetime import uuid as stdlib_uuid -from nova import config from nova import context from nova import db from nova import exception +from nova.openstack.common import cfg from nova.openstack.common import timeutils from nova import test from nova.tests import matchers -CONF = config.CONF +CONF = cfg.CONF CONF.import_opt('reserved_host_memory_mb', 'nova.compute.resource_tracker') CONF.import_opt('reserved_host_disk_mb', 'nova.compute.resource_tracker') diff --git a/nova/tests/test_flags.py b/nova/tests/test_flags.py index b832c95a..dd83c4ff 100644 --- a/nova/tests/test_flags.py +++ b/nova/tests/test_flags.py @@ -21,7 +21,7 @@ from nova import config from nova.openstack.common import cfg from nova import test -CONF = config.CONF +CONF = cfg.CONF CONF.register_opt(cfg.StrOpt('flags_unittest', default='foo', help='for testing purposes only')) diff --git a/nova/tests/test_hypervapi.py b/nova/tests/test_hypervapi.py index dab5d027..1c49fe2f 100644 --- a/nova/tests/test_hypervapi.py +++ b/nova/tests/test_hypervapi.py @@ -26,10 +26,10 @@ import sys import uuid from nova.compute import power_state -from nova import config from nova import context from nova import db from nova.image import glance +from nova.openstack.common import cfg from nova.tests import fake_network from nova.tests.hyperv import basetestcase from nova.tests.hyperv import db_fakes @@ -41,7 +41,7 @@ from nova.virt.hyperv import driver as driver_hyperv from nova.virt.hyperv import vmutils from nova.virt import images -CONF = config.CONF +CONF = cfg.CONF class HyperVAPITestCase(basetestcase.BaseTestCase): diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py index 224127f5..59eccdc4 100644 --- a/nova/tests/test_imagebackend.py +++ b/nova/tests/test_imagebackend.py @@ -17,13 +17,13 @@ import os -from nova import config +from nova.openstack.common import cfg from nova.openstack.common import fileutils from nova import test from nova.tests import fake_libvirt_utils from nova.virt.libvirt import imagebackend -CONF = config.CONF +CONF = cfg.CONF class _ImageTestCase(test.TestCase): diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index 3a1b40c4..3ea99d53 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -29,13 +29,14 @@ from nova.compute import manager as compute_manager from nova.compute import vm_states from nova import config from nova import db +from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import log from nova import utils from nova.virt.libvirt import imagecache from nova.virt.libvirt import utils as virtutils -CONF = config.CONF +CONF = cfg.CONF LOG = log.getLogger(__name__) diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py index deb16568..db44778f 100644 --- a/nova/tests/test_instance_types.py +++ b/nova/tests/test_instance_types.py @@ -18,7 +18,6 @@ Unit Tests for instance types code import time from nova.compute import instance_types -from nova import config from nova import context from nova import db from nova.db.sqlalchemy import models diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index b2bc8878..1b65afc2 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -37,6 +37,7 @@ from nova import config from nova import context from nova import db from nova import exception +from nova.openstack.common import cfg from nova.openstack.common import fileutils from nova.openstack.common import importutils from nova.openstack.common import jsonutils @@ -69,7 +70,7 @@ except ImportError: libvirt_driver.libvirt = libvirt -CONF = config.CONF +CONF = cfg.CONF LOG = logging.getLogger(__name__) _fake_network_info = fake_network.fake_get_instance_nw_info diff --git a/nova/tests/test_libvirt_vif.py b/nova/tests/test_libvirt_vif.py index af1c657a..bd51bf01 100644 --- a/nova/tests/test_libvirt_vif.py +++ b/nova/tests/test_libvirt_vif.py @@ -16,13 +16,13 @@ from lxml import etree -from nova import config +from nova.openstack.common import cfg from nova import test from nova import utils from nova.virt.libvirt import config as vconfig from nova.virt.libvirt import vif -CONF = config.CONF +CONF = cfg.CONF class LibvirtVifTestCase(test.TestCase): diff --git a/nova/tests/test_powervm.py b/nova/tests/test_powervm.py index e640d7f0..b84bd9fb 100644 --- a/nova/tests/test_powervm.py +++ b/nova/tests/test_powervm.py @@ -18,7 +18,6 @@ Test suite for PowerVMDriver. """ -from nova import config from nova import context from nova import db from nova import test diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 67c52ed3..252b0db5 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -17,7 +17,6 @@ import os -from nova import config from nova import exception from nova import test from nova import tests diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py index d6bce87f..ec0cb8b0 100644 --- a/nova/tests/test_vmwareapi.py +++ b/nova/tests/test_vmwareapi.py @@ -20,7 +20,6 @@ Test suite for VMWareAPI. """ from nova.compute import power_state -from nova import config from nova import context from nova import db from nova import exception diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 53ba9eea..bc3c1dd3 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -33,6 +33,7 @@ from nova import config from nova import context from nova import db from nova import exception +from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import jsonutils from nova.openstack.common import log as logging @@ -56,7 +57,7 @@ from nova.virt.xenapi import volume_utils LOG = logging.getLogger(__name__) -CONF = config.CONF +CONF = cfg.CONF IMAGE_MACHINE = '1' IMAGE_KERNEL = '2'