Use CONF.import_opt() for nova.config opts
The only reason for importing nova.config now is where one of the options defined in that file is needed. Rather than importing nova.config using an import statement, use CONF.import_opt() so that it is clear which option we actually require. In future, we will move many options out of nova.config so many of these import_opt() calls will either go away or cause a module other than nova.config to be imported. Change-Id: I0646efddecdf2530903afd50c1f4364cb1d5dce1
This commit is contained in:
@@ -50,6 +50,7 @@ from nova.vnc import xvp_proxy
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('enabled_apis', 'nova.config')
|
||||
LOG = logging.getLogger('nova.all')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -43,6 +43,7 @@ from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('enabled_apis', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -39,6 +39,7 @@ from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('cert_topic', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -48,6 +48,7 @@ from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_topic', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -39,6 +39,7 @@ from nova.openstack.common import log as logging
|
||||
from nova import service
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('console_topic', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -47,6 +47,8 @@ from nova.openstack.common import rpc
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('network_manager', 'nova.config')
|
||||
LOG = logging.getLogger('nova.dhcpbridge')
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ from nova import utils
|
||||
from nova import version
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('network_manager', 'nova.config')
|
||||
CONF.import_opt('service_down_time', 'nova.config')
|
||||
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')
|
||||
|
||||
@@ -41,6 +41,7 @@ from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('network_topic', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -43,6 +43,7 @@ from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('scheduler_topic', 'nova.config')
|
||||
|
||||
if __name__ == '__main__':
|
||||
config.parse_args(sys.argv)
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
import re
|
||||
|
||||
from nova import config
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_driver', 'nova.config')
|
||||
|
||||
DEFAULT_ROOT_DEV_NAME = '/dev/sda1'
|
||||
_DEFAULT_MAPPINGS = {'ami': 'sda1',
|
||||
|
||||
@@ -55,7 +55,6 @@ This module provides Manager, a base class for managers.
|
||||
|
||||
import eventlet
|
||||
|
||||
from nova import config
|
||||
from nova.db import base
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -65,6 +64,7 @@ from nova.scheduler import rpcapi as scheduler_rpcapi
|
||||
from nova import version
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ Chance (Random) Scheduler implementation
|
||||
|
||||
import random
|
||||
|
||||
from nova import config
|
||||
from nova import exception
|
||||
from nova.openstack.common import cfg
|
||||
from nova.scheduler import driver
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_topic', 'nova.config')
|
||||
|
||||
|
||||
class ChanceScheduler(driver.Scheduler):
|
||||
|
||||
@@ -28,7 +28,6 @@ from nova.compute import power_state
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.compute import vm_states
|
||||
from nova import config
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import notifications
|
||||
@@ -54,8 +53,7 @@ scheduler_driver_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(scheduler_driver_opts)
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_topic', 'nova.config')
|
||||
CONF.import_opt('instances_path', 'nova.compute.manager')
|
||||
CONF.import_opt('libvirt_type', 'nova.virt.libvirt.driver')
|
||||
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova import config
|
||||
from nova.openstack.common import cfg
|
||||
from nova.scheduler import filters
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('isolated_hosts', 'nova.config')
|
||||
CONF.import_opt('isolated_images', 'nova.config')
|
||||
|
||||
|
||||
class IsolatedHostsFilter(filters.BaseHostFilter):
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
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 = cfg.CONF
|
||||
CONF.import_opt('scheduler_topic', 'nova.config')
|
||||
|
||||
|
||||
class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
|
||||
@@ -30,7 +30,6 @@ import time
|
||||
import eventlet
|
||||
import greenlet
|
||||
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
@@ -92,6 +91,8 @@ service_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(service_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('node_availability_zone', 'nova.config')
|
||||
|
||||
|
||||
class SignalExit(SystemExit):
|
||||
@@ -477,8 +478,10 @@ class Service(object):
|
||||
if not topic:
|
||||
topic = binary.rpartition('nova-')[2]
|
||||
if not manager:
|
||||
manager = CONF.get('%s_manager' %
|
||||
binary.rpartition('nova-')[2], None)
|
||||
manager_cls = ('%s_manager' %
|
||||
binary.rpartition('nova-')[2])
|
||||
CONF.import_opt(manager_cls, 'nova.config')
|
||||
manager = CONF.get(manager_cls, None)
|
||||
if report_interval is None:
|
||||
report_interval = CONF.report_interval
|
||||
if periodic_interval is None:
|
||||
|
||||
@@ -31,7 +31,6 @@ setattr(__builtin__, '_', lambda x: x)
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from nova import config
|
||||
from nova.db.sqlalchemy.session import get_engine
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -42,6 +41,9 @@ import eventlet
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('sql_connection', 'nova.config')
|
||||
CONF.import_opt('sqlite_db', 'nova.config')
|
||||
CONF.import_opt('state_path', 'nova.config')
|
||||
CONF.set_override('use_stderr', False)
|
||||
|
||||
logging.setup('nova')
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova import config
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('state_path', 'nova.config')
|
||||
|
||||
CONF.import_opt('scheduler_driver', 'nova.scheduler.manager')
|
||||
CONF.import_opt('fake_network', 'nova.network.manager')
|
||||
|
||||
@@ -18,7 +18,6 @@ Tests For Scheduler Host Filters.
|
||||
import httplib
|
||||
import stubout
|
||||
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
@@ -32,6 +31,7 @@ from nova.tests.scheduler import fakes
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
DATA = ''
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
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
|
||||
@@ -26,6 +25,7 @@ from nova.scheduler import rpcapi as scheduler_rpcapi
|
||||
from nova import test
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('scheduler_topic', 'nova.config')
|
||||
|
||||
|
||||
class SchedulerRpcAPITestCase(test.TestCase):
|
||||
|
||||
@@ -27,7 +27,6 @@ from nova import test
|
||||
|
||||
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
|
||||
@@ -37,6 +36,8 @@ from nova.virt.libvirt import imagecache
|
||||
from nova.virt.libvirt import utils as virtutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ from nova.compute import instance_types
|
||||
from nova.compute import power_state
|
||||
from nova.compute import vm_mode
|
||||
from nova.compute import vm_states
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
@@ -71,6 +70,9 @@ libvirt_driver.libvirt = libvirt
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_fake_network_info = fake_network.fake_get_instance_nw_info
|
||||
|
||||
@@ -29,7 +29,6 @@ from nova.compute import instance_types
|
||||
from nova.compute import power_state
|
||||
from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
@@ -58,6 +57,10 @@ from nova.virt.xenapi import volume_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('network_manager', 'nova.config')
|
||||
CONF.import_opt('node_availability_zone', 'nova.config')
|
||||
|
||||
IMAGE_MACHINE = '1'
|
||||
IMAGE_KERNEL = '2'
|
||||
|
||||
@@ -46,7 +46,6 @@ from eventlet import greenthread
|
||||
from eventlet import semaphore
|
||||
import netaddr
|
||||
|
||||
from nova import config
|
||||
from nova import exception
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import excutils
|
||||
@@ -60,6 +59,11 @@ CONF = cfg.CONF
|
||||
CONF.register_opt(
|
||||
cfg.BoolOpt('disable_process_locking', default=False,
|
||||
help='Whether to disable inter-process locks'))
|
||||
CONF.import_opt('glance_port', 'nova.config')
|
||||
CONF.import_opt('instance_usage_audit_period', 'nova.config')
|
||||
CONF.import_opt('monkey_patch', 'nova.config')
|
||||
CONF.import_opt('rootwrap_config', 'nova.config')
|
||||
CONF.import_opt('service_down_time', 'nova.config')
|
||||
|
||||
# Used for looking up extensions of text
|
||||
# to their 'multiplied' byte amount
|
||||
|
||||
@@ -30,7 +30,6 @@ import routes.middleware
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from nova import config
|
||||
from nova import exception
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -46,6 +45,7 @@ wsgi_opts = [
|
||||
]
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(wsgi_opts)
|
||||
CONF.import_opt('api_paste_config', 'nova.config')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user