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
This commit is contained in:
Mark McLoughlin
2012-11-17 22:50:17 +00:00
parent ae34a772b3
commit 1573b2794c
35 changed files with 52 additions and 44 deletions

View File

@@ -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__':

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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__':

View File

@@ -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)

View File

@@ -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)

View File

@@ -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')

View File

@@ -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')

View File

@@ -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)

View File

@@ -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__)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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):

View File

@@ -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')

View File

@@ -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'))

View File

@@ -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')

View File

@@ -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'))

View File

@@ -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')

View File

@@ -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):

View File

@@ -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

View File

@@ -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')

View File

@@ -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'))

View File

@@ -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):

View File

@@ -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):

View File

@@ -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__)

View File

@@ -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

View File

@@ -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

View File

@@ -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):

View File

@@ -18,7 +18,6 @@
Test suite for PowerVMDriver.
"""
from nova import config
from nova import context
from nova import db
from nova import test

View File

@@ -17,7 +17,6 @@
import os
from nova import config
from nova import exception
from nova import test
from nova import tests

View File

@@ -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

View File

@@ -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'