summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-02-15 22:30:16 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2013-02-19 21:16:32 -0800
commit706a1370056ffccc2c8811fc1ac0679944564ece (patch)
tree0b71139bbf282e7909b0df37a69a2aaa8f3e32d2 /nova
parentd62205f316ad9490e1379e943972a007e071c688 (diff)
downloadnova-706a1370056ffccc2c8811fc1ac0679944564ece.tar.gz
nova-706a1370056ffccc2c8811fc1ac0679944564ece.tar.xz
nova-706a1370056ffccc2c8811fc1ac0679944564ece.zip
Use oslo-config-2013.1b4
The cfg API is now available via the oslo-config library, so switch to it and remove the copied-and-pasted version. Add the 2013.1b4 tarball to tools/pip-requires - this will be changed to 'oslo-config>=2013.1' when oslo-config is published to pypi. This will happen in time for grizzly final. Add dependency_links to setup.py so that oslo-config can be installed from the tarball URL specified in pip-requires. Remove the 'deps = pep8==1.3.3' from tox.ini as it means all the other deps get installed with easy_install which can't install oslo-config from the URL. Make tools/hacking.py include oslo in IMPORT_EXCEPTIONS like it already does for paste. It turns out imp.find_module() doesn't correct handle namespace packages. Retain dummy cfg.py file until keystoneclient middleware has been updated (I18c450174277c8e2d15ed93879da6cd92074c27a). Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
Diffstat (limited to 'nova')
-rw-r--r--nova/api/auth.py2
-rw-r--r--nova/api/ec2/__init__.py2
-rw-r--r--nova/api/ec2/cloud.py3
-rw-r--r--nova/api/ec2/faults.py2
-rw-r--r--nova/api/metadata/base.py3
-rw-r--r--nova/api/metadata/handler.py2
-rw-r--r--nova/api/openstack/auth.py2
-rw-r--r--nova/api/openstack/common.py2
-rw-r--r--nova/api/openstack/compute/__init__.py4
-rw-r--r--nova/api/openstack/compute/contrib/__init__.py3
-rw-r--r--nova/api/openstack/compute/contrib/availability_zone.py4
-rw-r--r--nova/api/openstack/compute/contrib/cells.py4
-rw-r--r--nova/api/openstack/compute/contrib/cloudpipe.py3
-rw-r--r--nova/api/openstack/compute/contrib/floating_ips_bulk.py2
-rw-r--r--nova/api/openstack/compute/contrib/fping.py3
-rw-r--r--nova/api/openstack/compute/contrib/hide_server_addresses.py2
-rw-r--r--nova/api/openstack/compute/contrib/instance_usage_audit_log.py2
-rw-r--r--nova/api/openstack/compute/contrib/os_tenant_networks.py2
-rw-r--r--nova/api/openstack/compute/contrib/rescue.py2
-rw-r--r--nova/api/openstack/compute/contrib/services.py4
-rw-r--r--nova/api/openstack/compute/extensions.py3
-rw-r--r--nova/api/openstack/compute/servers.py2
-rw-r--r--nova/api/sizelimit.py2
-rw-r--r--nova/availability_zones.py3
-rw-r--r--nova/cells/manager.py3
-rw-r--r--nova/cells/messaging.py2
-rw-r--r--nova/cells/opts.py2
-rw-r--r--nova/cells/rpc_driver.py3
-rw-r--r--nova/cells/rpcapi.py3
-rw-r--r--nova/cells/scheduler.py3
-rw-r--r--nova/cells/state.py3
-rw-r--r--nova/cert/rpcapi.py3
-rw-r--r--nova/cloudpipe/pipelib.py3
-rw-r--r--nova/common/memorycache.py3
-rw-r--r--nova/compute/__init__.py17
-rw-r--r--nova/compute/api.py3
-rw-r--r--nova/compute/instance_types.py3
-rwxr-xr-xnova/compute/manager.py2
-rw-r--r--nova/compute/resource_tracker.py3
-rw-r--r--nova/compute/rpcapi.py3
-rw-r--r--nova/compute/utils.py3
-rw-r--r--nova/conductor/__init__.py6
-rw-r--r--nova/conductor/api.py3
-rw-r--r--nova/conductor/rpcapi.py3
-rw-r--r--nova/config.py3
-rw-r--r--nova/console/api.py3
-rw-r--r--nova/console/manager.py3
-rw-r--r--nova/console/rpcapi.py3
-rw-r--r--nova/console/vmrc.py3
-rw-r--r--nova/console/vmrc_manager.py3
-rw-r--r--nova/console/xvp.py2
-rw-r--r--nova/consoleauth/__init__.py2
-rw-r--r--nova/consoleauth/manager.py3
-rw-r--r--nova/consoleauth/rpcapi.py3
-rw-r--r--nova/crypto.py2
-rw-r--r--nova/db/api.py3
-rw-r--r--nova/db/base.py3
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/db/sqlalchemy/models.py3
-rw-r--r--nova/exception.py2
-rw-r--r--nova/image/glance.py2
-rw-r--r--nova/image/s3.py2
-rw-r--r--nova/ipv6/api.py4
-rw-r--r--nova/manager.py5
-rw-r--r--nova/netconf.py2
-rw-r--r--nova/network/__init__.py15
-rw-r--r--nova/network/driver.py3
-rw-r--r--nova/network/floating_ips.py3
-rw-r--r--nova/network/ldapdns.py3
-rw-r--r--nova/network/linux_net.py4
-rw-r--r--nova/network/manager.py3
-rw-r--r--nova/network/minidns.py4
-rw-r--r--nova/network/quantumv2/__init__.py7
-rw-r--r--nova/network/quantumv2/api.py4
-rw-r--r--nova/network/rpcapi.py3
-rw-r--r--nova/notifications.py3
-rw-r--r--nova/objectstore/s3server.py2
-rw-r--r--nova/openstack/common/cfg.py1736
-rw-r--r--nova/openstack/common/db/sqlalchemy/session.py2
-rw-r--r--nova/openstack/common/eventlet_backdoor.py3
-rw-r--r--nova/openstack/common/iniparser.py130
-rw-r--r--nova/openstack/common/lockutils.py3
-rw-r--r--nova/openstack/common/log.py3
-rw-r--r--nova/openstack/common/notifier/api.py3
-rw-r--r--nova/openstack/common/notifier/log_notifier.py3
-rw-r--r--nova/openstack/common/notifier/rpc_notifier.py2
-rw-r--r--nova/openstack/common/notifier/rpc_notifier2.py3
-rw-r--r--nova/openstack/common/plugin/pluginmanager.py3
-rw-r--r--nova/openstack/common/rpc/__init__.py4
-rw-r--r--nova/openstack/common/rpc/common.py3
-rw-r--r--nova/openstack/common/rpc/impl_kombu.py2
-rw-r--r--nova/openstack/common/rpc/impl_qpid.py2
-rw-r--r--nova/openstack/common/rpc/impl_zmq.py2
-rw-r--r--nova/openstack/common/rpc/matchmaker.py3
-rw-r--r--nova/paths.py2
-rw-r--r--nova/policy.py3
-rw-r--r--nova/quota.py4
-rw-r--r--nova/scheduler/chance.py3
-rw-r--r--nova/scheduler/driver.py3
-rw-r--r--nova/scheduler/filter_scheduler.py3
-rw-r--r--nova/scheduler/filters/availability_zone_filter.py3
-rw-r--r--nova/scheduler/filters/compute_filter.py3
-rw-r--r--nova/scheduler/filters/core_filter.py4
-rw-r--r--nova/scheduler/filters/disk_filter.py3
-rw-r--r--nova/scheduler/filters/io_ops_filter.py3
-rw-r--r--nova/scheduler/filters/isolated_hosts_filter.py3
-rw-r--r--nova/scheduler/filters/num_instances_filter.py3
-rw-r--r--nova/scheduler/filters/ram_filter.py3
-rw-r--r--nova/scheduler/filters/trusted_filter.py4
-rw-r--r--nova/scheduler/host_manager.py3
-rw-r--r--nova/scheduler/manager.py3
-rw-r--r--nova/scheduler/multi.py3
-rw-r--r--nova/scheduler/rpcapi.py3
-rw-r--r--nova/scheduler/scheduler_options.py3
-rw-r--r--nova/scheduler/weights/__init__.py2
-rw-r--r--nova/scheduler/weights/least_cost.py3
-rw-r--r--nova/scheduler/weights/ram.py4
-rw-r--r--nova/service.py2
-rw-r--r--nova/servicegroup/api.py8
-rw-r--r--nova/servicegroup/drivers/db.py3
-rw-r--r--nova/servicegroup/drivers/mc.py3
-rw-r--r--nova/servicegroup/drivers/zk.py2
-rw-r--r--nova/spice/__init__.py2
-rw-r--r--nova/test.py2
-rw-r--r--nova/tests/api/ec2/test_cinder_cloud.py2
-rw-r--r--nova/tests/api/ec2/test_cloud.py2
-rw-r--r--nova/tests/api/ec2/test_ec2_validate.py3
-rw-r--r--nova/tests/api/ec2/test_middleware.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_admin_actions.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_cloudpipe.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_evacuate.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_floating_ip_bulk.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_networks.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_rescue.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_security_group_default_rules.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_security_groups.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_server_password.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_volumes.py4
-rw-r--r--nova/tests/api/openstack/compute/test_extensions.py2
-rw-r--r--nova/tests/api/openstack/compute/test_image_metadata.py2
-rw-r--r--nova/tests/api/openstack/compute/test_server_actions.py3
-rw-r--r--nova/tests/api/openstack/compute/test_server_metadata.py2
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py3
-rw-r--r--nova/tests/api/test_sizelimit.py2
-rw-r--r--nova/tests/baremetal/db/base.py3
-rw-r--r--nova/tests/baremetal/test_driver.py3
-rw-r--r--nova/tests/baremetal/test_ipmi.py3
-rw-r--r--nova/tests/baremetal/test_pxe.py2
-rw-r--r--nova/tests/baremetal/test_virtual_power_driver.py6
-rw-r--r--nova/tests/baremetal/test_volume_driver.py4
-rw-r--r--nova/tests/cells/fakes.py3
-rw-r--r--nova/tests/cells/test_cells_manager.py3
-rw-r--r--nova/tests/cells/test_cells_messaging.py5
-rw-r--r--nova/tests/cells/test_cells_rpc_driver.py3
-rw-r--r--nova/tests/cells/test_cells_rpcapi.py3
-rw-r--r--nova/tests/cells/test_cells_scheduler.py3
-rw-r--r--nova/tests/cert/test_rpcapi.py3
-rw-r--r--nova/tests/compute/test_compute.py2
-rw-r--r--nova/tests/compute/test_compute_utils.py3
-rw-r--r--nova/tests/compute/test_multiple_nodes.py3
-rw-r--r--nova/tests/compute/test_resource_tracker.py3
-rw-r--r--nova/tests/compute/test_rpcapi.py3
-rw-r--r--nova/tests/conf_fixture.py2
-rw-r--r--nova/tests/console/test_console.py3
-rw-r--r--nova/tests/console/test_rpcapi.py3
-rw-r--r--nova/tests/consoleauth/test_rpcapi.py3
-rw-r--r--nova/tests/fake_libvirt_utils.py3
-rw-r--r--nova/tests/fake_network.py3
-rw-r--r--nova/tests/fake_volume.py3
-rw-r--r--nova/tests/image/fake.py4
-rw-r--r--nova/tests/image/test_glance.py2
-rw-r--r--nova/tests/integrated/integrated_helpers.py3
-rw-r--r--nova/tests/integrated/test_api_samples.py2
-rw-r--r--nova/tests/integrated/test_extensions.py3
-rw-r--r--nova/tests/network/test_linux_net.py2
-rw-r--r--nova/tests/network/test_manager.py3
-rw-r--r--nova/tests/network/test_quantumv2.py5
-rw-r--r--nova/tests/network/test_rpcapi.py3
-rw-r--r--nova/tests/policy_fixture.py2
-rw-r--r--nova/tests/scheduler/test_host_filters.py3
-rw-r--r--nova/tests/scheduler/test_least_cost.py5
-rw-r--r--nova/tests/scheduler/test_rpcapi.py3
-rw-r--r--nova/tests/test_availability_zones.py3
-rw-r--r--nova/tests/test_db_api.py2
-rw-r--r--nova/tests/test_hypervapi.py3
-rw-r--r--nova/tests/test_imagebackend.py5
-rw-r--r--nova/tests/test_imagecache.py4
-rw-r--r--nova/tests/test_libvirt.py3
-rw-r--r--nova/tests/test_libvirt_vif.py2
-rw-r--r--nova/tests/test_libvirt_volume.py3
-rw-r--r--nova/tests/test_metadata.py2
-rw-r--r--nova/tests/test_notifications.py3
-rw-r--r--nova/tests/test_objectstore.py2
-rw-r--r--nova/tests/test_pipelib.py3
-rw-r--r--nova/tests/test_quota.py3
-rw-r--r--nova/tests/test_service.py6
-rw-r--r--nova/tests/test_test.py3
-rw-r--r--nova/tests/test_utils.py2
-rw-r--r--nova/tests/test_versions.py3
-rw-r--r--nova/tests/test_xenapi.py3
-rw-r--r--nova/tests/utils.py6
-rw-r--r--nova/utils.py3
-rw-r--r--nova/version.py3
-rw-r--r--nova/virt/baremetal/db/api.py4
-rw-r--r--nova/virt/baremetal/db/sqlalchemy/session.py3
-rwxr-xr-xnova/virt/baremetal/driver.py3
-rw-r--r--nova/virt/baremetal/ipmi.py3
-rw-r--r--nova/virt/baremetal/pxe.py4
-rw-r--r--nova/virt/baremetal/vif_driver.py3
-rw-r--r--nova/virt/baremetal/virtual_power_driver.py2
-rw-r--r--nova/virt/baremetal/volume_driver.py3
-rw-r--r--nova/virt/configdrive.py3
-rw-r--r--nova/virt/disk/api.py3
-rw-r--r--nova/virt/disk/mount/nbd.py3
-rwxr-xr-xnova/virt/driver.py3
-rw-r--r--nova/virt/firewall.py4
-rw-r--r--nova/virt/hyperv/basevolumeutils.py3
-rw-r--r--nova/virt/hyperv/hostops.py3
-rw-r--r--nova/virt/hyperv/livemigrationops.py3
-rw-r--r--nova/virt/hyperv/pathutils.py3
-rw-r--r--nova/virt/hyperv/snapshotops.py3
-rw-r--r--nova/virt/hyperv/vif.py4
-rw-r--r--nova/virt/hyperv/vmops.py3
-rw-r--r--nova/virt/hyperv/vmutils.py3
-rw-r--r--nova/virt/hyperv/volumeops.py3
-rw-r--r--nova/virt/hyperv/volumeutils.py2
-rw-r--r--nova/virt/hyperv/volumeutilsv2.py3
-rwxr-xr-xnova/virt/images.py4
-rwxr-xr-xnova/virt/libvirt/driver.py2
-rw-r--r--nova/virt/libvirt/firewall.py3
-rwxr-xr-xnova/virt/libvirt/imagebackend.py3
-rw-r--r--nova/virt/libvirt/imagecache.py4
-rwxr-xr-xnova/virt/libvirt/utils.py2
-rw-r--r--nova/virt/libvirt/vif.py4
-rw-r--r--nova/virt/libvirt/volume.py3
-rw-r--r--nova/virt/netutils.py2
-rw-r--r--nova/virt/powervm/blockdev.py3
-rwxr-xr-xnova/virt/powervm/driver.py4
-rw-r--r--nova/virt/powervm/operator.py8
-rwxr-xr-xnova/virt/vmwareapi/driver.py2
-rw-r--r--nova/virt/vmwareapi/vif.py3
-rw-r--r--nova/virt/vmwareapi/vim.py3
-rw-r--r--nova/virt/vmwareapi/vmops.py3
-rw-r--r--nova/virt/vmwareapi/volumeops.py4
-rw-r--r--nova/virt/xenapi/agent.py3
-rwxr-xr-xnova/virt/xenapi/driver.py2
-rw-r--r--nova/virt/xenapi/imageupload/glance.py3
-rw-r--r--nova/virt/xenapi/pool.py3
-rw-r--r--nova/virt/xenapi/vif.py3
-rw-r--r--nova/virt/xenapi/vm_utils.py2
-rw-r--r--nova/virt/xenapi/vmops.py2
-rw-r--r--nova/virt/xenapi/volume_utils.py4
-rw-r--r--nova/vnc/__init__.py2
-rw-r--r--nova/vnc/xvp_proxy.py2
-rw-r--r--nova/volume/__init__.py9
-rw-r--r--nova/volume/cinder.py2
-rw-r--r--nova/wsgi.py2
257 files changed, 450 insertions, 2199 deletions
diff --git a/nova/api/auth.py b/nova/api/auth.py
index 83388d638..04bb34066 100644
--- a/nova/api/auth.py
+++ b/nova/api/auth.py
@@ -18,11 +18,11 @@ Common Auth Middleware.
"""
+from oslo.config import cfg
import webob.dec
import webob.exc
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import wsgi
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index 85b87e3e5..397190fae 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -23,6 +23,7 @@ Starting point for routing EC2 requests.
import urlparse
from eventlet.green import httplib
+from oslo.config import cfg
import webob
import webob.dec
import webob.exc
@@ -34,7 +35,6 @@ from nova.api import validator
from nova.common import memorycache
from nova import context
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
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index b66b15852..03bf9f890 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -25,6 +25,8 @@ datastore.
import base64
import time
+from oslo.config import cfg
+
from nova.api.ec2 import ec2utils
from nova.api.ec2 import inst_state
from nova.api.metadata import password
@@ -40,7 +42,6 @@ from nova import db
from nova import exception
from nova.image import s3
from nova import network
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import quota
diff --git a/nova/api/ec2/faults.py b/nova/api/ec2/faults.py
index 9299a946c..f13f26a77 100644
--- a/nova/api/ec2/faults.py
+++ b/nova/api/ec2/faults.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
import webob.dec
import webob.exc
from nova import context
-from nova.openstack.common import cfg
from nova import utils
CONF = cfg.CONF
diff --git a/nova/api/metadata/base.py b/nova/api/metadata/base.py
index fca580b29..41f36541c 100644
--- a/nova/api/metadata/base.py
+++ b/nova/api/metadata/base.py
@@ -23,13 +23,14 @@ import json
import os
import posixpath
+from oslo.config import cfg
+
from nova.api.ec2 import ec2utils
from nova.api.metadata import password
from nova import block_device
from nova import conductor
from nova import context
from nova import network
-from nova.openstack.common import cfg
from nova.openstack.common import timeutils
from nova.virt import netutils
diff --git a/nova/api/metadata/handler.py b/nova/api/metadata/handler.py
index cedb27370..7cccbc324 100644
--- a/nova/api/metadata/handler.py
+++ b/nova/api/metadata/handler.py
@@ -21,6 +21,7 @@ import hashlib
import hmac
import os
+from oslo.config import cfg
import webob.dec
import webob.exc
@@ -28,7 +29,6 @@ from nova.api.metadata import base
from nova.common import memorycache
from nova import conductor
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import wsgi
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index 24276b2bd..979aa74b6 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -17,12 +17,12 @@
import os
+from oslo.config import cfg
import webob.dec
import webob.exc
from nova.api.openstack import wsgi
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import wsgi as base_wsgi
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 1f479b82e..8b880720b 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -20,6 +20,7 @@ import os
import re
import urlparse
+from oslo.config import cfg
import webob
from nova.api.openstack import wsgi
@@ -28,7 +29,6 @@ from nova.compute import task_states
from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import quota
from nova import utils
diff --git a/nova/api/openstack/compute/__init__.py b/nova/api/openstack/compute/__init__.py
index 92c84c13f..6b05dcf5f 100644
--- a/nova/api/openstack/compute/__init__.py
+++ b/nova/api/openstack/compute/__init__.py
@@ -20,6 +20,8 @@
WSGI middleware for OpenStack Compute API.
"""
+from oslo.config import cfg
+
import nova.api.openstack
from nova.api.openstack.compute import consoles
from nova.api.openstack.compute import extensions
@@ -31,10 +33,8 @@ from nova.api.openstack.compute import limits
from nova.api.openstack.compute import server_metadata
from nova.api.openstack.compute import servers
from nova.api.openstack.compute import versions
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
-
LOG = logging.getLogger(__name__)
allow_instance_snapshots_opt = cfg.BoolOpt('allow_instance_snapshots',
diff --git a/nova/api/openstack/compute/contrib/__init__.py b/nova/api/openstack/compute/contrib/__init__.py
index 7b21a0be8..8e1e8aa85 100644
--- a/nova/api/openstack/compute/contrib/__init__.py
+++ b/nova/api/openstack/compute/contrib/__init__.py
@@ -21,8 +21,9 @@ It can't be called 'extensions' because that causes namespacing problems.
"""
+from oslo.config import cfg
+
from nova.api.openstack import extensions
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
ext_opts = [
diff --git a/nova/api/openstack/compute/contrib/availability_zone.py b/nova/api/openstack/compute/contrib/availability_zone.py
index 98c508bd7..c79556839 100644
--- a/nova/api/openstack/compute/contrib/availability_zone.py
+++ b/nova/api/openstack/compute/contrib/availability_zone.py
@@ -14,17 +14,17 @@
# License for the specific language governing permissions and limitations
# under the License
+from oslo.config import cfg
+
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import availability_zones
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import servicegroup
-
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
diff --git a/nova/api/openstack/compute/contrib/cells.py b/nova/api/openstack/compute/contrib/cells.py
index 29a9ffcc4..8e31777e2 100644
--- a/nova/api/openstack/compute/contrib/cells.py
+++ b/nova/api/openstack/compute/contrib/cells.py
@@ -16,9 +16,10 @@
# under the License.
"""The cells extension."""
-from xml.parsers import expat
+from oslo.config import cfg
from webob import exc
+from xml.parsers import expat
from nova.api.openstack import common
from nova.api.openstack import extensions
@@ -28,7 +29,6 @@ from nova.cells import rpcapi as cells_rpcapi
from nova.compute import api as compute
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import utils
diff --git a/nova/api/openstack/compute/contrib/cloudpipe.py b/nova/api/openstack/compute/contrib/cloudpipe.py
index 4e224be46..20ae87fe1 100644
--- a/nova/api/openstack/compute/contrib/cloudpipe.py
+++ b/nova/api/openstack/compute/contrib/cloudpipe.py
@@ -14,6 +14,8 @@
"""Connect your vlan to the world."""
+from oslo.config import cfg
+
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
@@ -24,7 +26,6 @@ from nova.compute import vm_states
from nova import db
from nova import exception
from nova import network
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/api/openstack/compute/contrib/floating_ips_bulk.py b/nova/api/openstack/compute/contrib/floating_ips_bulk.py
index 11ab0ec69..afd42e12f 100644
--- a/nova/api/openstack/compute/contrib/floating_ips_bulk.py
+++ b/nova/api/openstack/compute/contrib/floating_ips_bulk.py
@@ -16,12 +16,12 @@
# under the License.
import netaddr
+from oslo.config import cfg
import webob.exc
from nova.api.openstack import extensions
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
CONF = cfg.CONF
diff --git a/nova/api/openstack/compute/contrib/fping.py b/nova/api/openstack/compute/contrib/fping.py
index 282be19ca..394d5924e 100644
--- a/nova/api/openstack/compute/contrib/fping.py
+++ b/nova/api/openstack/compute/contrib/fping.py
@@ -19,17 +19,16 @@
import itertools
import os
+from oslo.config import cfg
from webob import exc
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova import compute
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
-
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'fping')
authorize_all_tenants = extensions.extension_authorizer(
diff --git a/nova/api/openstack/compute/contrib/hide_server_addresses.py b/nova/api/openstack/compute/contrib/hide_server_addresses.py
index bb8ee553a..4d8bcd94e 100644
--- a/nova/api/openstack/compute/contrib/hide_server_addresses.py
+++ b/nova/api/openstack/compute/contrib/hide_server_addresses.py
@@ -15,11 +15,11 @@
"""Extension for hiding server addresses in certain states."""
+from oslo.config import cfg
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.compute import vm_states
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
opts = [
diff --git a/nova/api/openstack/compute/contrib/instance_usage_audit_log.py b/nova/api/openstack/compute/contrib/instance_usage_audit_log.py
index 512b58869..d6ffe3677 100644
--- a/nova/api/openstack/compute/contrib/instance_usage_audit_log.py
+++ b/nova/api/openstack/compute/contrib/instance_usage_audit_log.py
@@ -18,11 +18,11 @@
import datetime
+from oslo.config import cfg
import webob.exc
from nova.api.openstack import extensions
from nova import compute
-from nova.openstack.common import cfg
from nova import utils
CONF = cfg.CONF
diff --git a/nova/api/openstack/compute/contrib/os_tenant_networks.py b/nova/api/openstack/compute/contrib/os_tenant_networks.py
index 03178ab65..9848d2320 100644
--- a/nova/api/openstack/compute/contrib/os_tenant_networks.py
+++ b/nova/api/openstack/compute/contrib/os_tenant_networks.py
@@ -18,13 +18,13 @@
import netaddr
import netaddr.core as netexc
+from oslo.config import cfg
from webob import exc
from nova.api.openstack import extensions
from nova import context as nova_context
from nova import exception
import nova.network
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import quota
diff --git a/nova/api/openstack/compute/contrib/rescue.py b/nova/api/openstack/compute/contrib/rescue.py
index 29135418e..c62ed5894 100644
--- a/nova/api/openstack/compute/contrib/rescue.py
+++ b/nova/api/openstack/compute/contrib/rescue.py
@@ -14,6 +14,7 @@
"""The rescue mode extension."""
+from oslo.config import cfg
import webob
from webob import exc
@@ -22,7 +23,6 @@ from nova.api.openstack import extensions as exts
from nova.api.openstack import wsgi
from nova import compute
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/api/openstack/compute/contrib/services.py b/nova/api/openstack/compute/contrib/services.py
index 2786ad814..0f91bf13f 100644
--- a/nova/api/openstack/compute/contrib/services.py
+++ b/nova/api/openstack/compute/contrib/services.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-
+from oslo.config import cfg
import webob.exc
from nova.api.openstack import extensions
@@ -24,12 +24,10 @@ from nova.api.openstack import xmlutil
from nova import availability_zones
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import utils
-
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'services')
CONF = cfg.CONF
diff --git a/nova/api/openstack/compute/extensions.py b/nova/api/openstack/compute/extensions.py
index 1d0738417..4e49482f5 100644
--- a/nova/api/openstack/compute/extensions.py
+++ b/nova/api/openstack/compute/extensions.py
@@ -15,8 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova.api.openstack import extensions as base_extensions
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common.plugin import pluginmanager
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 3b8eb506d..cc33537af 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -19,6 +19,7 @@ import os
import re
import socket
+from oslo.config import cfg
import webob
from webob import exc
@@ -30,7 +31,6 @@ from nova.api.openstack import xmlutil
from nova import compute
from nova.compute import instance_types
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common.rpc import common as rpc_common
diff --git a/nova/api/sizelimit.py b/nova/api/sizelimit.py
index 77ab4415c..67d459583 100644
--- a/nova/api/sizelimit.py
+++ b/nova/api/sizelimit.py
@@ -18,10 +18,10 @@ Request Body limiting middleware.
"""
+from oslo.config import cfg
import webob.dec
import webob.exc
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import wsgi
diff --git a/nova/availability_zones.py b/nova/availability_zones.py
index 8c9d4acf7..61486517d 100644
--- a/nova/availability_zones.py
+++ b/nova/availability_zones.py
@@ -15,8 +15,9 @@
"""Availability zone helper functions."""
+from oslo.config import cfg
+
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
availability_zone_opts = [
diff --git a/nova/cells/manager.py b/nova/cells/manager.py
index c07a23ebb..55b3dadf7 100644
--- a/nova/cells/manager.py
+++ b/nova/cells/manager.py
@@ -19,13 +19,14 @@ Cells Service Manager
import datetime
import time
+from oslo.config import cfg
+
from nova.cells import messaging
from nova.cells import state as cells_state
from nova.cells import utils as cells_utils
from nova import context
from nova import exception
from nova import manager
-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 timeutils
diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py
index 5c7247085..50a673464 100644
--- a/nova/cells/messaging.py
+++ b/nova/cells/messaging.py
@@ -25,6 +25,7 @@ The interface into this module is the MessageRunner class.
import sys
from eventlet import queue
+from oslo.config import cfg
from nova.cells import state as cells_state
from nova.cells import utils as cells_utils
@@ -32,7 +33,6 @@ from nova import compute
from nova import context
from nova.db import base
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/cells/opts.py b/nova/cells/opts.py
index 45b453ebc..b66dd6b42 100644
--- a/nova/cells/opts.py
+++ b/nova/cells/opts.py
@@ -18,7 +18,7 @@
Global cells config options
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
cells_opts = [
cfg.BoolOpt('enable',
diff --git a/nova/cells/rpc_driver.py b/nova/cells/rpc_driver.py
index 5e420aa8e..0dcf1184c 100644
--- a/nova/cells/rpc_driver.py
+++ b/nova/cells/rpc_driver.py
@@ -16,8 +16,9 @@
"""
Cells RPC Communication Driver
"""
+from oslo.config import cfg
+
from nova.cells import driver
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
from nova.openstack.common.rpc import proxy as rpc_proxy
diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py
index e7db2582f..910c4ab9d 100644
--- a/nova/cells/rpcapi.py
+++ b/nova/cells/rpcapi.py
@@ -22,7 +22,8 @@ services. That communication is handled by the cells driver via the
messging module.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.openstack.common.rpc import proxy as rpc_proxy
diff --git a/nova/cells/scheduler.py b/nova/cells/scheduler.py
index 211bbb48f..3b69b2eac 100644
--- a/nova/cells/scheduler.py
+++ b/nova/cells/scheduler.py
@@ -19,11 +19,12 @@ Cells Scheduler
import random
import time
+from oslo.config import cfg
+
from nova import compute
from nova.compute import vm_states
from nova.db import base
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.scheduler import rpcapi as scheduler_rpcapi
diff --git a/nova/cells/state.py b/nova/cells/state.py
index e3886bedb..53c536888 100644
--- a/nova/cells/state.py
+++ b/nova/cells/state.py
@@ -20,10 +20,11 @@ import copy
import datetime
import functools
+from oslo.config import cfg
+
from nova.cells import rpc_driver
from nova import context
from nova.db import base
-from nova.openstack.common import cfg
from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/cert/rpcapi.py b/nova/cert/rpcapi.py
index fdaa327cb..7dd843813 100644
--- a/nova/cert/rpcapi.py
+++ b/nova/cert/rpcapi.py
@@ -18,7 +18,8 @@
Client side of the cert manager RPC API.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
import nova.openstack.common.rpc.proxy
rpcapi_opts = [
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py
index cb7fb8bac..c395a754c 100644
--- a/nova/cloudpipe/pipelib.py
+++ b/nova/cloudpipe/pipelib.py
@@ -26,12 +26,13 @@ import os
import string
import zipfile
+from oslo.config import cfg
+
from nova import compute
from nova.compute import instance_types
from nova import crypto
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 log as logging
from nova import paths
diff --git a/nova/common/memorycache.py b/nova/common/memorycache.py
index 86057b6ae..f89e4b265 100644
--- a/nova/common/memorycache.py
+++ b/nova/common/memorycache.py
@@ -18,7 +18,8 @@
"""Super simple fake memcache client."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import timeutils
memcache_opts = [
diff --git a/nova/compute/__init__.py b/nova/compute/__init__.py
index d1f8cc16c..f1451aab3 100644
--- a/nova/compute/__init__.py
+++ b/nova/compute/__init__.py
@@ -16,24 +16,25 @@
# License for the specific language governing permissions and limitations
# under the License.
+import oslo.config.cfg
+
# Importing full names to not pollute the namespace and cause possible
# collisions with use of 'from nova.compute import <foo>' elsewhere.
-import nova.openstack.common.cfg
import nova.openstack.common.importutils
_compute_opts = [
- nova.openstack.common.cfg.StrOpt('compute_api_class',
- default='nova.compute.api.API',
- help='The full class name of the '
- 'compute API class to use'),
+ oslo.config.cfg.StrOpt('compute_api_class',
+ default='nova.compute.api.API',
+ help='The full class name of the '
+ 'compute API class to use'),
]
-nova.openstack.common.cfg.CONF.register_opts(_compute_opts)
+oslo.config.cfg.CONF.register_opts(_compute_opts)
def API(*args, **kwargs):
importutils = nova.openstack.common.importutils
- class_name = nova.openstack.common.cfg.CONF.compute_api_class
+ class_name = oslo.config.cfg.CONF.compute_api_class
return importutils.import_object(class_name, *args, **kwargs)
@@ -43,7 +44,7 @@ def HostAPI(*args, **kwargs):
api
"""
importutils = nova.openstack.common.importutils
- compute_api_class_name = nova.openstack.common.cfg.CONF.compute_api_class
+ compute_api_class_name = oslo.config.cfg.CONF.compute_api_class
compute_api_class = importutils.import_class(compute_api_class_name)
class_name = compute_api_class.__module__ + ".HostAPI"
return importutils.import_object(class_name, *args, **kwargs)
diff --git a/nova/compute/api.py b/nova/compute/api.py
index b83e9fa70..f29189362 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -29,6 +29,8 @@ import time
import urllib
import uuid
+from oslo.config import cfg
+
from nova import availability_zones
from nova import block_device
from nova.compute import instance_actions
@@ -46,7 +48,6 @@ from nova import hooks
from nova.image import glance
from nova import network
from nova import notifications
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py
index 4cc5d5d4e..73105b33f 100644
--- a/nova/compute/instance_types.py
+++ b/nova/compute/instance_types.py
@@ -23,10 +23,11 @@
import re
import uuid
+from oslo.config import cfg
+
from nova import context
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index a482d9c05..04aaf9e22 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -37,6 +37,7 @@ import traceback
import uuid
from eventlet import greenthread
+from oslo.config import cfg
from nova import block_device
from nova.cloudpipe import pipelib
@@ -56,7 +57,6 @@ from nova.image import glance
from nova import manager
from nova import network
from nova.network import model as network_model
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import jsonutils
from nova.openstack.common import lockutils
diff --git a/nova/compute/resource_tracker.py b/nova/compute/resource_tracker.py
index 825422e86..efb95dd7b 100644
--- a/nova/compute/resource_tracker.py
+++ b/nova/compute/resource_tracker.py
@@ -19,6 +19,8 @@ scheduler with useful information about availability through the ComputeNode
model.
"""
+from oslo.config import cfg
+
from nova.compute import claims
from nova.compute import instance_types
from nova.compute import task_states
@@ -26,7 +28,6 @@ from nova.compute import vm_states
from nova import conductor
from nova import context
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 lockutils
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index 525d1adc7..b2eac8065 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -18,8 +18,9 @@
Client side of the compute RPC API.
"""
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import rpc
import nova.openstack.common.rpc.proxy
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 35139838d..8c1f1d577 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -20,12 +20,13 @@ import re
import string
import traceback
+from oslo.config import cfg
+
from nova import block_device
from nova.compute import instance_types
from nova import exception
from nova.network import model as network_model
from nova import notifications
-from nova.openstack.common import cfg
from nova.openstack.common import log
from nova.openstack.common.notifier import api as notifier_api
from nova.openstack.common import timeutils
diff --git a/nova/conductor/__init__.py b/nova/conductor/__init__.py
index 4c702d037..b192ca7a7 100644
--- a/nova/conductor/__init__.py
+++ b/nova/conductor/__init__.py
@@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+import oslo.config.cfg
+
from nova.conductor import api as conductor_api
-import nova.openstack.common.cfg
-import nova.openstack.common.importutils
def API(*args, **kwargs):
use_local = kwargs.pop('use_local', False)
- if nova.openstack.common.cfg.CONF.conductor.use_local or use_local:
+ if oslo.config.cfg.CONF.conductor.use_local or use_local:
api = conductor_api.LocalAPI
else:
api = conductor_api.API
diff --git a/nova/conductor/api.py b/nova/conductor/api.py
index 9026eb8a2..6bc2d3f25 100644
--- a/nova/conductor/api.py
+++ b/nova/conductor/api.py
@@ -14,10 +14,11 @@
"""Handles all requests to the conductor service."""
+from oslo.config import cfg
+
from nova.conductor import manager
from nova.conductor import rpcapi
from nova import exception as exc
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common.rpc import common as rpc_common
from nova import utils
diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py
index b82f2b8e1..f7b7a7814 100644
--- a/nova/conductor/rpcapi.py
+++ b/nova/conductor/rpcapi.py
@@ -14,7 +14,8 @@
"""Client side of the conductor RPC API."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
import nova.openstack.common.rpc.proxy
diff --git a/nova/config.py b/nova/config.py
index 18147bdbb..ff6681b44 100644
--- a/nova/config.py
+++ b/nova/config.py
@@ -17,7 +17,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import rpc
from nova import paths
diff --git a/nova/console/api.py b/nova/console/api.py
index 57c5cb0e3..a2bc40ae0 100644
--- a/nova/console/api.py
+++ b/nova/console/api.py
@@ -17,10 +17,11 @@
"""Handles ConsoleProxy API requests."""
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova.console import rpcapi as console_rpcapi
from nova.db import base
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common import uuidutils
diff --git a/nova/console/manager.py b/nova/console/manager.py
index 2045f824d..77be2ad4d 100644
--- a/nova/console/manager.py
+++ b/nova/console/manager.py
@@ -19,10 +19,11 @@
import socket
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import manager
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/console/rpcapi.py b/nova/console/rpcapi.py
index 5a91a81cb..78c0c9c1a 100644
--- a/nova/console/rpcapi.py
+++ b/nova/console/rpcapi.py
@@ -18,7 +18,8 @@
Client side of the console RPC API.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
import nova.openstack.common.rpc.proxy
rpcapi_opts = [
diff --git a/nova/console/vmrc.py b/nova/console/vmrc.py
index fcd733cf9..d7c66a00d 100644
--- a/nova/console/vmrc.py
+++ b/nova/console/vmrc.py
@@ -19,8 +19,9 @@
import base64
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.virt.vmwareapi import vim_util
diff --git a/nova/console/vmrc_manager.py b/nova/console/vmrc_manager.py
index bb1818943..f1ea41796 100644
--- a/nova/console/vmrc_manager.py
+++ b/nova/console/vmrc_manager.py
@@ -17,10 +17,11 @@
"""VMRC Console Manager."""
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import manager
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.virt.vmwareapi import driver as vmwareapi_conn
diff --git a/nova/console/xvp.py b/nova/console/xvp.py
index ce2eb5350..c090e84d4 100644
--- a/nova/console/xvp.py
+++ b/nova/console/xvp.py
@@ -21,11 +21,11 @@ import os
import signal
from Cheetah import Template
+from oslo.config import cfg
from nova import context
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
diff --git a/nova/consoleauth/__init__.py b/nova/consoleauth/__init__.py
index c533043f3..3100ee15c 100644
--- a/nova/consoleauth/__init__.py
+++ b/nova/consoleauth/__init__.py
@@ -18,7 +18,7 @@
"""Module to authenticate Consoles."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
consoleauth_topic_opt = cfg.StrOpt('consoleauth_topic',
diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py
index 2dfc72435..74321a27b 100644
--- a/nova/consoleauth/manager.py
+++ b/nova/consoleauth/manager.py
@@ -20,9 +20,10 @@
import time
+from oslo.config import cfg
+
from nova.common import memorycache
from nova import manager
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
diff --git a/nova/consoleauth/rpcapi.py b/nova/consoleauth/rpcapi.py
index 64b915ec3..813143f76 100644
--- a/nova/consoleauth/rpcapi.py
+++ b/nova/consoleauth/rpcapi.py
@@ -18,7 +18,8 @@
Client side of the consoleauth RPC API.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
import nova.openstack.common.rpc.proxy
CONF = cfg.CONF
diff --git a/nova/crypto.py b/nova/crypto.py
index 96e545893..4d72aa624 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -31,13 +31,13 @@ import re
import string
import struct
+from oslo.config import cfg
from pyasn1.codec.der import encoder as der_encoder
from pyasn1.type import univ
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 log as logging
from nova.openstack.common import timeutils
diff --git a/nova/db/api.py b/nova/db/api.py
index 6b0360f00..e38cf1866 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -43,9 +43,10 @@ these objects be simple dictionaries.
"""
+from oslo.config import cfg
+
from nova.cells import rpcapi as cells_rpcapi
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/db/base.py b/nova/db/base.py
index 2028e375e..1d8433661 100644
--- a/nova/db/base.py
+++ b/nova/db/base.py
@@ -18,7 +18,8 @@
"""Base class for classes that need modular database access."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import importutils
db_driver_opt = cfg.StrOpt('db_driver',
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 9d595408d..2ac08f6eb 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -25,6 +25,7 @@ import datetime
import functools
import uuid
+from oslo.config import cfg
from sqlalchemy import and_
from sqlalchemy import Boolean
from sqlalchemy.exc import IntegrityError
@@ -47,7 +48,6 @@ from nova.compute import vm_states
from nova import db
from nova.db.sqlalchemy import models
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common.db.sqlalchemy import utils as sqlalchemyutils
from nova.openstack.common import log as logging
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index f0dcd3307..95456bf98 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -25,13 +25,12 @@ from sqlalchemy import Column, Integer, BigInteger, String, schema
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime, Boolean, Text, Float
from sqlalchemy.orm import relationship, backref, object_mapper
+from oslo.config import cfg
from nova.db.sqlalchemy import types
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import models
from nova.openstack.common import timeutils
-
CONF = cfg.CONF
BASE = declarative_base()
diff --git a/nova/exception.py b/nova/exception.py
index 09b01b342..5969d9e57 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -26,9 +26,9 @@ SHOULD include dedicated exception logging.
import functools
+from oslo.config import cfg
import webob.exc
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
diff --git a/nova/image/glance.py b/nova/image/glance.py
index 78cfc3dee..79614d6a7 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -29,9 +29,9 @@ import urlparse
import glanceclient
import glanceclient.exc
+from oslo.config import cfg
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/image/s3.py b/nova/image/s3.py
index 833fb44f9..100d80030 100644
--- a/nova/image/s3.py
+++ b/nova/image/s3.py
@@ -28,12 +28,12 @@ import tempfile
import boto.s3.connection
import eventlet
from lxml import etree
+from oslo.config import cfg
from nova.api.ec2 import ec2utils
import nova.cert.rpcapi
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/ipv6/api.py b/nova/ipv6/api.py
index 43a185101..7f94abcfb 100644
--- a/nova/ipv6/api.py
+++ b/nova/ipv6/api.py
@@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
-from nova import utils
+from oslo.config import cfg
+from nova import utils
ipv6_backend_opt = cfg.StrOpt('ipv6_backend',
default='rfc2462',
diff --git a/nova/manager.py b/nova/manager.py
index a0269d30b..cc7d464ca 100644
--- a/nova/manager.py
+++ b/nova/manager.py
@@ -53,12 +53,13 @@ This module provides Manager, a base class for managers.
"""
-import eventlet
import time
+import eventlet
+from oslo.config import cfg
+
from nova.db import base
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common.plugin import pluginmanager
from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
diff --git a/nova/netconf.py b/nova/netconf.py
index 531a9e200..f8116ed97 100644
--- a/nova/netconf.py
+++ b/nova/netconf.py
@@ -19,7 +19,7 @@
import socket
-from nova.openstack.common import cfg
+from oslo.config import cfg
CONF = cfg.CONF
diff --git a/nova/network/__init__.py b/nova/network/__init__.py
index f0eeb4e84..89c63fcab 100644
--- a/nova/network/__init__.py
+++ b/nova/network/__init__.py
@@ -16,23 +16,24 @@
# License for the specific language governing permissions and limitations
# under the License.
+import oslo.config.cfg
+
# Importing full names to not pollute the namespace and cause possible
# collisions with use of 'from nova.network import <foo>' elsewhere.
-import nova.openstack.common.cfg
import nova.openstack.common.importutils
_network_opts = [
- nova.openstack.common.cfg.StrOpt('network_api_class',
- default='nova.network.api.API',
- help='The full class name of the '
- 'network API class to use'),
+ oslo.config.cfg.StrOpt('network_api_class',
+ default='nova.network.api.API',
+ help='The full class name of the '
+ 'network API class to use'),
]
-nova.openstack.common.cfg.CONF.register_opts(_network_opts)
+oslo.config.cfg.CONF.register_opts(_network_opts)
def API():
importutils = nova.openstack.common.importutils
- network_api_class = nova.openstack.common.cfg.CONF.network_api_class
+ network_api_class = oslo.config.cfg.CONF.network_api_class
cls = importutils.import_class(network_api_class)
return cls()
diff --git a/nova/network/driver.py b/nova/network/driver.py
index 2a9218898..47d043e09 100644
--- a/nova/network/driver.py
+++ b/nova/network/driver.py
@@ -16,7 +16,8 @@
import sys
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/network/floating_ips.py b/nova/network/floating_ips.py
index 2890573c1..c35dc85f9 100644
--- a/nova/network/floating_ips.py
+++ b/nova/network/floating_ips.py
@@ -17,11 +17,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova import context
from nova.db import base
from nova import exception
from nova.network import rpcapi as network_rpcapi
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import lockutils
diff --git a/nova/network/ldapdns.py b/nova/network/ldapdns.py
index 680b2f435..df24680b0 100644
--- a/nova/network/ldapdns.py
+++ b/nova/network/ldapdns.py
@@ -15,9 +15,10 @@
import ldap
import time
+from oslo.config import cfg
+
from nova import exception
from nova.network import dns_driver
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 317f2a309..29b882a02 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -25,9 +25,10 @@ import netaddr
import os
import re
+from oslo.config import cfg
+
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 lockutils
@@ -36,7 +37,6 @@ from nova.openstack.common import timeutils
from nova import paths
from nova import utils
-
LOG = logging.getLogger(__name__)
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 410f7a2cb..d7f80dbda 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -50,6 +50,7 @@ import uuid
from eventlet import greenpool
import netaddr
+from oslo.config import cfg
from nova.compute import api as compute_api
from nova import context
@@ -61,7 +62,6 @@ from nova.network import driver
from nova.network import floating_ips
from nova.network import model as network_model
from nova.network import rpcapi as network_rpcapi
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
@@ -72,7 +72,6 @@ from nova.openstack.common import uuidutils
from nova import servicegroup
from nova import utils
-
LOG = logging.getLogger(__name__)
diff --git a/nova/network/minidns.py b/nova/network/minidns.py
index dc9dc6f17..b4b5257ea 100644
--- a/nova/network/minidns.py
+++ b/nova/network/minidns.py
@@ -16,12 +16,12 @@ import os
import shutil
import tempfile
+from oslo.config import cfg
+
from nova import exception
from nova.network import dns_driver
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
-
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
diff --git a/nova/network/quantumv2/__init__.py b/nova/network/quantumv2/__init__.py
index 1b7381e8e..5d3cf5770 100644
--- a/nova/network/quantumv2/__init__.py
+++ b/nova/network/quantumv2/__init__.py
@@ -15,12 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
-from nova.openstack.common import excutils
-from nova.openstack.common import log as logging
+from oslo.config import cfg
from quantumclient import client
from quantumclient.v2_0 import client as clientv20
+from nova.openstack.common import excutils
+from nova.openstack.common import log as logging
+
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
diff --git a/nova/network/quantumv2/api.py b/nova/network/quantumv2/api.py
index f3388f2ab..19a8070b0 100644
--- a/nova/network/quantumv2/api.py
+++ b/nova/network/quantumv2/api.py
@@ -18,6 +18,8 @@
import time
+from oslo.config import cfg
+
from nova import conductor
from nova import context
from nova.db import base
@@ -25,12 +27,10 @@ from nova import exception
from nova.network import api as network_api
from nova.network import model as network_model
from nova.network import quantumv2
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova.openstack.common import uuidutils
-
quantum_opts = [
cfg.StrOpt('quantum_url',
default='http://127.0.0.1:9696',
diff --git a/nova/network/rpcapi.py b/nova/network/rpcapi.py
index ed8b775fd..d0d6b5f99 100644
--- a/nova/network/rpcapi.py
+++ b/nova/network/rpcapi.py
@@ -18,7 +18,8 @@
Client side of the network RPC API.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
from nova.openstack.common import rpc
from nova.openstack.common.rpc import proxy as rpc_proxy
diff --git a/nova/notifications.py b/nova/notifications.py
index f40fff7f2..79d43126a 100644
--- a/nova/notifications.py
+++ b/nova/notifications.py
@@ -19,12 +19,13 @@
the system.
"""
+from oslo.config import cfg
+
import nova.context
from nova import db
from nova.image import glance
from nova import network
from nova.network import model as network_model
-from nova.openstack.common import cfg
from nova.openstack.common import log
from nova.openstack.common.notifier import api as notifier_api
from nova.openstack.common import timeutils
diff --git a/nova/objectstore/s3server.py b/nova/objectstore/s3server.py
index 6a6d6bf32..3ff5fa003 100644
--- a/nova/objectstore/s3server.py
+++ b/nova/objectstore/s3server.py
@@ -41,10 +41,10 @@ import os
import os.path
import urllib
+from oslo.config import cfg
import routes
import webob
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova import paths
from nova import utils
diff --git a/nova/openstack/common/cfg.py b/nova/openstack/common/cfg.py
index baecc0c3b..c35dcb845 100644
--- a/nova/openstack/common/cfg.py
+++ b/nova/openstack/common/cfg.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2012 Red Hat, Inc.
+# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -14,1736 +14,4 @@
# License for the specific language governing permissions and limitations
# under the License.
-r"""
-Configuration options which may be set on the command line or in config files.
-
-The schema for each option is defined using the Opt sub-classes, e.g.:
-
-::
-
- common_opts = [
- cfg.StrOpt('bind_host',
- default='0.0.0.0',
- help='IP address to listen on'),
- cfg.IntOpt('bind_port',
- default=9292,
- help='Port number to listen on')
- ]
-
-Options can be strings, integers, floats, booleans, lists or 'multi strings'::
-
- enabled_apis_opt = cfg.ListOpt('enabled_apis',
- default=['ec2', 'osapi_compute'],
- help='List of APIs to enable by default')
-
- DEFAULT_EXTENSIONS = [
- 'nova.api.openstack.compute.contrib.standard_extensions'
- ]
- osapi_compute_extension_opt = cfg.MultiStrOpt('osapi_compute_extension',
- default=DEFAULT_EXTENSIONS)
-
-Option schemas are registered with the config manager at runtime, but before
-the option is referenced::
-
- class ExtensionManager(object):
-
- enabled_apis_opt = cfg.ListOpt(...)
-
- def __init__(self, conf):
- self.conf = conf
- self.conf.register_opt(enabled_apis_opt)
- ...
-
- def _load_extensions(self):
- for ext_factory in self.conf.osapi_compute_extension:
- ....
-
-A common usage pattern is for each option schema to be defined in the module or
-class which uses the option::
-
- opts = ...
-
- def add_common_opts(conf):
- conf.register_opts(opts)
-
- def get_bind_host(conf):
- return conf.bind_host
-
- def get_bind_port(conf):
- return conf.bind_port
-
-An option may optionally be made available via the command line. Such options
-must registered with the config manager before the command line is parsed (for
-the purposes of --help and CLI arg validation)::
-
- cli_opts = [
- cfg.BoolOpt('verbose',
- short='v',
- default=False,
- help='Print more verbose output'),
- cfg.BoolOpt('debug',
- short='d',
- default=False,
- help='Print debugging output'),
- ]
-
- def add_common_opts(conf):
- conf.register_cli_opts(cli_opts)
-
-The config manager has two CLI options defined by default, --config-file
-and --config-dir::
-
- class ConfigOpts(object):
-
- def __call__(self, ...):
-
- opts = [
- MultiStrOpt('config-file',
- ...),
- StrOpt('config-dir',
- ...),
- ]
-
- self.register_cli_opts(opts)
-
-Option values are parsed from any supplied config files using
-openstack.common.iniparser. If none are specified, a default set is used
-e.g. glance-api.conf and glance-common.conf::
-
- glance-api.conf:
- [DEFAULT]
- bind_port = 9292
-
- glance-common.conf:
- [DEFAULT]
- bind_host = 0.0.0.0
-
-Option values in config files override those on the command line. Config files
-are parsed in order, with values in later files overriding those in earlier
-files.
-
-The parsing of CLI args and config files is initiated by invoking the config
-manager e.g.::
-
- conf = ConfigOpts()
- conf.register_opt(BoolOpt('verbose', ...))
- conf(sys.argv[1:])
- if conf.verbose:
- ...
-
-Options can be registered as belonging to a group::
-
- rabbit_group = cfg.OptGroup(name='rabbit',
- title='RabbitMQ options')
-
- rabbit_host_opt = cfg.StrOpt('host',
- default='localhost',
- help='IP/hostname to listen on'),
- rabbit_port_opt = cfg.IntOpt('port',
- default=5672,
- help='Port number to listen on')
-
- def register_rabbit_opts(conf):
- conf.register_group(rabbit_group)
- # options can be registered under a group in either of these ways:
- conf.register_opt(rabbit_host_opt, group=rabbit_group)
- conf.register_opt(rabbit_port_opt, group='rabbit')
-
-If it no group attributes are required other than the group name, the group
-need not be explicitly registered e.g.
-
- def register_rabbit_opts(conf):
- # The group will automatically be created, equivalent calling::
- # conf.register_group(OptGroup(name='rabbit'))
- conf.register_opt(rabbit_port_opt, group='rabbit')
-
-If no group is specified, options belong to the 'DEFAULT' section of config
-files::
-
- glance-api.conf:
- [DEFAULT]
- bind_port = 9292
- ...
-
- [rabbit]
- host = localhost
- port = 5672
- use_ssl = False
- userid = guest
- password = guest
- virtual_host = /
-
-Command-line options in a group are automatically prefixed with the
-group name::
-
- --rabbit-host localhost --rabbit-port 9999
-
-Option values in the default group are referenced as attributes/properties on
-the config manager; groups are also attributes on the config manager, with
-attributes for each of the options associated with the group::
-
- server.start(app, conf.bind_port, conf.bind_host, conf)
-
- self.connection = kombu.connection.BrokerConnection(
- hostname=conf.rabbit.host,
- port=conf.rabbit.port,
- ...)
-
-Option values may reference other values using PEP 292 string substitution::
-
- opts = [
- cfg.StrOpt('state_path',
- default=os.path.join(os.path.dirname(__file__), '../'),
- help='Top-level directory for maintaining nova state'),
- cfg.StrOpt('sqlite_db',
- default='nova.sqlite',
- help='file name for sqlite'),
- cfg.StrOpt('sql_connection',
- default='sqlite:///$state_path/$sqlite_db',
- help='connection string for sql database'),
- ]
-
-Note that interpolation can be avoided by using '$$'.
-
-Options may be declared as required so that an error is raised if the user
-does not supply a value for the option.
-
-Options may be declared as secret so that their values are not leaked into
-log files::
-
- opts = [
- cfg.StrOpt('s3_store_access_key', secret=True),
- cfg.StrOpt('s3_store_secret_key', secret=True),
- ...
- ]
-
-This module also contains a global instance of the ConfigOpts class
-in order to support a common usage pattern in OpenStack::
-
- from nova.openstack.common import cfg
-
- opts = [
- cfg.StrOpt('bind_host', default='0.0.0.0'),
- cfg.IntOpt('bind_port', default=9292),
- ]
-
- CONF = cfg.CONF
- CONF.register_opts(opts)
-
- def start(server, app):
- server.start(app, CONF.bind_port, CONF.bind_host)
-
-Positional command line arguments are supported via a 'positional' Opt
-constructor argument::
-
- >>> conf = ConfigOpts()
- >>> conf.register_cli_opt(MultiStrOpt('bar', positional=True))
- True
- >>> conf(['a', 'b'])
- >>> conf.bar
- ['a', 'b']
-
-It is also possible to use argparse "sub-parsers" to parse additional
-command line arguments using the SubCommandOpt class:
-
- >>> def add_parsers(subparsers):
- ... list_action = subparsers.add_parser('list')
- ... list_action.add_argument('id')
- ...
- >>> conf = ConfigOpts()
- >>> conf.register_cli_opt(SubCommandOpt('action', handler=add_parsers))
- True
- >>> conf(args=['list', '10'])
- >>> conf.action.name, conf.action.id
- ('list', '10')
-
-"""
-
-import argparse
-import collections
-import copy
-import functools
-import glob
-import os
-import string
-import sys
-
-from nova.openstack.common import iniparser
-
-
-class Error(Exception):
- """Base class for cfg exceptions."""
-
- def __init__(self, msg=None):
- self.msg = msg
-
- def __str__(self):
- return self.msg
-
-
-class ArgsAlreadyParsedError(Error):
- """Raised if a CLI opt is registered after parsing."""
-
- def __str__(self):
- ret = "arguments already parsed"
- if self.msg:
- ret += ": " + self.msg
- return ret
-
-
-class NoSuchOptError(Error, AttributeError):
- """Raised if an opt which doesn't exist is referenced."""
-
- def __init__(self, opt_name, group=None):
- self.opt_name = opt_name
- self.group = group
-
- def __str__(self):
- if self.group is None:
- return "no such option: %s" % self.opt_name
- else:
- return "no such option in group %s: %s" % (self.group.name,
- self.opt_name)
-
-
-class NoSuchGroupError(Error):
- """Raised if a group which doesn't exist is referenced."""
-
- def __init__(self, group_name):
- self.group_name = group_name
-
- def __str__(self):
- return "no such group: %s" % self.group_name
-
-
-class DuplicateOptError(Error):
- """Raised if multiple opts with the same name are registered."""
-
- def __init__(self, opt_name):
- self.opt_name = opt_name
-
- def __str__(self):
- return "duplicate option: %s" % self.opt_name
-
-
-class RequiredOptError(Error):
- """Raised if an option is required but no value is supplied by the user."""
-
- def __init__(self, opt_name, group=None):
- self.opt_name = opt_name
- self.group = group
-
- def __str__(self):
- if self.group is None:
- return "value required for option: %s" % self.opt_name
- else:
- return "value required for option: %s.%s" % (self.group.name,
- self.opt_name)
-
-
-class TemplateSubstitutionError(Error):
- """Raised if an error occurs substituting a variable in an opt value."""
-
- def __str__(self):
- return "template substitution error: %s" % self.msg
-
-
-class ConfigFilesNotFoundError(Error):
- """Raised if one or more config files are not found."""
-
- def __init__(self, config_files):
- self.config_files = config_files
-
- def __str__(self):
- return ('Failed to read some config files: %s' %
- string.join(self.config_files, ','))
-
-
-class ConfigFileParseError(Error):
- """Raised if there is an error parsing a config file."""
-
- def __init__(self, config_file, msg):
- self.config_file = config_file
- self.msg = msg
-
- def __str__(self):
- return 'Failed to parse %s: %s' % (self.config_file, self.msg)
-
-
-class ConfigFileValueError(Error):
- """Raised if a config file value does not match its opt type."""
- pass
-
-
-def _fixpath(p):
- """Apply tilde expansion and absolutization to a path."""
- return os.path.abspath(os.path.expanduser(p))
-
-
-def _get_config_dirs(project=None):
- """Return a list of directors where config files may be located.
-
- :param project: an optional project name
-
- If a project is specified, following directories are returned::
-
- ~/.${project}/
- ~/
- /etc/${project}/
- /etc/
-
- Otherwise, these directories::
-
- ~/
- /etc/
- """
- cfg_dirs = [
- _fixpath(os.path.join('~', '.' + project)) if project else None,
- _fixpath('~'),
- os.path.join('/etc', project) if project else None,
- '/etc'
- ]
-
- return filter(bool, cfg_dirs)
-
-
-def _search_dirs(dirs, basename, extension=""):
- """Search a list of directories for a given filename.
-
- Iterator over the supplied directories, returning the first file
- found with the supplied name and extension.
-
- :param dirs: a list of directories
- :param basename: the filename, e.g. 'glance-api'
- :param extension: the file extension, e.g. '.conf'
- :returns: the path to a matching file, or None
- """
- for d in dirs:
- path = os.path.join(d, '%s%s' % (basename, extension))
- if os.path.exists(path):
- return path
-
-
-def find_config_files(project=None, prog=None, extension='.conf'):
- """Return a list of default configuration files.
-
- :param project: an optional project name
- :param prog: the program name, defaulting to the basename of sys.argv[0]
- :param extension: the type of the config file
-
- We default to two config files: [${project}.conf, ${prog}.conf]
-
- And we look for those config files in the following directories::
-
- ~/.${project}/
- ~/
- /etc/${project}/
- /etc/
-
- We return an absolute path for (at most) one of each the default config
- files, for the topmost directory it exists in.
-
- For example, if project=foo, prog=bar and /etc/foo/foo.conf, /etc/bar.conf
- and ~/.foo/bar.conf all exist, then we return ['/etc/foo/foo.conf',
- '~/.foo/bar.conf']
-
- If no project name is supplied, we only look for ${prog.conf}.
- """
- if prog is None:
- prog = os.path.basename(sys.argv[0])
-
- cfg_dirs = _get_config_dirs(project)
-
- config_files = []
- if project:
- config_files.append(_search_dirs(cfg_dirs, project, extension))
- config_files.append(_search_dirs(cfg_dirs, prog, extension))
-
- return filter(bool, config_files)
-
-
-def _is_opt_registered(opts, opt):
- """Check whether an opt with the same name is already registered.
-
- The same opt may be registered multiple times, with only the first
- registration having any effect. However, it is an error to attempt
- to register a different opt with the same name.
-
- :param opts: the set of opts already registered
- :param opt: the opt to be registered
- :returns: True if the opt was previously registered, False otherwise
- :raises: DuplicateOptError if a naming conflict is detected
- """
- if opt.dest in opts:
- if opts[opt.dest]['opt'] != opt:
- raise DuplicateOptError(opt.name)
- return True
- else:
- return False
-
-
-def set_defaults(opts, **kwargs):
- for opt in opts:
- if opt.dest in kwargs:
- opt.default = kwargs[opt.dest]
- break
-
-
-class Opt(object):
-
- """Base class for all configuration options.
-
- An Opt object has no public methods, but has a number of public string
- properties:
-
- name:
- the name of the option, which may include hyphens
- dest:
- the (hyphen-less) ConfigOpts property which contains the option value
- short:
- a single character CLI option name
- default:
- the default value of the option
- positional:
- True if the option is a positional CLI argument
- metavar:
- the name shown as the argument to a CLI option in --help output
- help:
- an string explaining how the options value is used
- """
- multi = False
-
- def __init__(self, name, dest=None, short=None, default=None,
- positional=False, metavar=None, help=None,
- secret=False, required=False, deprecated_name=None):
- """Construct an Opt object.
-
- The only required parameter is the option's name. However, it is
- common to also supply a default and help string for all options.
-
- :param name: the option's name
- :param dest: the name of the corresponding ConfigOpts property
- :param short: a single character CLI option name
- :param default: the default value of the option
- :param positional: True if the option is a positional CLI argument
- :param metavar: the option argument to show in --help
- :param help: an explanation of how the option is used
- :param secret: true iff the value should be obfuscated in log output
- :param required: true iff a value must be supplied for this option
- :param deprecated_name: deprecated name option. Acts like an alias
- """
- self.name = name
- if dest is None:
- self.dest = self.name.replace('-', '_')
- else:
- self.dest = dest
- self.short = short
- self.default = default
- self.positional = positional
- self.metavar = metavar
- self.help = help
- self.secret = secret
- self.required = required
- if deprecated_name is not None:
- self.deprecated_name = deprecated_name.replace('-', '_')
- else:
- self.deprecated_name = None
-
- def __ne__(self, another):
- return vars(self) != vars(another)
-
- def _get_from_config_parser(self, cparser, section):
- """Retrieves the option value from a MultiConfigParser object.
-
- This is the method ConfigOpts uses to look up the option value from
- config files. Most opt types override this method in order to perform
- type appropriate conversion of the returned value.
-
- :param cparser: a ConfigParser object
- :param section: a section name
- """
- return self._cparser_get_with_deprecated(cparser, section)
-
- def _cparser_get_with_deprecated(self, cparser, section):
- """If cannot find option as dest try deprecated_name alias."""
- if self.deprecated_name is not None:
- return cparser.get(section, [self.dest, self.deprecated_name])
- return cparser.get(section, [self.dest])
-
- def _add_to_cli(self, parser, group=None):
- """Makes the option available in the command line interface.
-
- This is the method ConfigOpts uses to add the opt to the CLI interface
- as appropriate for the opt type. Some opt types may extend this method,
- others may just extend the helper methods it uses.
-
- :param parser: the CLI option parser
- :param group: an optional OptGroup object
- """
- container = self._get_argparse_container(parser, group)
- kwargs = self._get_argparse_kwargs(group)
- prefix = self._get_argparse_prefix('', group)
- self._add_to_argparse(container, self.name, self.short, kwargs, prefix,
- self.positional, self.deprecated_name)
-
- def _add_to_argparse(self, container, name, short, kwargs, prefix='',
- positional=False, deprecated_name=None):
- """Add an option to an argparse parser or group.
-
- :param container: an argparse._ArgumentGroup object
- :param name: the opt name
- :param short: the short opt name
- :param kwargs: the keyword arguments for add_argument()
- :param prefix: an optional prefix to prepend to the opt name
- :param position: whether the optional is a positional CLI argument
- :raises: DuplicateOptError if a naming confict is detected
- """
- def hyphen(arg):
- return arg if not positional else ''
-
- args = [hyphen('--') + prefix + name]
- if short:
- args.append(hyphen('-') + short)
- if deprecated_name:
- args.append(hyphen('--') + prefix + deprecated_name)
-
- try:
- container.add_argument(*args, **kwargs)
- except argparse.ArgumentError as e:
- raise DuplicateOptError(e)
-
- def _get_argparse_container(self, parser, group):
- """Returns an argparse._ArgumentGroup.
-
- :param parser: an argparse.ArgumentParser
- :param group: an (optional) OptGroup object
- :returns: an argparse._ArgumentGroup if group is given, else parser
- """
- if group is not None:
- return group._get_argparse_group(parser)
- else:
- return parser
-
- def _get_argparse_kwargs(self, group, **kwargs):
- """Build a dict of keyword arguments for argparse's add_argument().
-
- Most opt types extend this method to customize the behaviour of the
- options added to argparse.
-
- :param group: an optional group
- :param kwargs: optional keyword arguments to add to
- :returns: a dict of keyword arguments
- """
- if not self.positional:
- dest = self.dest
- if group is not None:
- dest = group.name + '_' + dest
- kwargs['dest'] = dest
- else:
- kwargs['nargs'] = '?'
- kwargs.update({'default': None,
- 'metavar': self.metavar,
- 'help': self.help, })
- return kwargs
-
- def _get_argparse_prefix(self, prefix, group):
- """Build a prefix for the CLI option name, if required.
-
- CLI options in a group are prefixed with the group's name in order
- to avoid conflicts between similarly named options in different
- groups.
-
- :param prefix: an existing prefix to append to (e.g. 'no' or '')
- :param group: an optional OptGroup object
- :returns: a CLI option prefix including the group name, if appropriate
- """
- if group is not None:
- return group.name + '-' + prefix
- else:
- return prefix
-
-
-class StrOpt(Opt):
- """
- String opts do not have their values transformed and are returned as
- str objects.
- """
- pass
-
-
-class BoolOpt(Opt):
-
- """
- Bool opts are set to True or False on the command line using --optname or
- --noopttname respectively.
-
- In config files, boolean values are case insensitive and can be set using
- 1/0, yes/no, true/false or on/off.
- """
-
- _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True,
- '0': False, 'no': False, 'false': False, 'off': False}
-
- def __init__(self, *args, **kwargs):
- if 'positional' in kwargs:
- raise ValueError('positional boolean args not supported')
- super(BoolOpt, self).__init__(*args, **kwargs)
-
- def _get_from_config_parser(self, cparser, section):
- """Retrieve the opt value as a boolean from ConfigParser."""
- def convert_bool(v):
- value = self._boolean_states.get(v.lower())
- if value is None:
- raise ValueError('Unexpected boolean value %r' % v)
-
- return value
-
- return [convert_bool(v) for v in
- self._cparser_get_with_deprecated(cparser, section)]
-
- def _add_to_cli(self, parser, group=None):
- """Extends the base class method to add the --nooptname option."""
- super(BoolOpt, self)._add_to_cli(parser, group)
- self._add_inverse_to_argparse(parser, group)
-
- def _add_inverse_to_argparse(self, parser, group):
- """Add the --nooptname option to the option parser."""
- container = self._get_argparse_container(parser, group)
- kwargs = self._get_argparse_kwargs(group, action='store_false')
- prefix = self._get_argparse_prefix('no', group)
- kwargs["help"] = "The inverse of --" + self.name
- self._add_to_argparse(container, self.name, None, kwargs, prefix,
- self.positional, self.deprecated_name)
-
- def _get_argparse_kwargs(self, group, action='store_true', **kwargs):
- """Extends the base argparse keyword dict for boolean options."""
-
- kwargs = super(BoolOpt, self)._get_argparse_kwargs(group, **kwargs)
-
- # metavar has no effect for BoolOpt
- if 'metavar' in kwargs:
- del kwargs['metavar']
-
- if action != 'store_true':
- action = 'store_false'
-
- kwargs['action'] = action
-
- return kwargs
-
-
-class IntOpt(Opt):
-
- """Int opt values are converted to integers using the int() builtin."""
-
- def _get_from_config_parser(self, cparser, section):
- """Retrieve the opt value as a integer from ConfigParser."""
- return [int(v) for v in self._cparser_get_with_deprecated(cparser,
- section)]
-
- def _get_argparse_kwargs(self, group, **kwargs):
- """Extends the base argparse keyword dict for integer options."""
- return super(IntOpt,
- self)._get_argparse_kwargs(group, type=int, **kwargs)
-
-
-class FloatOpt(Opt):
-
- """Float opt values are converted to floats using the float() builtin."""
-
- def _get_from_config_parser(self, cparser, section):
- """Retrieve the opt value as a float from ConfigParser."""
- return [float(v) for v in
- self._cparser_get_with_deprecated(cparser, section)]
-
- def _get_argparse_kwargs(self, group, **kwargs):
- """Extends the base argparse keyword dict for float options."""
- return super(FloatOpt, self)._get_argparse_kwargs(group,
- type=float, **kwargs)
-
-
-class ListOpt(Opt):
-
- """
- List opt values are simple string values separated by commas. The opt value
- is a list containing these strings.
- """
-
- class _StoreListAction(argparse.Action):
- """
- An argparse action for parsing an option value into a list.
- """
- def __call__(self, parser, namespace, values, option_string=None):
- if values is not None:
- values = [a.strip() for a in values.split(',')]
- setattr(namespace, self.dest, values)
-
- def _get_from_config_parser(self, cparser, section):
- """Retrieve the opt value as a list from ConfigParser."""
- return [[a.strip() for a in v.split(',')] for v in
- self._cparser_get_with_deprecated(cparser, section)]
-
- def _get_argparse_kwargs(self, group, **kwargs):
- """Extends the base argparse keyword dict for list options."""
- return Opt._get_argparse_kwargs(self,
- group,
- action=ListOpt._StoreListAction,
- **kwargs)
-
-
-class MultiStrOpt(Opt):
-
- """
- Multistr opt values are string opts which may be specified multiple times.
- The opt value is a list containing all the string values specified.
- """
- multi = True
-
- def _get_argparse_kwargs(self, group, **kwargs):
- """Extends the base argparse keyword dict for multi str options."""
- kwargs = super(MultiStrOpt, self)._get_argparse_kwargs(group)
- if not self.positional:
- kwargs['action'] = 'append'
- else:
- kwargs['nargs'] = '*'
- return kwargs
-
- def _cparser_get_with_deprecated(self, cparser, section):
- """If cannot find option as dest try deprecated_name alias."""
- if self.deprecated_name is not None:
- return cparser.get(section, [self.dest, self.deprecated_name],
- multi=True)
- return cparser.get(section, [self.dest], multi=True)
-
-
-class SubCommandOpt(Opt):
-
- """
- Sub-command options allow argparse sub-parsers to be used to parse
- additional command line arguments.
-
- The handler argument to the SubCommandOpt contructor is a callable
- which is supplied an argparse subparsers object. Use this handler
- callable to add sub-parsers.
-
- The opt value is SubCommandAttr object with the name of the chosen
- sub-parser stored in the 'name' attribute and the values of other
- sub-parser arguments available as additional attributes.
- """
-
- def __init__(self, name, dest=None, handler=None,
- title=None, description=None, help=None):
- """Construct an sub-command parsing option.
-
- This behaves similarly to other Opt sub-classes but adds a
- 'handler' argument. The handler is a callable which is supplied
- an subparsers object when invoked. The add_parser() method on
- this subparsers object can be used to register parsers for
- sub-commands.
-
- :param name: the option's name
- :param dest: the name of the corresponding ConfigOpts property
- :param title: title of the sub-commands group in help output
- :param description: description of the group in help output
- :param help: a help string giving an overview of available sub-commands
- """
- super(SubCommandOpt, self).__init__(name, dest=dest, help=help)
- self.handler = handler
- self.title = title
- self.description = description
-
- def _add_to_cli(self, parser, group=None):
- """Add argparse sub-parsers and invoke the handler method."""
- dest = self.dest
- if group is not None:
- dest = group.name + '_' + dest
-
- subparsers = parser.add_subparsers(dest=dest,
- title=self.title,
- description=self.description,
- help=self.help)
-
- if self.handler is not None:
- self.handler(subparsers)
-
-
-class OptGroup(object):
-
- """
- Represents a group of opts.
-
- CLI opts in the group are automatically prefixed with the group name.
-
- Each group corresponds to a section in config files.
-
- An OptGroup object has no public methods, but has a number of public string
- properties:
-
- name:
- the name of the group
- title:
- the group title as displayed in --help
- help:
- the group description as displayed in --help
- """
-
- def __init__(self, name, title=None, help=None):
- """Constructs an OptGroup object.
-
- :param name: the group name
- :param title: the group title for --help
- :param help: the group description for --help
- """
- self.name = name
- if title is None:
- self.title = "%s options" % title
- else:
- self.title = title
- self.help = help
-
- self._opts = {} # dict of dicts of (opt:, override:, default:)
- self._argparse_group = None
-
- def _register_opt(self, opt, cli=False):
- """Add an opt to this group.
-
- :param opt: an Opt object
- :param cli: whether this is a CLI option
- :returns: False if previously registered, True otherwise
- :raises: DuplicateOptError if a naming conflict is detected
- """
- if _is_opt_registered(self._opts, opt):
- return False
-
- self._opts[opt.dest] = {'opt': opt, 'cli': cli}
-
- return True
-
- def _unregister_opt(self, opt):
- """Remove an opt from this group.
-
- :param opt: an Opt object
- """
- if opt.dest in self._opts:
- del self._opts[opt.dest]
-
- def _get_argparse_group(self, parser):
- if self._argparse_group is None:
- """Build an argparse._ArgumentGroup for this group."""
- self._argparse_group = parser.add_argument_group(self.title,
- self.help)
- return self._argparse_group
-
- def _clear(self):
- """Clear this group's option parsing state."""
- self._argparse_group = None
-
-
-class ParseError(iniparser.ParseError):
- def __init__(self, msg, lineno, line, filename):
- super(ParseError, self).__init__(msg, lineno, line)
- self.filename = filename
-
- def __str__(self):
- return 'at %s:%d, %s: %r' % (self.filename, self.lineno,
- self.msg, self.line)
-
-
-class ConfigParser(iniparser.BaseParser):
- def __init__(self, filename, sections):
- super(ConfigParser, self).__init__()
- self.filename = filename
- self.sections = sections
- self.section = None
-
- def parse(self):
- with open(self.filename) as f:
- return super(ConfigParser, self).parse(f)
-
- def new_section(self, section):
- self.section = section
- self.sections.setdefault(self.section, {})
-
- def assignment(self, key, value):
- if not self.section:
- raise self.error_no_section()
-
- self.sections[self.section].setdefault(key, [])
- self.sections[self.section][key].append('\n'.join(value))
-
- def parse_exc(self, msg, lineno, line=None):
- return ParseError(msg, lineno, line, self.filename)
-
- def error_no_section(self):
- return self.parse_exc('Section must be started before assignment',
- self.lineno)
-
-
-class MultiConfigParser(object):
- def __init__(self):
- self.parsed = []
-
- def read(self, config_files):
- read_ok = []
-
- for filename in config_files:
- sections = {}
- parser = ConfigParser(filename, sections)
-
- try:
- parser.parse()
- except IOError:
- continue
- self.parsed.insert(0, sections)
- read_ok.append(filename)
-
- return read_ok
-
- def get(self, section, names, multi=False):
- rvalue = []
- for sections in self.parsed:
- if section not in sections:
- continue
- for name in names:
- if name in sections[section]:
- if multi:
- rvalue = sections[section][name] + rvalue
- else:
- return sections[section][name]
- if multi and rvalue != []:
- return rvalue
- raise KeyError
-
-
-class ConfigOpts(collections.Mapping):
-
- """
- Config options which may be set on the command line or in config files.
-
- ConfigOpts is a configuration option manager with APIs for registering
- option schemas, grouping options, parsing option values and retrieving
- the values of options.
- """
-
- def __init__(self):
- """Construct a ConfigOpts object."""
- self._opts = {} # dict of dicts of (opt:, override:, default:)
- self._groups = {}
-
- self._args = None
-
- self._oparser = None
- self._cparser = None
- self._cli_values = {}
- self.__cache = {}
- self._config_opts = []
-
- def _pre_setup(self, project, prog, version, usage, default_config_files):
- """Initialize a ConfigCliParser object for option parsing."""
-
- if prog is None:
- prog = os.path.basename(sys.argv[0])
-
- if default_config_files is None:
- default_config_files = find_config_files(project, prog)
-
- self._oparser = argparse.ArgumentParser(prog=prog, usage=usage)
- self._oparser.add_argument('--version',
- action='version',
- version=version)
-
- return prog, default_config_files
-
- def _setup(self, project, prog, version, usage, default_config_files):
- """Initialize a ConfigOpts object for option parsing."""
-
- self._config_opts = [
- MultiStrOpt('config-file',
- default=default_config_files,
- metavar='PATH',
- help='Path to a config file to use. Multiple config '
- 'files can be specified, with values in later '
- 'files taking precedence. The default files '
- ' used are: %s' % (default_config_files, )),
- StrOpt('config-dir',
- metavar='DIR',
- help='Path to a config directory to pull *.conf '
- 'files from. This file set is sorted, so as to '
- 'provide a predictable parse order if individual '
- 'options are over-ridden. The set is parsed after '
- 'the file(s), if any, specified via --config-file, '
- 'hence over-ridden options in the directory take '
- 'precedence.'),
- ]
- self.register_cli_opts(self._config_opts)
-
- self.project = project
- self.prog = prog
- self.version = version
- self.usage = usage
- self.default_config_files = default_config_files
-
- def __clear_cache(f):
- @functools.wraps(f)
- def __inner(self, *args, **kwargs):
- if kwargs.pop('clear_cache', True):
- self.__cache.clear()
- return f(self, *args, **kwargs)
-
- return __inner
-
- def __call__(self,
- args=None,
- project=None,
- prog=None,
- version=None,
- usage=None,
- default_config_files=None):
- """Parse command line arguments and config files.
-
- Calling a ConfigOpts object causes the supplied command line arguments
- and config files to be parsed, causing opt values to be made available
- as attributes of the object.
-
- The object may be called multiple times, each time causing the previous
- set of values to be overwritten.
-
- Automatically registers the --config-file option with either a supplied
- list of default config files, or a list from find_config_files().
-
- If the --config-dir option is set, any *.conf files from this
- directory are pulled in, after all the file(s) specified by the
- --config-file option.
-
- :param args: command line arguments (defaults to sys.argv[1:])
- :param project: the toplevel project name, used to locate config files
- :param prog: the name of the program (defaults to sys.argv[0] basename)
- :param version: the program version (for --version)
- :param usage: a usage string (%prog will be expanded)
- :param default_config_files: config files to use by default
- :returns: the list of arguments left over after parsing options
- :raises: SystemExit, ConfigFilesNotFoundError, ConfigFileParseError,
- RequiredOptError, DuplicateOptError
- """
-
- self.clear()
-
- prog, default_config_files = self._pre_setup(project,
- prog,
- version,
- usage,
- default_config_files)
-
- self._setup(project, prog, version, usage, default_config_files)
-
- self._cli_values = self._parse_cli_opts(args)
-
- self._parse_config_files()
-
- self._check_required_opts()
-
- def __getattr__(self, name):
- """Look up an option value and perform string substitution.
-
- :param name: the opt name (or 'dest', more precisely)
- :returns: the option value (after string subsititution) or a GroupAttr
- :raises: NoSuchOptError,ConfigFileValueError,TemplateSubstitutionError
- """
- return self._get(name)
-
- def __getitem__(self, key):
- """Look up an option value and perform string substitution."""
- return self.__getattr__(key)
-
- def __contains__(self, key):
- """Return True if key is the name of a registered opt or group."""
- return key in self._opts or key in self._groups
-
- def __iter__(self):
- """Iterate over all registered opt and group names."""
- for key in self._opts.keys() + self._groups.keys():
- yield key
-
- def __len__(self):
- """Return the number of options and option groups."""
- return len(self._opts) + len(self._groups)
-
- def reset(self):
- """Clear the object state and unset overrides and defaults."""
- self._unset_defaults_and_overrides()
- self.clear()
-
- @__clear_cache
- def clear(self):
- """Clear the state of the object to before it was called.
-
- Any subparsers added using the add_cli_subparsers() will also be
- removed as a side-effect of this method.
- """
- self._args = None
- self._cli_values.clear()
- self._oparser = argparse.ArgumentParser()
- self._cparser = None
- self.unregister_opts(self._config_opts)
- for group in self._groups.values():
- group._clear()
-
- @__clear_cache
- def register_opt(self, opt, group=None, cli=False):
- """Register an option schema.
-
- Registering an option schema makes any option value which is previously
- or subsequently parsed from the command line or config files available
- as an attribute of this object.
-
- :param opt: an instance of an Opt sub-class
- :param cli: whether this is a CLI option
- :param group: an optional OptGroup object or group name
- :return: False if the opt was already register, True otherwise
- :raises: DuplicateOptError
- """
- if group is not None:
- group = self._get_group(group, autocreate=True)
- return group._register_opt(opt, cli)
-
- if _is_opt_registered(self._opts, opt):
- return False
-
- self._opts[opt.dest] = {'opt': opt, 'cli': cli}
-
- return True
-
- @__clear_cache
- def register_opts(self, opts, group=None):
- """Register multiple option schemas at once."""
- for opt in opts:
- self.register_opt(opt, group, clear_cache=False)
-
- @__clear_cache
- def register_cli_opt(self, opt, group=None):
- """Register a CLI option schema.
-
- CLI option schemas must be registered before the command line and
- config files are parsed. This is to ensure that all CLI options are
- show in --help and option validation works as expected.
-
- :param opt: an instance of an Opt sub-class
- :param group: an optional OptGroup object or group name
- :return: False if the opt was already register, True otherwise
- :raises: DuplicateOptError, ArgsAlreadyParsedError
- """
- if self._args is not None:
- raise ArgsAlreadyParsedError("cannot register CLI option")
-
- return self.register_opt(opt, group, cli=True, clear_cache=False)
-
- @__clear_cache
- def register_cli_opts(self, opts, group=None):
- """Register multiple CLI option schemas at once."""
- for opt in opts:
- self.register_cli_opt(opt, group, clear_cache=False)
-
- def register_group(self, group):
- """Register an option group.
-
- An option group must be registered before options can be registered
- with the group.
-
- :param group: an OptGroup object
- """
- if group.name in self._groups:
- return
-
- self._groups[group.name] = copy.copy(group)
-
- @__clear_cache
- def unregister_opt(self, opt, group=None):
- """Unregister an option.
-
- :param opt: an Opt object
- :param group: an optional OptGroup object or group name
- :raises: ArgsAlreadyParsedError, NoSuchGroupError
- """
- if self._args is not None:
- raise ArgsAlreadyParsedError("reset before unregistering options")
-
- if group is not None:
- self._get_group(group)._unregister_opt(opt)
- elif opt.dest in self._opts:
- del self._opts[opt.dest]
-
- @__clear_cache
- def unregister_opts(self, opts, group=None):
- """Unregister multiple CLI option schemas at once."""
- for opt in opts:
- self.unregister_opt(opt, group, clear_cache=False)
-
- def import_opt(self, name, module_str, group=None):
- """Import an option definition from a module.
-
- Import a module and check that a given option is registered.
-
- This is intended for use with global configuration objects
- like cfg.CONF where modules commonly register options with
- CONF at module load time. If one module requires an option
- defined by another module it can use this method to explicitly
- declare the dependency.
-
- :param name: the name/dest of the opt
- :param module_str: the name of a module to import
- :param group: an option OptGroup object or group name
- :raises: NoSuchOptError, NoSuchGroupError
- """
- __import__(module_str)
- self._get_opt_info(name, group)
-
- def import_group(self, group, module_str):
- """Import an option group from a module.
-
- Import a module and check that a given option group is registered.
-
- This is intended for use with global configuration objects
- like cfg.CONF where modules commonly register options with
- CONF at module load time. If one module requires an option group
- defined by another module it can use this method to explicitly
- declare the dependency.
-
- :param group: an option OptGroup object or group name
- :param module_str: the name of a module to import
- :raises: ImportError, NoSuchGroupError
- """
- __import__(module_str)
- self._get_group(group)
-
- @__clear_cache
- def set_override(self, name, override, group=None):
- """Override an opt value.
-
- Override the command line, config file and default values of a
- given option.
-
- :param name: the name/dest of the opt
- :param override: the override value
- :param group: an option OptGroup object or group name
- :raises: NoSuchOptError, NoSuchGroupError
- """
- opt_info = self._get_opt_info(name, group)
- opt_info['override'] = override
-
- @__clear_cache
- def set_default(self, name, default, group=None):
- """Override an opt's default value.
-
- Override the default value of given option. A command line or
- config file value will still take precedence over this default.
-
- :param name: the name/dest of the opt
- :param default: the default value
- :param group: an option OptGroup object or group name
- :raises: NoSuchOptError, NoSuchGroupError
- """
- opt_info = self._get_opt_info(name, group)
- opt_info['default'] = default
-
- @__clear_cache
- def clear_override(self, name, group=None):
- """Clear an override an opt value.
-
- Clear a previously set override of the command line, config file
- and default values of a given option.
-
- :param name: the name/dest of the opt
- :param group: an option OptGroup object or group name
- :raises: NoSuchOptError, NoSuchGroupError
- """
- opt_info = self._get_opt_info(name, group)
- opt_info.pop('override', None)
-
- @__clear_cache
- def clear_default(self, name, group=None):
- """Clear an override an opt's default value.
-
- Clear a previously set override of the default value of given option.
-
- :param name: the name/dest of the opt
- :param group: an option OptGroup object or group name
- :raises: NoSuchOptError, NoSuchGroupError
- """
- opt_info = self._get_opt_info(name, group)
- opt_info.pop('default', None)
-
- def _all_opt_infos(self):
- """A generator function for iteration opt infos."""
- for info in self._opts.values():
- yield info, None
- for group in self._groups.values():
- for info in group._opts.values():
- yield info, group
-
- def _all_cli_opts(self):
- """A generator function for iterating CLI opts."""
- for info, group in self._all_opt_infos():
- if info['cli']:
- yield info['opt'], group
-
- def _unset_defaults_and_overrides(self):
- """Unset any default or override on all options."""
- for info, group in self._all_opt_infos():
- info.pop('default', None)
- info.pop('override', None)
-
- def find_file(self, name):
- """Locate a file located alongside the config files.
-
- Search for a file with the supplied basename in the directories
- which we have already loaded config files from and other known
- configuration directories.
-
- The directory, if any, supplied by the config_dir option is
- searched first. Then the config_file option is iterated over
- and each of the base directories of the config_files values
- are searched. Failing both of these, the standard directories
- searched by the module level find_config_files() function is
- used. The first matching file is returned.
-
- :param basename: the filename, e.g. 'policy.json'
- :returns: the path to a matching file, or None
- """
- dirs = []
- if self.config_dir:
- dirs.append(_fixpath(self.config_dir))
-
- for cf in reversed(self.config_file):
- dirs.append(os.path.dirname(_fixpath(cf)))
-
- dirs.extend(_get_config_dirs(self.project))
-
- return _search_dirs(dirs, name)
-
- def log_opt_values(self, logger, lvl):
- """Log the value of all registered opts.
-
- It's often useful for an app to log its configuration to a log file at
- startup for debugging. This method dumps to the entire config state to
- the supplied logger at a given log level.
-
- :param logger: a logging.Logger object
- :param lvl: the log level (e.g. logging.DEBUG) arg to logger.log()
- """
- logger.log(lvl, "*" * 80)
- logger.log(lvl, "Configuration options gathered from:")
- logger.log(lvl, "command line args: %s", self._args)
- logger.log(lvl, "config files: %s", self.config_file)
- logger.log(lvl, "=" * 80)
-
- def _sanitize(opt, value):
- """Obfuscate values of options declared secret"""
- return value if not opt.secret else '*' * len(str(value))
-
- for opt_name in sorted(self._opts):
- opt = self._get_opt_info(opt_name)['opt']
- logger.log(lvl, "%-30s = %s", opt_name,
- _sanitize(opt, getattr(self, opt_name)))
-
- for group_name in self._groups:
- group_attr = self.GroupAttr(self, self._get_group(group_name))
- for opt_name in sorted(self._groups[group_name]._opts):
- opt = self._get_opt_info(opt_name, group_name)['opt']
- logger.log(lvl, "%-30s = %s",
- "%s.%s" % (group_name, opt_name),
- _sanitize(opt, getattr(group_attr, opt_name)))
-
- logger.log(lvl, "*" * 80)
-
- def print_usage(self, file=None):
- """Print the usage message for the current program."""
- self._oparser.print_usage(file)
-
- def print_help(self, file=None):
- """Print the help message for the current program."""
- self._oparser.print_help(file)
-
- def _get(self, name, group=None):
- if isinstance(group, OptGroup):
- key = (group.name, name)
- else:
- key = (group, name)
- try:
- return self.__cache[key]
- except KeyError:
- value = self._substitute(self._do_get(name, group))
- self.__cache[key] = value
- return value
-
- def _do_get(self, name, group=None):
- """Look up an option value.
-
- :param name: the opt name (or 'dest', more precisely)
- :param group: an OptGroup
- :returns: the option value, or a GroupAttr object
- :raises: NoSuchOptError, NoSuchGroupError, ConfigFileValueError,
- TemplateSubstitutionError
- """
- if group is None and name in self._groups:
- return self.GroupAttr(self, self._get_group(name))
-
- info = self._get_opt_info(name, group)
- opt = info['opt']
-
- if isinstance(opt, SubCommandOpt):
- return self.SubCommandAttr(self, group, opt.dest)
-
- if 'override' in info:
- return info['override']
-
- values = []
- if self._cparser is not None:
- section = group.name if group is not None else 'DEFAULT'
- try:
- value = opt._get_from_config_parser(self._cparser, section)
- except KeyError:
- pass
- except ValueError as ve:
- raise ConfigFileValueError(str(ve))
- else:
- if not opt.multi:
- # No need to continue since the last value wins
- return value[-1]
- values.extend(value)
-
- name = name if group is None else group.name + '_' + name
- value = self._cli_values.get(name)
- if value is not None:
- if not opt.multi:
- return value
-
- # argparse ignores default=None for nargs='*'
- if opt.positional and not value:
- value = opt.default
-
- return value + values
-
- if values:
- return values
-
- if 'default' in info:
- return info['default']
-
- return opt.default
-
- def _substitute(self, value):
- """Perform string template substitution.
-
- Substitute any template variables (e.g. $foo, ${bar}) in the supplied
- string value(s) with opt values.
-
- :param value: the string value, or list of string values
- :returns: the substituted string(s)
- """
- if isinstance(value, list):
- return [self._substitute(i) for i in value]
- elif isinstance(value, str):
- tmpl = string.Template(value)
- return tmpl.safe_substitute(self.StrSubWrapper(self))
- else:
- return value
-
- def _get_group(self, group_or_name, autocreate=False):
- """Looks up a OptGroup object.
-
- Helper function to return an OptGroup given a parameter which can
- either be the group's name or an OptGroup object.
-
- The OptGroup object returned is from the internal dict of OptGroup
- objects, which will be a copy of any OptGroup object that users of
- the API have access to.
-
- :param group_or_name: the group's name or the OptGroup object itself
- :param autocreate: whether to auto-create the group if it's not found
- :raises: NoSuchGroupError
- """
- group = group_or_name if isinstance(group_or_name, OptGroup) else None
- group_name = group.name if group else group_or_name
-
- if group_name not in self._groups:
- if group is not None or not autocreate:
- raise NoSuchGroupError(group_name)
-
- self.register_group(OptGroup(name=group_name))
-
- return self._groups[group_name]
-
- def _get_opt_info(self, opt_name, group=None):
- """Return the (opt, override, default) dict for an opt.
-
- :param opt_name: an opt name/dest
- :param group: an optional group name or OptGroup object
- :raises: NoSuchOptError, NoSuchGroupError
- """
- if group is None:
- opts = self._opts
- else:
- group = self._get_group(group)
- opts = group._opts
-
- if opt_name not in opts:
- raise NoSuchOptError(opt_name, group)
-
- return opts[opt_name]
-
- def _parse_config_files(self):
- """Parse the config files from --config-file and --config-dir.
-
- :raises: ConfigFilesNotFoundError, ConfigFileParseError
- """
- config_files = list(self.config_file)
-
- if self.config_dir:
- config_dir_glob = os.path.join(self.config_dir, '*.conf')
- config_files += sorted(glob.glob(config_dir_glob))
-
- config_files = [_fixpath(p) for p in config_files]
-
- self._cparser = MultiConfigParser()
-
- try:
- read_ok = self._cparser.read(config_files)
- except iniparser.ParseError as pe:
- raise ConfigFileParseError(pe.filename, str(pe))
-
- if read_ok != config_files:
- not_read_ok = filter(lambda f: f not in read_ok, config_files)
- raise ConfigFilesNotFoundError(not_read_ok)
-
- def _check_required_opts(self):
- """Check that all opts marked as required have values specified.
-
- :raises: RequiredOptError
- """
- for info, group in self._all_opt_infos():
- opt = info['opt']
-
- if opt.required:
- if 'default' in info or 'override' in info:
- continue
-
- if self._get(opt.dest, group) is None:
- raise RequiredOptError(opt.name, group)
-
- def _parse_cli_opts(self, args):
- """Parse command line options.
-
- Initializes the command line option parser and parses the supplied
- command line arguments.
-
- :param args: the command line arguments
- :returns: a dict of parsed option values
- :raises: SystemExit, DuplicateOptError
-
- """
- self._args = args
-
- for opt, group in sorted(self._all_cli_opts()):
- opt._add_to_cli(self._oparser, group)
-
- return vars(self._oparser.parse_args(args))
-
- class GroupAttr(collections.Mapping):
-
- """
- A helper class representing the option values of a group as a mapping
- and attributes.
- """
-
- def __init__(self, conf, group):
- """Construct a GroupAttr object.
-
- :param conf: a ConfigOpts object
- :param group: an OptGroup object
- """
- self._conf = conf
- self._group = group
-
- def __getattr__(self, name):
- """Look up an option value and perform template substitution."""
- return self._conf._get(name, self._group)
-
- def __getitem__(self, key):
- """Look up an option value and perform string substitution."""
- return self.__getattr__(key)
-
- def __contains__(self, key):
- """Return True if key is the name of a registered opt or group."""
- return key in self._group._opts
-
- def __iter__(self):
- """Iterate over all registered opt and group names."""
- for key in self._group._opts.keys():
- yield key
-
- def __len__(self):
- """Return the number of options and option groups."""
- return len(self._group._opts)
-
- class SubCommandAttr(object):
-
- """
- A helper class representing the name and arguments of an argparse
- sub-parser.
- """
-
- def __init__(self, conf, group, dest):
- """Construct a SubCommandAttr object.
-
- :param conf: a ConfigOpts object
- :param group: an OptGroup object
- :param dest: the name of the sub-parser
- """
- self._conf = conf
- self._group = group
- self._dest = dest
-
- def __getattr__(self, name):
- """Look up a sub-parser name or argument value."""
- if name == 'name':
- name = self._dest
- if self._group is not None:
- name = self._group.name + '_' + name
- return self._conf._cli_values[name]
-
- if name in self._conf:
- raise DuplicateOptError(name)
-
- try:
- return self._conf._cli_values[name]
- except KeyError:
- raise NoSuchOptError(name)
-
- class StrSubWrapper(object):
-
- """
- A helper class exposing opt values as a dict for string substitution.
- """
-
- def __init__(self, conf):
- """Construct a StrSubWrapper object.
-
- :param conf: a ConfigOpts object
- """
- self.conf = conf
-
- def __getitem__(self, key):
- """Look up an opt value from the ConfigOpts object.
-
- :param key: an opt name
- :returns: an opt value
- :raises: TemplateSubstitutionError if attribute is a group
- """
- value = getattr(self.conf, key)
- if isinstance(value, self.conf.GroupAttr):
- raise TemplateSubstitutionError(
- 'substituting group %s not supported' % key)
- return value
-
-
-CONF = ConfigOpts()
+from oslo.config.cfg import *
diff --git a/nova/openstack/common/db/sqlalchemy/session.py b/nova/openstack/common/db/sqlalchemy/session.py
index bc889fc36..93bfa9b15 100644
--- a/nova/openstack/common/db/sqlalchemy/session.py
+++ b/nova/openstack/common/db/sqlalchemy/session.py
@@ -246,13 +246,13 @@ import time
from eventlet import db_pool
from eventlet import greenthread
+from oslo.config import cfg
from sqlalchemy.exc import DisconnectionError, OperationalError, IntegrityError
import sqlalchemy.interfaces
import sqlalchemy.orm
from sqlalchemy.pool import NullPool, StaticPool
from sqlalchemy.sql.expression import literal_column
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common.gettextutils import _
diff --git a/nova/openstack/common/eventlet_backdoor.py b/nova/openstack/common/eventlet_backdoor.py
index 118385427..61ceded43 100644
--- a/nova/openstack/common/eventlet_backdoor.py
+++ b/nova/openstack/common/eventlet_backdoor.py
@@ -24,8 +24,7 @@ import traceback
import eventlet
import eventlet.backdoor
import greenlet
-
-from nova.openstack.common import cfg
+from oslo.config import cfg
eventlet_backdoor_opts = [
cfg.IntOpt('backdoor_port',
diff --git a/nova/openstack/common/iniparser.py b/nova/openstack/common/iniparser.py
deleted file mode 100644
index 9bf399f0c..000000000
--- a/nova/openstack/common/iniparser.py
+++ /dev/null
@@ -1,130 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-class ParseError(Exception):
- def __init__(self, message, lineno, line):
- self.msg = message
- self.line = line
- self.lineno = lineno
-
- def __str__(self):
- return 'at line %d, %s: %r' % (self.lineno, self.msg, self.line)
-
-
-class BaseParser(object):
- lineno = 0
- parse_exc = ParseError
-
- def _assignment(self, key, value):
- self.assignment(key, value)
- return None, []
-
- def _get_section(self, line):
- if line[-1] != ']':
- return self.error_no_section_end_bracket(line)
- if len(line) <= 2:
- return self.error_no_section_name(line)
-
- return line[1:-1]
-
- def _split_key_value(self, line):
- colon = line.find(':')
- equal = line.find('=')
- if colon < 0 and equal < 0:
- return self.error_invalid_assignment(line)
-
- if colon < 0 or (equal >= 0 and equal < colon):
- key, value = line[:equal], line[equal + 1:]
- else:
- key, value = line[:colon], line[colon + 1:]
-
- value = value.strip()
- if ((value and value[0] == value[-1]) and
- (value[0] == "\"" or value[0] == "'")):
- value = value[1:-1]
- return key.strip(), [value]
-
- def parse(self, lineiter):
- key = None
- value = []
-
- for line in lineiter:
- self.lineno += 1
-
- line = line.rstrip()
- if not line:
- # Blank line, ends multi-line values
- if key:
- key, value = self._assignment(key, value)
- continue
- elif line[0] in (' ', '\t'):
- # Continuation of previous assignment
- if key is None:
- self.error_unexpected_continuation(line)
- else:
- value.append(line.lstrip())
- continue
-
- if key:
- # Flush previous assignment, if any
- key, value = self._assignment(key, value)
-
- if line[0] == '[':
- # Section start
- section = self._get_section(line)
- if section:
- self.new_section(section)
- elif line[0] in '#;':
- self.comment(line[1:].lstrip())
- else:
- key, value = self._split_key_value(line)
- if not key:
- return self.error_empty_key(line)
-
- if key:
- # Flush previous assignment, if any
- self._assignment(key, value)
-
- def assignment(self, key, value):
- """Called when a full assignment is parsed"""
- raise NotImplementedError()
-
- def new_section(self, section):
- """Called when a new section is started"""
- raise NotImplementedError()
-
- def comment(self, comment):
- """Called when a comment is parsed"""
- pass
-
- def error_invalid_assignment(self, line):
- raise self.parse_exc("No ':' or '=' found in assignment",
- self.lineno, line)
-
- def error_empty_key(self, line):
- raise self.parse_exc('Key cannot be empty', self.lineno, line)
-
- def error_unexpected_continuation(self, line):
- raise self.parse_exc('Unexpected continuation line',
- self.lineno, line)
-
- def error_no_section_end_bracket(self, line):
- raise self.parse_exc('Invalid section (must end with ])',
- self.lineno, line)
-
- def error_no_section_name(self, line):
- raise self.parse_exc('Empty section name', self.lineno, line)
diff --git a/nova/openstack/common/lockutils.py b/nova/openstack/common/lockutils.py
index 930e265f6..6ee376929 100644
--- a/nova/openstack/common/lockutils.py
+++ b/nova/openstack/common/lockutils.py
@@ -25,14 +25,13 @@ import time
import weakref
from eventlet import semaphore
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common.gettextutils import _
from nova.openstack.common import local
from nova.openstack.common import log as logging
-
LOG = logging.getLogger(__name__)
diff --git a/nova/openstack/common/log.py b/nova/openstack/common/log.py
index 32513bb32..796045657 100644
--- a/nova/openstack/common/log.py
+++ b/nova/openstack/common/log.py
@@ -40,7 +40,8 @@ import stat
import sys
import traceback
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.gettextutils import _
from nova.openstack.common import jsonutils
from nova.openstack.common import local
diff --git a/nova/openstack/common/notifier/api.py b/nova/openstack/common/notifier/api.py
index 0ec55fbf0..70941e243 100644
--- a/nova/openstack/common/notifier/api.py
+++ b/nova/openstack/common/notifier/api.py
@@ -15,7 +15,8 @@
import uuid
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import context
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
diff --git a/nova/openstack/common/notifier/log_notifier.py b/nova/openstack/common/notifier/log_notifier.py
index a334f92e7..4fe4d74ea 100644
--- a/nova/openstack/common/notifier/log_notifier.py
+++ b/nova/openstack/common/notifier/log_notifier.py
@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
-
CONF = cfg.CONF
diff --git a/nova/openstack/common/notifier/rpc_notifier.py b/nova/openstack/common/notifier/rpc_notifier.py
index 8316f7ab7..b348480c9 100644
--- a/nova/openstack/common/notifier/rpc_notifier.py
+++ b/nova/openstack/common/notifier/rpc_notifier.py
@@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import context as req_context
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
diff --git a/nova/openstack/common/notifier/rpc_notifier2.py b/nova/openstack/common/notifier/rpc_notifier2.py
index beb2e9f71..f1158a2f9 100644
--- a/nova/openstack/common/notifier/rpc_notifier2.py
+++ b/nova/openstack/common/notifier/rpc_notifier2.py
@@ -15,7 +15,8 @@
'''messaging based notification driver, with message envelopes'''
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import context as req_context
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
diff --git a/nova/openstack/common/plugin/pluginmanager.py b/nova/openstack/common/plugin/pluginmanager.py
index 157ecbf44..040b721a4 100644
--- a/nova/openstack/common/plugin/pluginmanager.py
+++ b/nova/openstack/common/plugin/pluginmanager.py
@@ -15,7 +15,8 @@
import pkg_resources
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier_api
diff --git a/nova/openstack/common/rpc/__init__.py b/nova/openstack/common/rpc/__init__.py
index b98fef006..736b25b24 100644
--- a/nova/openstack/common/rpc/__init__.py
+++ b/nova/openstack/common/rpc/__init__.py
@@ -28,12 +28,12 @@ For some wrappers that add message versioning to rpc, see:
import inspect
import logging
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import local
-
LOG = logging.getLogger(__name__)
diff --git a/nova/openstack/common/rpc/common.py b/nova/openstack/common/rpc/common.py
index d2f5a7b8f..287986da8 100644
--- a/nova/openstack/common/rpc/common.py
+++ b/nova/openstack/common/rpc/common.py
@@ -21,7 +21,8 @@ import copy
import sys
import traceback
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/openstack/common/rpc/impl_kombu.py b/nova/openstack/common/rpc/impl_kombu.py
index 4b5550d6f..298c82d52 100644
--- a/nova/openstack/common/rpc/impl_kombu.py
+++ b/nova/openstack/common/rpc/impl_kombu.py
@@ -28,8 +28,8 @@ import kombu
import kombu.connection
import kombu.entity
import kombu.messaging
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common.gettextutils import _
from nova.openstack.common import network_utils
from nova.openstack.common.rpc import amqp as rpc_amqp
diff --git a/nova/openstack/common/rpc/impl_qpid.py b/nova/openstack/common/rpc/impl_qpid.py
index 544d33790..3daf4ba91 100644
--- a/nova/openstack/common/rpc/impl_qpid.py
+++ b/nova/openstack/common/rpc/impl_qpid.py
@@ -22,8 +22,8 @@ import uuid
import eventlet
import greenlet
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/openstack/common/rpc/impl_zmq.py b/nova/openstack/common/rpc/impl_zmq.py
index d562b932f..20a7f923d 100644
--- a/nova/openstack/common/rpc/impl_zmq.py
+++ b/nova/openstack/common/rpc/impl_zmq.py
@@ -23,8 +23,8 @@ import uuid
import eventlet
import greenlet
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common.gettextutils import _
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/openstack/common/rpc/matchmaker.py b/nova/openstack/common/rpc/matchmaker.py
index 9eec1df83..57cc0b34c 100644
--- a/nova/openstack/common/rpc/matchmaker.py
+++ b/nova/openstack/common/rpc/matchmaker.py
@@ -22,7 +22,8 @@ import contextlib
import itertools
import json
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
diff --git a/nova/paths.py b/nova/paths.py
index 7405a7409..8d84289ae 100644
--- a/nova/paths.py
+++ b/nova/paths.py
@@ -19,7 +19,7 @@
import os
-from nova.openstack.common import cfg
+from oslo.config import cfg
path_opts = [
cfg.StrOpt('pybasedir',
diff --git a/nova/policy.py b/nova/policy.py
index ac2f2e730..6e500d926 100644
--- a/nova/policy.py
+++ b/nova/policy.py
@@ -19,8 +19,9 @@
import os.path
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import policy
from nova import utils
diff --git a/nova/quota.py b/nova/quota.py
index 1856c97c1..3361154dd 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -20,14 +20,14 @@
import datetime
+from oslo.config import cfg
+
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 log as logging
from nova.openstack.common import timeutils
-
LOG = logging.getLogger(__name__)
quota_opts = [
diff --git a/nova/scheduler/chance.py b/nova/scheduler/chance.py
index 806758e42..c639aaf80 100644
--- a/nova/scheduler/chance.py
+++ b/nova/scheduler/chance.py
@@ -23,8 +23,9 @@ Chance (Random) Scheduler implementation
import random
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.scheduler import driver
CONF = cfg.CONF
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py
index a8531a587..96a3e5e98 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -23,6 +23,8 @@ Scheduler base class that all Schedulers should inherit from
import sys
+from oslo.config import cfg
+
from nova.compute import power_state
from nova.compute import rpcapi as compute_rpcapi
from nova.compute import utils as compute_utils
@@ -32,7 +34,6 @@ from nova import db
from nova import exception
from nova.image import glance
from nova import notifications
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier
diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py
index 905b582cd..b886a04cc 100644
--- a/nova/scheduler/filter_scheduler.py
+++ b/nova/scheduler/filter_scheduler.py
@@ -21,8 +21,9 @@ Weighing Functions.
import random
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier
from nova.scheduler import driver
diff --git a/nova/scheduler/filters/availability_zone_filter.py b/nova/scheduler/filters/availability_zone_filter.py
index 390276ea3..f6c7472bf 100644
--- a/nova/scheduler/filters/availability_zone_filter.py
+++ b/nova/scheduler/filters/availability_zone_filter.py
@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
from nova import db
-from nova.openstack.common import cfg
from nova.scheduler import filters
-
CONF = cfg.CONF
CONF.import_opt('default_availability_zone', 'nova.availability_zones')
diff --git a/nova/scheduler/filters/compute_filter.py b/nova/scheduler/filters/compute_filter.py
index 2cdfb91f4..f571955d9 100644
--- a/nova/scheduler/filters/compute_filter.py
+++ b/nova/scheduler/filters/compute_filter.py
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
from nova import servicegroup
diff --git a/nova/scheduler/filters/core_filter.py b/nova/scheduler/filters/core_filter.py
index 54561b811..a07a1b39a 100644
--- a/nova/scheduler/filters/core_filter.py
+++ b/nova/scheduler/filters/core_filter.py
@@ -15,11 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
-
LOG = logging.getLogger(__name__)
cpu_allocation_ratio_opt = cfg.FloatOpt('cpu_allocation_ratio',
diff --git a/nova/scheduler/filters/disk_filter.py b/nova/scheduler/filters/disk_filter.py
index e7a292c45..812b9b212 100644
--- a/nova/scheduler/filters/disk_filter.py
+++ b/nova/scheduler/filters/disk_filter.py
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
diff --git a/nova/scheduler/filters/io_ops_filter.py b/nova/scheduler/filters/io_ops_filter.py
index 2780ff252..a60be57e2 100644
--- a/nova/scheduler/filters/io_ops_filter.py
+++ b/nova/scheduler/filters/io_ops_filter.py
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
diff --git a/nova/scheduler/filters/isolated_hosts_filter.py b/nova/scheduler/filters/isolated_hosts_filter.py
index 37a8f440d..89beb0ed0 100644
--- a/nova/scheduler/filters/isolated_hosts_filter.py
+++ b/nova/scheduler/filters/isolated_hosts_filter.py
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.scheduler import filters
isolated_opts = [
diff --git a/nova/scheduler/filters/num_instances_filter.py b/nova/scheduler/filters/num_instances_filter.py
index bdc350f95..f65fccbf6 100644
--- a/nova/scheduler/filters/num_instances_filter.py
+++ b/nova/scheduler/filters/num_instances_filter.py
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
diff --git a/nova/scheduler/filters/ram_filter.py b/nova/scheduler/filters/ram_filter.py
index f9d6bb750..3345bf386 100644
--- a/nova/scheduler/filters/ram_filter.py
+++ b/nova/scheduler/filters/ram_filter.py
@@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.scheduler import filters
diff --git a/nova/scheduler/filters/trusted_filter.py b/nova/scheduler/filters/trusted_filter.py
index 14f1a37b0..a7bb850bf 100644
--- a/nova/scheduler/filters/trusted_filter.py
+++ b/nova/scheduler/filters/trusted_filter.py
@@ -48,15 +48,15 @@ import httplib
import socket
import ssl
+from oslo.config import cfg
+
from nova import context
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova.scheduler import filters
-
LOG = logging.getLogger(__name__)
trusted_opts = [
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py
index 7203fb735..c004b2947 100644
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -19,11 +19,12 @@ Manage hosts in the current zone.
import UserDict
+from oslo.config import cfg
+
from nova.compute import task_states
from nova.compute import vm_states
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova.scheduler import filters
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 6b47f37f8..a9b774a4d 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -23,6 +23,8 @@ Scheduler Service
import sys
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova.compute import task_states
from nova.compute import utils as compute_utils
@@ -33,7 +35,6 @@ from nova import db
from nova import exception
from nova import manager
from nova import notifications
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/scheduler/multi.py b/nova/scheduler/multi.py
index a92e09556..ec45ad618 100644
--- a/nova/scheduler/multi.py
+++ b/nova/scheduler/multi.py
@@ -27,7 +27,8 @@ schedule requests to compute nodes but provide their own manager and topic.
https://bugs.launchpad.net/nova/+bug/1009681
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import importutils
from nova.scheduler import driver
diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py
index 5ce8abd7f..47b1de79b 100644
--- a/nova/scheduler/rpcapi.py
+++ b/nova/scheduler/rpcapi.py
@@ -18,7 +18,8 @@
Client side of the scheduler manager RPC API.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
import nova.openstack.common.rpc.proxy
diff --git a/nova/scheduler/scheduler_options.py b/nova/scheduler/scheduler_options.py
index e0840dd01..1753c897b 100644
--- a/nova/scheduler/scheduler_options.py
+++ b/nova/scheduler/scheduler_options.py
@@ -26,7 +26,8 @@ import datetime
import json
import os
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/scheduler/weights/__init__.py b/nova/scheduler/weights/__init__.py
index b979b1e55..f96ec929a 100644
--- a/nova/scheduler/weights/__init__.py
+++ b/nova/scheduler/weights/__init__.py
@@ -17,8 +17,8 @@
Scheduler host weights
"""
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.scheduler.weights import least_cost
from nova import weights
diff --git a/nova/scheduler/weights/least_cost.py b/nova/scheduler/weights/least_cost.py
index 26b9e7a8c..0e617ff42 100644
--- a/nova/scheduler/weights/least_cost.py
+++ b/nova/scheduler/weights/least_cost.py
@@ -25,8 +25,9 @@ NOTE(comstud): This is deprecated. One should use the RAMWeigher and/or
create other weight modules.
"""
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/scheduler/weights/ram.py b/nova/scheduler/weights/ram.py
index ea4cfab38..3fc15fbdf 100644
--- a/nova/scheduler/weights/ram.py
+++ b/nova/scheduler/weights/ram.py
@@ -20,9 +20,9 @@ stacking, you can set the 'ram_weight_multiplier' option to a negative
number and the weighing has the opposite effect of the default.
"""
-from nova.openstack.common import cfg
-from nova.scheduler import weights
+from oslo.config import cfg
+from nova.scheduler import weights
ram_weight_opts = [
cfg.FloatOpt('ram_weight_multiplier',
diff --git a/nova/service.py b/nova/service.py
index 3d556a202..0aa66310a 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -29,11 +29,11 @@ import time
import eventlet
import greenlet
+from oslo.config import cfg
from nova import conductor
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import eventlet_backdoor
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/servicegroup/api.py b/nova/servicegroup/api.py
index 057a44103..2701329a0 100644
--- a/nova/servicegroup/api.py
+++ b/nova/servicegroup/api.py
@@ -17,14 +17,14 @@
"""Define APIs for the servicegroup access."""
-from nova.openstack.common import cfg
+import random
+
+from oslo.config import cfg
+
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
-import random
-
-
LOG = logging.getLogger(__name__)
_default_driver = 'db'
servicegroup_driver_opt = cfg.StrOpt('servicegroup_driver',
diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py
index 18b4b74e5..994015b34 100644
--- a/nova/servicegroup/drivers/db.py
+++ b/nova/servicegroup/drivers/db.py
@@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from oslo.config import cfg
+
from nova import conductor
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova.servicegroup import api
diff --git a/nova/servicegroup/drivers/mc.py b/nova/servicegroup/drivers/mc.py
index c5048a04c..2857185d9 100644
--- a/nova/servicegroup/drivers/mc.py
+++ b/nova/servicegroup/drivers/mc.py
@@ -18,10 +18,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from oslo.config import cfg
+
from nova.common import memorycache
from nova import conductor
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova.servicegroup import api
diff --git a/nova/servicegroup/drivers/zk.py b/nova/servicegroup/drivers/zk.py
index 6a98d6dc3..92b49f274 100644
--- a/nova/servicegroup/drivers/zk.py
+++ b/nova/servicegroup/drivers/zk.py
@@ -21,10 +21,10 @@ import os
import eventlet
import evzookeeper
from evzookeeper import membership
+from oslo.config import cfg
import zookeeper
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.servicegroup import api
from nova import utils
diff --git a/nova/spice/__init__.py b/nova/spice/__init__.py
index 390957e27..aa283d5cc 100644
--- a/nova/spice/__init__.py
+++ b/nova/spice/__init__.py
@@ -17,7 +17,7 @@
"""Module for SPICE Proxying."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
spice_opts = [
diff --git a/nova/test.py b/nova/test.py
index e5c11081c..e917e6c2a 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -31,6 +31,7 @@ import uuid
import eventlet
import fixtures
import mox
+from oslo.config import cfg
import stubout
import testtools
@@ -38,7 +39,6 @@ from nova import context
from nova import db
from nova.db import migration
from nova.network import manager as network_manager
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/tests/api/ec2/test_cinder_cloud.py b/nova/tests/api/ec2/test_cinder_cloud.py
index 5e5723a08..d4ce58023 100644
--- a/nova/tests/api/ec2/test_cinder_cloud.py
+++ b/nova/tests/api/ec2/test_cinder_cloud.py
@@ -21,6 +21,7 @@ import copy
import uuid
import fixtures
+from oslo.config import cfg
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
@@ -29,7 +30,6 @@ from nova.compute import utils as compute_utils
from nova import context
from nova import db
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 import test
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py
index 0eb2b89ae..07780eb02 100644
--- a/nova/tests/api/ec2/test_cloud.py
+++ b/nova/tests/api/ec2/test_cloud.py
@@ -26,6 +26,7 @@ import string
import tempfile
import fixtures
+from oslo.config import cfg
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
@@ -40,7 +41,6 @@ from nova import db
from nova import exception
from nova.image import s3
from nova.network import api as network_api
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/api/ec2/test_ec2_validate.py b/nova/tests/api/ec2/test_ec2_validate.py
index 4dcdf4e54..24d226335 100644
--- a/nova/tests/api/ec2/test_ec2_validate.py
+++ b/nova/tests/api/ec2/test_ec2_validate.py
@@ -18,13 +18,14 @@
import datetime
+from oslo.config import cfg
+
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
from nova.compute import utils as compute_utils
from nova import context
from nova import db
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 import timeutils
diff --git a/nova/tests/api/ec2/test_middleware.py b/nova/tests/api/ec2/test_middleware.py
index f50689028..05463b849 100644
--- a/nova/tests/api/ec2/test_middleware.py
+++ b/nova/tests/api/ec2/test_middleware.py
@@ -17,6 +17,7 @@
# under the License.
from lxml import etree
+from oslo.config import cfg
import webob
import webob.dec
import webob.exc
@@ -24,7 +25,6 @@ import webob.exc
from nova.api import ec2
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import timeutils
from nova import test
diff --git a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
index 76351e489..600d25889 100644
--- a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
+++ b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
@@ -15,6 +15,7 @@
import datetime
import uuid
+from oslo.config import cfg
import webob
from nova.api.openstack import compute
@@ -23,7 +24,6 @@ from nova.compute import api as compute_api
from nova.compute import vm_states
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova import test
diff --git a/nova/tests/api/openstack/compute/contrib/test_cloudpipe.py b/nova/tests/api/openstack/compute/contrib/test_cloudpipe.py
index 133554abd..40b4e6d93 100644
--- a/nova/tests/api/openstack/compute/contrib/test_cloudpipe.py
+++ b/nova/tests/api/openstack/compute/contrib/test_cloudpipe.py
@@ -14,12 +14,12 @@
# under the License.
from lxml import etree
+from oslo.config import cfg
from nova.api.openstack.compute.contrib import cloudpipe
from nova.api.openstack import wsgi
from nova.compute import utils as compute_utils
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import timeutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_evacuate.py b/nova/tests/api/openstack/compute/contrib/test_evacuate.py
index f76bf7bcf..9411b5663 100644
--- a/nova/tests/api/openstack/compute/contrib/test_evacuate.py
+++ b/nova/tests/api/openstack/compute/contrib/test_evacuate.py
@@ -14,12 +14,12 @@
import uuid
+from oslo.config import cfg
import webob
from nova.compute import api as compute_api
from nova.compute import vm_states
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ip_bulk.py b/nova/tests/api/openstack/compute/contrib/test_floating_ip_bulk.py
index 408b17d48..a36bb32cf 100644
--- a/nova/tests/api/openstack/compute/contrib/test_floating_ip_bulk.py
+++ b/nova/tests/api/openstack/compute/contrib/test_floating_ip_bulk.py
@@ -14,11 +14,11 @@
# under the License.
import netaddr
+from oslo.config import cfg
import webob
from nova.api.openstack.compute.contrib import floating_ips_bulk
from nova import context
-from nova.openstack.common import cfg
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_networks.py b/nova/tests/api/openstack/compute/contrib/test_networks.py
index 44d9e8af3..fef60f20b 100644
--- a/nova/tests/api/openstack/compute/contrib/test_networks.py
+++ b/nova/tests/api/openstack/compute/contrib/test_networks.py
@@ -19,12 +19,12 @@ import math
import netaddr
import uuid
+from oslo.config import cfg
import webob
from nova.api.openstack.compute.contrib import networks_associate
from nova.api.openstack.compute.contrib import os_networks as networks
from nova import exception
-from nova.openstack.common import cfg
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_rescue.py b/nova/tests/api/openstack/compute/contrib/test_rescue.py
index 2719c1339..359eafb2a 100644
--- a/nova/tests/api/openstack/compute/contrib/test_rescue.py
+++ b/nova/tests/api/openstack/compute/contrib/test_rescue.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
import webob
from nova import compute
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_security_group_default_rules.py b/nova/tests/api/openstack/compute/contrib/test_security_group_default_rules.py
index 88dee2edf..2b4145764 100644
--- a/nova/tests/api/openstack/compute/contrib/test_security_group_default_rules.py
+++ b/nova/tests/api/openstack/compute/contrib/test_security_group_default_rules.py
@@ -15,13 +15,13 @@
# under the License.
from lxml import etree
+from oslo.config import cfg
import webob
from nova.api.openstack.compute.contrib import security_group_default_rules
from nova.api.openstack import wsgi
from nova import context
import nova.db
-from nova.openstack.common import cfg
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_security_groups.py b/nova/tests/api/openstack/compute/contrib/test_security_groups.py
index 2823c3e8f..1b254c2a7 100644
--- a/nova/tests/api/openstack/compute/contrib/test_security_groups.py
+++ b/nova/tests/api/openstack/compute/contrib/test_security_groups.py
@@ -17,6 +17,7 @@
from lxml import etree
import mox
+from oslo.config import cfg
import webob
from nova.api.openstack.compute.contrib import security_groups
@@ -25,7 +26,6 @@ from nova.api.openstack import xmlutil
from nova import compute
import nova.db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import quota
from nova import test
diff --git a/nova/tests/api/openstack/compute/contrib/test_server_password.py b/nova/tests/api/openstack/compute/contrib/test_server_password.py
index 87da90efe..6e7d66a06 100644
--- a/nova/tests/api/openstack/compute/contrib/test_server_password.py
+++ b/nova/tests/api/openstack/compute/contrib/test_server_password.py
@@ -14,11 +14,11 @@
# under the License.
from lxml import etree
+from oslo.config import cfg
import webob
from nova.api.metadata import password
from nova import compute
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/contrib/test_volumes.py b/nova/tests/api/openstack/compute/contrib/test_volumes.py
index 175513e72..90e226eac 100644
--- a/nova/tests/api/openstack/compute/contrib/test_volumes.py
+++ b/nova/tests/api/openstack/compute/contrib/test_volumes.py
@@ -16,19 +16,19 @@
import datetime
from lxml import etree
+from oslo.config import cfg
import webob
+from webob import exc
from nova.api.openstack.compute.contrib import volumes
from nova.compute import api as compute_api
from nova.compute import instance_types
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import timeutils
from nova import test
from nova.tests.api.openstack import fakes
from nova.volume import cinder
-from webob import exc
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
diff --git a/nova/tests/api/openstack/compute/test_extensions.py b/nova/tests/api/openstack/compute/test_extensions.py
index 63a6b3c9a..bd3fde1f3 100644
--- a/nova/tests/api/openstack/compute/test_extensions.py
+++ b/nova/tests/api/openstack/compute/test_extensions.py
@@ -18,6 +18,7 @@
import iso8601
from lxml import etree
+from oslo.config import cfg
import webob
from nova.api.openstack import compute
@@ -25,7 +26,6 @@ from nova.api.openstack.compute import extensions as compute_extensions
from nova.api.openstack import extensions as base_extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/test_image_metadata.py b/nova/tests/api/openstack/compute/test_image_metadata.py
index 9a8b75c9e..29165b548 100644
--- a/nova/tests/api/openstack/compute/test_image_metadata.py
+++ b/nova/tests/api/openstack/compute/test_image_metadata.py
@@ -15,10 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
import webob
from nova.api.openstack.compute import image_metadata
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py
index d4c93ef39..101458bf3 100644
--- a/nova/tests/api/openstack/compute/test_server_actions.py
+++ b/nova/tests/api/openstack/compute/test_server_actions.py
@@ -17,6 +17,7 @@ import base64
import uuid
import mox
+from oslo.config import cfg
import webob
from nova.api.openstack.compute import servers
@@ -26,14 +27,12 @@ from nova.compute import vm_states
from nova import db
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova import test
from nova.tests.api.openstack import fakes
from nova.tests.image import fake
from nova.tests import matchers
-
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
FAKE_UUID = fakes.FAKE_UUID
diff --git a/nova/tests/api/openstack/compute/test_server_metadata.py b/nova/tests/api/openstack/compute/test_server_metadata.py
index 71fa9f3f3..3ba895953 100644
--- a/nova/tests/api/openstack/compute/test_server_metadata.py
+++ b/nova/tests/api/openstack/compute/test_server_metadata.py
@@ -17,6 +17,7 @@
import uuid
+from oslo.config import cfg
import webob
from nova.api.openstack.compute import server_metadata
@@ -24,7 +25,6 @@ from nova.compute import rpcapi as compute_rpcapi
from nova.compute import vm_states
import nova.db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py
index 597422ab8..228d81f45 100644
--- a/nova/tests/api/openstack/compute/test_servers.py
+++ b/nova/tests/api/openstack/compute/test_servers.py
@@ -23,6 +23,7 @@ import uuid
import iso8601
from lxml import etree
+from oslo.config import cfg
import webob
from nova.api.openstack import compute
@@ -41,7 +42,6 @@ from nova.db.sqlalchemy import models
from nova import exception
from nova.network import manager
from nova.network.quantumv2 import api as quantum_api
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import policy as common_policy
from nova.openstack.common import rpc
@@ -52,7 +52,6 @@ from nova.tests import fake_network
from nova.tests.image import fake
from nova.tests import matchers
-
CONF = cfg.CONF
CONF.import_opt('password_length', 'nova.utils')
CONF.import_opt('scheduler_topic', 'nova.scheduler.rpcapi')
diff --git a/nova/tests/api/test_sizelimit.py b/nova/tests/api/test_sizelimit.py
index 9c5ab1a27..862a0d65f 100644
--- a/nova/tests/api/test_sizelimit.py
+++ b/nova/tests/api/test_sizelimit.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
import webob
import nova.api.sizelimit
-from nova.openstack.common import cfg
from nova import test
CONF = cfg.CONF
diff --git a/nova/tests/baremetal/db/base.py b/nova/tests/baremetal/db/base.py
index 37e51fe79..499eee32a 100644
--- a/nova/tests/baremetal/db/base.py
+++ b/nova/tests/baremetal/db/base.py
@@ -15,8 +15,9 @@
"""Bare-metal DB test base class."""
+from oslo.config import cfg
+
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
diff --git a/nova/tests/baremetal/test_driver.py b/nova/tests/baremetal/test_driver.py
index 37ef71881..a4bcc8128 100644
--- a/nova/tests/baremetal/test_driver.py
+++ b/nova/tests/baremetal/test_driver.py
@@ -20,8 +20,9 @@
"""Tests for the base baremetal driver class."""
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova import test
from nova.tests.baremetal.db import base as bm_db_base
from nova.tests.baremetal.db import utils as bm_db_utils
diff --git a/nova/tests/baremetal/test_ipmi.py b/nova/tests/baremetal/test_ipmi.py
index 87800cb47..faf800a46 100644
--- a/nova/tests/baremetal/test_ipmi.py
+++ b/nova/tests/baremetal/test_ipmi.py
@@ -23,7 +23,8 @@ import os
import stat
import tempfile
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova import test
from nova.tests.baremetal.db import utils as bm_db_utils
from nova import utils
diff --git a/nova/tests/baremetal/test_pxe.py b/nova/tests/baremetal/test_pxe.py
index 9703feb40..2f3ac5158 100644
--- a/nova/tests/baremetal/test_pxe.py
+++ b/nova/tests/baremetal/test_pxe.py
@@ -21,10 +21,10 @@
import os
+from oslo.config import cfg
from testtools import matchers
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.tests.baremetal.db import base as bm_db_base
from nova.tests.baremetal.db import utils as bm_db_utils
diff --git a/nova/tests/baremetal/test_virtual_power_driver.py b/nova/tests/baremetal/test_virtual_power_driver.py
index 689677698..5a38ed87b 100644
--- a/nova/tests/baremetal/test_virtual_power_driver.py
+++ b/nova/tests/baremetal/test_virtual_power_driver.py
@@ -19,16 +19,14 @@
"""Tests for baremetal virtual power driver."""
import mox
+from oslo.config import cfg
from nova import exception
-from nova.openstack.common import cfg
-from nova import utils as nutils
-
from nova.tests.baremetal.db import base as bm_db_base
from nova.tests.baremetal.db import utils as bm_db_utils
from nova.tests.image import fake as fake_image
from nova.tests import utils
-
+from nova import utils as nutils
from nova.virt.baremetal import db
from nova.virt.baremetal import virtual_power_driver
import nova.virt.powervm.common as connection
diff --git a/nova/tests/baremetal/test_volume_driver.py b/nova/tests/baremetal/test_volume_driver.py
index c83277516..24dadac94 100644
--- a/nova/tests/baremetal/test_volume_driver.py
+++ b/nova/tests/baremetal/test_volume_driver.py
@@ -15,9 +15,9 @@
"""Tests for baremetal volume driver."""
-from nova.openstack.common import cfg
-from nova import test
+from oslo.config import cfg
+from nova import test
from nova.virt.baremetal import volume_driver
CONF = cfg.CONF
diff --git a/nova/tests/cells/fakes.py b/nova/tests/cells/fakes.py
index e996cbe13..c200d3dba 100644
--- a/nova/tests/cells/fakes.py
+++ b/nova/tests/cells/fakes.py
@@ -16,6 +16,8 @@
Fakes For Cells tests.
"""
+from oslo.config import cfg
+
from nova.cells import driver
from nova.cells import manager as cells_manager
from nova.cells import messaging
@@ -23,7 +25,6 @@ from nova.cells import state as cells_state
import nova.db
from nova.db import base
from nova import exception
-from nova.openstack.common import cfg
CONF = cfg.CONF
CONF.import_opt('name', 'nova.cells.opts', group='cells')
diff --git a/nova/tests/cells/test_cells_manager.py b/nova/tests/cells/test_cells_manager.py
index 1ebbc407d..d53fdbb7f 100644
--- a/nova/tests/cells/test_cells_manager.py
+++ b/nova/tests/cells/test_cells_manager.py
@@ -18,10 +18,11 @@ Tests For CellsManager
import copy
import datetime
+from oslo.config import cfg
+
from nova.cells import messaging
from nova.cells import utils as cells_utils
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common import timeutils
from nova import test
diff --git a/nova/tests/cells/test_cells_messaging.py b/nova/tests/cells/test_cells_messaging.py
index 811ad17fd..30adfdcd7 100644
--- a/nova/tests/cells/test_cells_messaging.py
+++ b/nova/tests/cells/test_cells_messaging.py
@@ -14,17 +14,18 @@
"""
Tests For Cells Messaging module
"""
+
+from oslo.config import cfg
+
from nova.cells import messaging
from nova.cells import utils as cells_utils
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common import timeutils
from nova import test
from nova.tests.cells import fakes
-
CONF = cfg.CONF
CONF.import_opt('name', 'nova.cells.opts', group='cells')
CONF.import_opt('allowed_rpc_exception_modules',
diff --git a/nova/tests/cells/test_cells_rpc_driver.py b/nova/tests/cells/test_cells_rpc_driver.py
index a44fe9376..e5e847c12 100644
--- a/nova/tests/cells/test_cells_rpc_driver.py
+++ b/nova/tests/cells/test_cells_rpc_driver.py
@@ -16,10 +16,11 @@
Tests For Cells RPC Communication Driver
"""
+from oslo.config import cfg
+
from nova.cells import messaging
from nova.cells import rpc_driver
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
from nova import test
diff --git a/nova/tests/cells/test_cells_rpcapi.py b/nova/tests/cells/test_cells_rpcapi.py
index d19ce5b2b..f00b1b290 100644
--- a/nova/tests/cells/test_cells_rpcapi.py
+++ b/nova/tests/cells/test_cells_rpcapi.py
@@ -16,8 +16,9 @@
Tests For Cells RPCAPI
"""
+from oslo.config import cfg
+
from nova.cells import rpcapi as cells_rpcapi
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/cells/test_cells_scheduler.py b/nova/tests/cells/test_cells_scheduler.py
index ecd51c9f7..c9e626385 100644
--- a/nova/tests/cells/test_cells_scheduler.py
+++ b/nova/tests/cells/test_cells_scheduler.py
@@ -17,11 +17,12 @@ Tests For CellsScheduler
"""
import time
+from oslo.config import cfg
+
from nova.compute import vm_states
from nova import context
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import uuidutils
from nova import test
from nova.tests.cells import fakes
diff --git a/nova/tests/cert/test_rpcapi.py b/nova/tests/cert/test_rpcapi.py
index dce325354..b743ca1e5 100644
--- a/nova/tests/cert/test_rpcapi.py
+++ b/nova/tests/cert/test_rpcapi.py
@@ -18,9 +18,10 @@
Unit Tests for nova.cert.rpcapi
"""
+from oslo.config import cfg
+
from nova.cert import rpcapi as cert_rpcapi
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index c372eef02..f06bc0587 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -27,6 +27,7 @@ import traceback
import uuid
import mox
+from oslo.config import cfg
import nova
from nova import compute
@@ -45,7 +46,6 @@ from nova import exception
from nova.image import glance
from nova.network import api as network_api
from nova.network import model as network_model
-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
diff --git a/nova/tests/compute/test_compute_utils.py b/nova/tests/compute/test_compute_utils.py
index 9b865014c..0f96e657d 100644
--- a/nova/tests/compute/test_compute_utils.py
+++ b/nova/tests/compute/test_compute_utils.py
@@ -19,6 +19,8 @@
import string
+from oslo.config import cfg
+
from nova.compute import instance_types
from nova.compute import utils as compute_utils
from nova import context
@@ -26,7 +28,6 @@ from nova import db
from nova import exception
from nova.image import glance
from nova.network import api as network_api
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier_api
diff --git a/nova/tests/compute/test_multiple_nodes.py b/nova/tests/compute/test_multiple_nodes.py
index 27ee7aaba..1a967c5e4 100644
--- a/nova/tests/compute/test_multiple_nodes.py
+++ b/nova/tests/compute/test_multiple_nodes.py
@@ -16,9 +16,10 @@
# under the License.
"""Tests for compute service with multiple compute nodes."""
+from oslo.config import cfg
+
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova import test
from nova.virt import fake
diff --git a/nova/tests/compute/test_resource_tracker.py b/nova/tests/compute/test_resource_tracker.py
index f1d0d1f0c..84dbc69fc 100644
--- a/nova/tests/compute/test_resource_tracker.py
+++ b/nova/tests/compute/test_resource_tracker.py
@@ -19,13 +19,14 @@
import uuid
+from oslo.config import cfg
+
from nova.compute import instance_types
from nova.compute import resource_tracker
from nova.compute import task_states
from nova.compute import vm_states
from nova import context
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import test
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index b81e049bf..a78a13883 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -18,10 +18,11 @@
Unit Tests for nova.compute.rpcapi
"""
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova import context
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/conf_fixture.py b/nova/tests/conf_fixture.py
index 230f70a1b..e2ea18f98 100644
--- a/nova/tests/conf_fixture.py
+++ b/nova/tests/conf_fixture.py
@@ -17,10 +17,10 @@
# under the License.
import fixtures
+from oslo.config import cfg
from nova import config
from nova import ipv6
-from nova.openstack.common import cfg
from nova import paths
from nova.tests import utils
diff --git a/nova/tests/console/test_console.py b/nova/tests/console/test_console.py
index 8c2e603aa..0f95f3d95 100644
--- a/nova/tests/console/test_console.py
+++ b/nova/tests/console/test_console.py
@@ -18,12 +18,13 @@
"""Tests For Console proxy."""
+from oslo.config import cfg
+
from nova.console import api as console_api
from nova.console import rpcapi as console_rpcapi
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 rpc
from nova import test
diff --git a/nova/tests/console/test_rpcapi.py b/nova/tests/console/test_rpcapi.py
index 8d9d0514f..298c59c4e 100644
--- a/nova/tests/console/test_rpcapi.py
+++ b/nova/tests/console/test_rpcapi.py
@@ -18,9 +18,10 @@
Unit Tests for nova.console.rpcapi
"""
+from oslo.config import cfg
+
from nova.console import rpcapi as console_rpcapi
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/consoleauth/test_rpcapi.py b/nova/tests/consoleauth/test_rpcapi.py
index 264c4e10b..15af5fdcf 100644
--- a/nova/tests/consoleauth/test_rpcapi.py
+++ b/nova/tests/consoleauth/test_rpcapi.py
@@ -18,9 +18,10 @@
Unit Tests for nova.consoleauth.rpcapi
"""
+from oslo.config import cfg
+
from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/fake_libvirt_utils.py b/nova/tests/fake_libvirt_utils.py
index 38236cd21..31b1af231 100644
--- a/nova/tests/fake_libvirt_utils.py
+++ b/nova/tests/fake_libvirt_utils.py
@@ -17,7 +17,8 @@
import os
import StringIO
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.virt.libvirt import utils as libvirt_utils
diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py
index f384df272..42ce71ded 100644
--- a/nova/tests/fake_network.py
+++ b/nova/tests/fake_network.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova.compute import api as compute_api
from nova.compute import manager as compute_manager
import nova.context
@@ -25,7 +27,6 @@ from nova.network import manager as network_manager
from nova.network import model as network_model
from nova.network import nova_ipam_lib
from nova.network import rpcapi as network_rpcapi
-from nova.openstack.common import cfg
from nova.virt.libvirt import config as libvirt_config
diff --git a/nova/tests/fake_volume.py b/nova/tests/fake_volume.py
index 0d8a502a5..607f1444d 100644
--- a/nova/tests/fake_volume.py
+++ b/nova/tests/fake_volume.py
@@ -16,8 +16,9 @@
import uuid
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/tests/image/fake.py b/nova/tests/image/fake.py
index 78cd667e4..51cf30a3e 100644
--- a/nova/tests/image/fake.py
+++ b/nova/tests/image/fake.py
@@ -22,12 +22,12 @@ import copy
import datetime
import uuid
+from oslo.config import cfg
+
from nova import exception
import nova.image.glance
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
-
CONF = cfg.CONF
CONF.import_opt('null_kernel', 'nova.compute.api')
LOG = logging.getLogger(__name__)
diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py
index fb26fa4f1..a7ed4c409 100644
--- a/nova/tests/image/test_glance.py
+++ b/nova/tests/image/test_glance.py
@@ -24,11 +24,11 @@ import tempfile
import time
import glanceclient.exc
+from oslo.config import cfg
from nova import context
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova import test
from nova.tests.api.openstack import fakes
from nova.tests.glance import stubs as glance_stubs
diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py
index 90e9a806e..0e696a6c4 100644
--- a/nova/tests/integrated/integrated_helpers.py
+++ b/nova/tests/integrated/integrated_helpers.py
@@ -23,8 +23,9 @@ import random
import string
import uuid
+from oslo.config import cfg
+
import nova.image.glance
-from nova.openstack.common import cfg
from nova.openstack.common.log import logging
from nova import service
from nova import test
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index a61ac3b8d..8c2723e67 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -25,6 +25,7 @@ import uuid as uuid_lib
import coverage
from lxml import etree
+from oslo.config import cfg
from nova.api.metadata import password
from nova.api.openstack.compute.contrib import coverage_ext
@@ -36,7 +37,6 @@ from nova import db
from nova.db.sqlalchemy import models
from nova import exception
from nova.network import api as network_api
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
from nova.openstack.common.log import logging
diff --git a/nova/tests/integrated/test_extensions.py b/nova/tests/integrated/test_extensions.py
index ca5ff8374..33499ee5d 100644
--- a/nova/tests/integrated/test_extensions.py
+++ b/nova/tests/integrated/test_extensions.py
@@ -15,8 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
# Import extensions to pull in osapi_compute_extension CONF option used below.
-from nova.openstack.common import cfg
from nova.openstack.common.log import logging
from nova.tests.integrated import integrated_helpers
diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py
index 50c98e78c..cba08d9ce 100644
--- a/nova/tests/network/test_linux_net.py
+++ b/nova/tests/network/test_linux_net.py
@@ -19,12 +19,12 @@ import calendar
import os
import mox
+from oslo.config import cfg
from nova import context
from nova import db
from nova.network import driver
from nova.network import linux_net
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index 4344aa07b..313321ea7 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -18,6 +18,7 @@
import fixtures
import mox
+from oslo.config import cfg
from nova import context
from nova import db
@@ -28,7 +29,6 @@ from nova.network import floating_ips
from nova.network import linux_net
from nova.network import manager as network_manager
from nova.network import model as net_model
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
@@ -40,7 +40,6 @@ from nova.tests import fake_network
from nova.tests import matchers
from nova import utils
-
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py
index 91d609914..a37c63efb 100644
--- a/nova/tests/network/test_quantumv2.py
+++ b/nova/tests/network/test_quantumv2.py
@@ -18,16 +18,15 @@
import uuid
import mox
+from oslo.config import cfg
+from quantumclient.v2_0 import client
from nova import context
from nova import exception
from nova.network import model
from nova.network import quantumv2
from nova.network.quantumv2 import api as quantumapi
-from nova.openstack.common import cfg
from nova import test
-from quantumclient.v2_0 import client
-
CONF = cfg.CONF
diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py
index 33663b8da..a161fe5e0 100644
--- a/nova/tests/network/test_rpcapi.py
+++ b/nova/tests/network/test_rpcapi.py
@@ -18,9 +18,10 @@
Unit Tests for nova.network.rpcapi
"""
+from oslo.config import cfg
+
from nova import context
from nova.network import rpcapi as network_rpcapi
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/policy_fixture.py b/nova/tests/policy_fixture.py
index 282a28b44..91813defd 100644
--- a/nova/tests/policy_fixture.py
+++ b/nova/tests/policy_fixture.py
@@ -15,8 +15,8 @@
import os
import fixtures
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import policy as common_policy
import nova.policy
from nova.tests import fake_policy
diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py
index 53e51668c..009614610 100644
--- a/nova/tests/scheduler/test_host_filters.py
+++ b/nova/tests/scheduler/test_host_filters.py
@@ -16,11 +16,12 @@ Tests For Scheduler Host Filters.
"""
import httplib
+
+from oslo.config import cfg
import stubout
from nova import context
from nova import db
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import timeutils
from nova.scheduler import filters
diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py
index d159d8f4c..d920b7255 100644
--- a/nova/tests/scheduler/test_least_cost.py
+++ b/nova/tests/scheduler/test_least_cost.py
@@ -15,14 +15,15 @@
"""
Tests For Least Cost functions.
"""
+
+from oslo.config import cfg
+
from nova import context
-from nova.openstack.common import cfg
from nova.scheduler import weights
from nova.scheduler.weights import least_cost
from nova import test
from nova.tests.scheduler import fakes
-
test_least_cost_opts = [
cfg.FloatOpt('compute_fake_weigher1_weight',
default=2.0,
diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py
index af6a57ba6..62038c722 100644
--- a/nova/tests/scheduler/test_rpcapi.py
+++ b/nova/tests/scheduler/test_rpcapi.py
@@ -18,8 +18,9 @@
Unit Tests for nova.scheduler.rpcapi
"""
+from oslo.config import cfg
+
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
diff --git a/nova/tests/test_availability_zones.py b/nova/tests/test_availability_zones.py
index 4192fa08f..85dc1eefd 100644
--- a/nova/tests/test_availability_zones.py
+++ b/nova/tests/test_availability_zones.py
@@ -19,10 +19,11 @@
Tests for availability zones
"""
+from oslo.config import cfg
+
from nova import availability_zones as az
from nova import context
from nova import db
-from nova.openstack.common import cfg
from nova import test
CONF = cfg.CONF
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index 27ca1ed8b..cf81cca74 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -22,6 +22,7 @@
import datetime
import uuid as stdlib_uuid
+from oslo.config import cfg
from sqlalchemy import MetaData
from sqlalchemy.schema import Table
from sqlalchemy.sql.expression import select
@@ -29,7 +30,6 @@ from sqlalchemy.sql.expression import select
from nova import context
from nova import db
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import timeutils
from nova import test
diff --git a/nova/tests/test_hypervapi.py b/nova/tests/test_hypervapi.py
index 025d3a454..5912bb301 100644
--- a/nova/tests/test_hypervapi.py
+++ b/nova/tests/test_hypervapi.py
@@ -26,13 +26,14 @@ import shutil
import time
import uuid
+from oslo.config import cfg
+
from nova.api.metadata import base as instance_metadata
from nova.compute import power_state
from nova.compute import task_states
from nova import context
from nova import db
from nova.image import glance
-from nova.openstack.common import cfg
from nova import test
from nova.tests import fake_network
from nova.tests.hyperv import db_fakes
diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py
index bd88fcd60..c3d274da8 100644
--- a/nova/tests/test_imagebackend.py
+++ b/nova/tests/test_imagebackend.py
@@ -15,10 +15,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import fixtures
import os
-from nova.openstack.common import cfg
+import fixtures
+from oslo.config import cfg
+
from nova.openstack.common import uuidutils
from nova import test
from nova.tests import fake_libvirt_utils
diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py
index 389612c64..8c752bbb9 100644
--- a/nova/tests/test_imagecache.py
+++ b/nova/tests/test_imagecache.py
@@ -24,14 +24,14 @@ import logging
import os
import time
-from nova import test
+from oslo.config import cfg
from nova.compute import vm_states
from nova import conductor
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 test
from nova import utils
from nova.virt.libvirt import imagecache
from nova.virt.libvirt import utils as virtutils
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 8ac74aabd..80437ede8 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -27,6 +27,7 @@ import shutil
import tempfile
from lxml import etree
+from oslo.config import cfg
from xml.dom import minidom
from nova.api.ec2 import cloud
@@ -38,7 +39,6 @@ from nova.compute import vm_states
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
@@ -63,7 +63,6 @@ from nova.virt.libvirt import firewall
from nova.virt.libvirt import imagebackend
from nova.virt.libvirt import utils as libvirt_utils
-
try:
import libvirt
except ImportError:
diff --git a/nova/tests/test_libvirt_vif.py b/nova/tests/test_libvirt_vif.py
index 749fda33a..cb7943ea8 100644
--- a/nova/tests/test_libvirt_vif.py
+++ b/nova/tests/test_libvirt_vif.py
@@ -15,10 +15,10 @@
# under the License.
from lxml import etree
+from oslo.config import cfg
from nova import exception
from nova.network import model as network_model
-from nova.openstack.common import cfg
from nova import test
from nova.tests import fakelibvirt
from nova import utils
diff --git a/nova/tests/test_libvirt_volume.py b/nova/tests/test_libvirt_volume.py
index fa71782ee..7945329f8 100644
--- a/nova/tests/test_libvirt_volume.py
+++ b/nova/tests/test_libvirt_volume.py
@@ -17,8 +17,9 @@
import os
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.storage import linuxscsi
from nova import test
from nova.tests import fake_libvirt_utils
diff --git a/nova/tests/test_metadata.py b/nova/tests/test_metadata.py
index 95399e33d..3d01f1336 100644
--- a/nova/tests/test_metadata.py
+++ b/nova/tests/test_metadata.py
@@ -25,6 +25,7 @@ import hmac
import json
import re
+from oslo.config import cfg
import webob
from nova.api.metadata import base
@@ -36,7 +37,6 @@ from nova import db
from nova.db.sqlalchemy import api
from nova import exception
from nova.network import api as network_api
-from nova.openstack.common import cfg
from nova import test
from nova.tests import fake_network
diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py
index aec6c8f67..9b38756c8 100644
--- a/nova/tests/test_notifications.py
+++ b/nova/tests/test_notifications.py
@@ -19,6 +19,8 @@
import copy
+from oslo.config import cfg
+
from nova.compute import instance_types
from nova.compute import task_states
from nova.compute import vm_states
@@ -26,7 +28,6 @@ from nova import context
from nova import db
from nova.network import api as network_api
from nova import notifications
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier_api
from nova.openstack.common.notifier import test_notifier
diff --git a/nova/tests/test_objectstore.py b/nova/tests/test_objectstore.py
index 37d8c5d7d..0775bb66f 100644
--- a/nova/tests/test_objectstore.py
+++ b/nova/tests/test_objectstore.py
@@ -27,9 +27,9 @@ import tempfile
from boto import exception as boto_exception
from boto.s3 import connection as s3
+from oslo.config import cfg
from nova.objectstore import s3server
-from nova.openstack.common import cfg
from nova import test
from nova import wsgi
diff --git a/nova/tests/test_pipelib.py b/nova/tests/test_pipelib.py
index 5cd715552..4b76581a4 100644
--- a/nova/tests/test_pipelib.py
+++ b/nova/tests/test_pipelib.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova.cloudpipe import pipelib
from nova import context
from nova import crypto
-from nova.openstack.common import cfg
from nova import test
from nova import utils
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index 08b33e201..1ea4eea21 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -18,6 +18,8 @@
import datetime
+from oslo.config import cfg
+
from nova import compute
from nova.compute import instance_types
from nova import context
@@ -25,7 +27,6 @@ from nova import db
from nova.db.sqlalchemy import api as sqa_api
from nova.db.sqlalchemy import models as sqa_models
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import rpc
from nova.openstack.common import timeutils
from nova import quota
diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py
index 71beed51e..efe84fbb1 100644
--- a/nova/tests/test_service.py
+++ b/nova/tests/test_service.py
@@ -20,19 +20,19 @@
Unit Tests for remote procedure calls using queue
"""
-import mox
import sys
+import mox
+from oslo.config import cfg
+
from nova import context
from nova import db
from nova import exception
from nova import manager
-from nova.openstack.common import cfg
from nova import service
from nova import test
from nova import wsgi
-
test_service_opts = [
cfg.StrOpt("fake_manager",
default="nova.tests.test_service.FakeManager",
diff --git a/nova/tests/test_test.py b/nova/tests/test_test.py
index 9e2d3560c..759b05e3b 100644
--- a/nova/tests/test_test.py
+++ b/nova/tests/test_test.py
@@ -18,7 +18,8 @@
"""Tests for the testing base code."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import rpc
from nova import test
diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py
index bdff108d9..940ddf6ec 100644
--- a/nova/tests/test_utils.py
+++ b/nova/tests/test_utils.py
@@ -26,10 +26,10 @@ import tempfile
import mox
import netaddr
+from oslo.config import cfg
import nova
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import timeutils
from nova import test
from nova import utils
diff --git a/nova/tests/test_versions.py b/nova/tests/test_versions.py
index 780e5ae12..1536af4c0 100644
--- a/nova/tests/test_versions.py
+++ b/nova/tests/test_versions.py
@@ -17,7 +17,8 @@
import __builtin__
import StringIO
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova import test
from nova import version
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 2a484d832..84c3caa63 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -23,6 +23,8 @@ import functools
import os
import re
+from oslo.config import cfg
+
from nova.compute import api as compute_api
from nova.compute import instance_types
from nova.compute import power_state
@@ -31,7 +33,6 @@ from nova.compute import vm_states
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
diff --git a/nova/tests/utils.py b/nova/tests/utils.py
index 74199eb92..9daa72f34 100644
--- a/nova/tests/utils.py
+++ b/nova/tests/utils.py
@@ -16,15 +16,15 @@
import platform
-import nova.context
-import nova.db
+from oslo.config import cfg
from nova.compute import instance_types
+import nova.context
+import nova.db
from nova import exception
from nova.image import glance
from nova.network import minidns
from nova.network import model as network_model
-from nova.openstack.common import cfg
CONF = cfg.CONF
CONF.import_opt('use_ipv6', 'nova.netconf')
diff --git a/nova/utils.py b/nova/utils.py
index ac658cd5e..2dcedb5d5 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -47,8 +47,9 @@ from eventlet.green import subprocess
from eventlet import greenthread
import netaddr
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/version.py b/nova/version.py
index 722a20e16..d54c112be 100644
--- a/nova/version.py
+++ b/nova/version.py
@@ -31,7 +31,8 @@ def _load_config():
# this module
import ConfigParser
- from nova.openstack.common import cfg
+ from oslo.config import cfg
+
from nova.openstack.common import log as logging
global loaded, NOVA_VENDOR, NOVA_PRODUCT, NOVA_PACKAGE
diff --git a/nova/virt/baremetal/db/api.py b/nova/virt/baremetal/db/api.py
index 002425333..672f14486 100644
--- a/nova/virt/baremetal/db/api.py
+++ b/nova/virt/baremetal/db/api.py
@@ -42,9 +42,9 @@ these objects be simple dictionaries.
"""
-from nova.openstack.common import cfg
-from nova import utils
+from oslo.config import cfg
+from nova import utils
# NOTE(deva): we can't move baremetal_db_backend into an OptGroup yet
# because utils.LazyPluggable doesn't support reading from
diff --git a/nova/virt/baremetal/db/sqlalchemy/session.py b/nova/virt/baremetal/db/sqlalchemy/session.py
index 06d777354..585096c94 100644
--- a/nova/virt/baremetal/db/sqlalchemy/session.py
+++ b/nova/virt/baremetal/db/sqlalchemy/session.py
@@ -19,7 +19,8 @@
"""Session Handling for SQLAlchemy backend."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common.db.sqlalchemy import session as nova_session
from nova import paths
diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py
index 9160485a6..379eaf04d 100755
--- a/nova/virt/baremetal/driver.py
+++ b/nova/virt/baremetal/driver.py
@@ -21,10 +21,11 @@
A driver for Bare-metal platform.
"""
+from oslo.config import cfg
+
from nova.compute import power_state
from nova import context as nova_context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/virt/baremetal/ipmi.py b/nova/virt/baremetal/ipmi.py
index 5d4a87625..7cc272c32 100644
--- a/nova/virt/baremetal/ipmi.py
+++ b/nova/virt/baremetal/ipmi.py
@@ -25,8 +25,9 @@ import os
import stat
import tempfile
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py
index 14bdab2b0..ce4060a5e 100644
--- a/nova/virt/baremetal/pxe.py
+++ b/nova/virt/baremetal/pxe.py
@@ -22,9 +22,10 @@ Class for PXE bare-metal nodes.
import os
+from oslo.config import cfg
+
from nova.compute import instance_types
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common.db.sqlalchemy import session as db_session
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
@@ -32,7 +33,6 @@ from nova.virt.baremetal import base
from nova.virt.baremetal import db
from nova.virt.baremetal import utils as bm_utils
-
pxe_opts = [
cfg.StrOpt('deploy_kernel',
help='Default kernel image ID used in deployment phase'),
diff --git a/nova/virt/baremetal/vif_driver.py b/nova/virt/baremetal/vif_driver.py
index 08e68c250..627155f9c 100644
--- a/nova/virt/baremetal/vif_driver.py
+++ b/nova/virt/baremetal/vif_driver.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.baremetal import db as bmdb
diff --git a/nova/virt/baremetal/virtual_power_driver.py b/nova/virt/baremetal/virtual_power_driver.py
index f77579dba..a18a2f9d3 100644
--- a/nova/virt/baremetal/virtual_power_driver.py
+++ b/nova/virt/baremetal/virtual_power_driver.py
@@ -17,9 +17,9 @@
#
# Virtual power driver
+from oslo.config import cfg
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/baremetal/volume_driver.py b/nova/virt/baremetal/volume_driver.py
index e92325b97..cc23f9064 100644
--- a/nova/virt/baremetal/volume_driver.py
+++ b/nova/virt/baremetal/volume_driver.py
@@ -18,9 +18,10 @@
import re
+from oslo.config import cfg
+
from nova import context as nova_context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/configdrive.py b/nova/virt/configdrive.py
index 886136460..658710e26 100644
--- a/nova/virt/configdrive.py
+++ b/nova/virt/configdrive.py
@@ -21,8 +21,9 @@ import os
import shutil
import tempfile
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index d4f8b6cc0..0880af1cb 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -32,8 +32,9 @@ import tempfile
if os.name != 'nt':
import crypt
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import paths
diff --git a/nova/virt/disk/mount/nbd.py b/nova/virt/disk/mount/nbd.py
index 72302fb91..d6414e96c 100644
--- a/nova/virt/disk/mount/nbd.py
+++ b/nova/virt/disk/mount/nbd.py
@@ -20,7 +20,8 @@ import random
import re
import time
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.disk.mount import api
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index ba0dfbafe..5689ad6fc 100755
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -24,7 +24,8 @@ Driver base-classes:
import sys
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py
index ad38cd9a4..6ab4249b1 100644
--- a/nova/virt/firewall.py
+++ b/nova/virt/firewall.py
@@ -17,16 +17,16 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova import context
from nova import network
from nova.network import linux_net
-from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova.virt import netutils
-
LOG = logging.getLogger(__name__)
firewall_opts = [
diff --git a/nova/virt/hyperv/basevolumeutils.py b/nova/virt/hyperv/basevolumeutils.py
index 5b515a0f1..32221843f 100644
--- a/nova/virt/hyperv/basevolumeutils.py
+++ b/nova/virt/hyperv/basevolumeutils.py
@@ -28,8 +28,9 @@ if sys.platform == 'win32':
import _winreg
import wmi
+from oslo.config import cfg
+
from nova import block_device
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt import driver
diff --git a/nova/virt/hyperv/hostops.py b/nova/virt/hyperv/hostops.py
index b3b38aab9..4e5cfc6a4 100644
--- a/nova/virt/hyperv/hostops.py
+++ b/nova/virt/hyperv/hostops.py
@@ -21,7 +21,8 @@ Management class for host operations.
import os
import platform
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.virt.hyperv import constants
diff --git a/nova/virt/hyperv/livemigrationops.py b/nova/virt/hyperv/livemigrationops.py
index 108413b0b..dca5de0cc 100644
--- a/nova/virt/hyperv/livemigrationops.py
+++ b/nova/virt/hyperv/livemigrationops.py
@@ -18,7 +18,8 @@
"""
Management class for live migration VM operations.
"""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova.virt.hyperv import imagecache
diff --git a/nova/virt/hyperv/pathutils.py b/nova/virt/hyperv/pathutils.py
index 05cfffaac..1297cd1ed 100644
--- a/nova/virt/hyperv/pathutils.py
+++ b/nova/virt/hyperv/pathutils.py
@@ -18,7 +18,8 @@
import os
import shutil
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
diff --git a/nova/virt/hyperv/snapshotops.py b/nova/virt/hyperv/snapshotops.py
index ab7c96943..5bed46665 100644
--- a/nova/virt/hyperv/snapshotops.py
+++ b/nova/virt/hyperv/snapshotops.py
@@ -20,9 +20,10 @@ Management class for VM snapshot operations.
"""
import os
+from oslo.config import cfg
+
from nova.compute import task_states
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.hyperv import pathutils
from nova.virt.hyperv import vhdutils
diff --git a/nova/virt/hyperv/vif.py b/nova/virt/hyperv/vif.py
index cfe7c6a4c..d49441cee 100644
--- a/nova/virt/hyperv/vif.py
+++ b/nova/virt/hyperv/vif.py
@@ -18,12 +18,12 @@
import abc
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.virt.hyperv import networkutils
from nova.virt.hyperv import vmutils
-
hyperv_opts = [
cfg.StrOpt('vswitch_name',
default=None,
diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py
index c8acc0fa1..c7a4e5468 100644
--- a/nova/virt/hyperv/vmops.py
+++ b/nova/virt/hyperv/vmops.py
@@ -21,9 +21,10 @@ Management class for basic VM operations.
"""
import os
+from oslo.config import cfg
+
from nova.api.metadata import base as instance_metadata
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
diff --git a/nova/virt/hyperv/vmutils.py b/nova/virt/hyperv/vmutils.py
index d80144b65..6536efe1e 100644
--- a/nova/virt/hyperv/vmutils.py
+++ b/nova/virt/hyperv/vmutils.py
@@ -27,8 +27,9 @@ import uuid
if sys.platform == 'win32':
import wmi
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.hyperv import constants
diff --git a/nova/virt/hyperv/volumeops.py b/nova/virt/hyperv/volumeops.py
index c665cbeb7..0d12b93a2 100644
--- a/nova/virt/hyperv/volumeops.py
+++ b/nova/virt/hyperv/volumeops.py
@@ -21,7 +21,8 @@ Management class for Storage-related functions (attach, detach, etc).
"""
import time
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.virt import driver
from nova.virt.hyperv import hostutils
diff --git a/nova/virt/hyperv/volumeutils.py b/nova/virt/hyperv/volumeutils.py
index 713ace258..6d623fca7 100644
--- a/nova/virt/hyperv/volumeutils.py
+++ b/nova/virt/hyperv/volumeutils.py
@@ -24,8 +24,8 @@ and storage repositories
import time
from eventlet.green import subprocess
+from oslo.config import cfg
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.hyperv import basevolumeutils
from nova.virt.hyperv import vmutils
diff --git a/nova/virt/hyperv/volumeutilsv2.py b/nova/virt/hyperv/volumeutilsv2.py
index 8322d31d3..2dc86c2e0 100644
--- a/nova/virt/hyperv/volumeutilsv2.py
+++ b/nova/virt/hyperv/volumeutilsv2.py
@@ -26,7 +26,8 @@ import time
if sys.platform == 'win32':
import wmi
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.virt.hyperv import basevolumeutils
diff --git a/nova/virt/images.py b/nova/virt/images.py
index b5ca8fa47..50d89bfb8 100755
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -24,13 +24,13 @@ Handling of VM disk images.
import os
import re
+from oslo.config import cfg
+
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
-
LOG = logging.getLogger(__name__)
image_opts = [
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 9ac5e047b..2a6d6179c 100755
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -54,6 +54,7 @@ import uuid
from eventlet import greenthread
from eventlet import tpool
from lxml import etree
+from oslo.config import cfg
from xml.dom import minidom
from nova.api.metadata import base as instance_metadata
@@ -64,7 +65,6 @@ from nova.compute import vm_mode
from nova import context as nova_context
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import fileutils
from nova.openstack.common import importutils
diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py
index c9a1b1fbb..054ec4c75 100644
--- a/nova/virt/libvirt/firewall.py
+++ b/nova/virt/libvirt/firewall.py
@@ -17,11 +17,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-
from eventlet import tpool
+from oslo.config import cfg
from nova.cloudpipe import pipelib
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
import nova.virt.firewall as base_firewall
diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
index ba75ccf8b..cc5bfcf3d 100755
--- a/nova/virt/libvirt/imagebackend.py
+++ b/nova/virt/libvirt/imagebackend.py
@@ -19,7 +19,8 @@ import abc
import contextlib
import os
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import excutils
from nova.openstack.common import fileutils
from nova.openstack.common import lockutils
diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py
index adc7691c6..d66d61415 100644
--- a/nova/virt/libvirt/imagecache.py
+++ b/nova/virt/libvirt/imagecache.py
@@ -28,9 +28,10 @@ import os
import re
import time
+from oslo.config import cfg
+
from nova.compute import task_states
from nova.compute import vm_states
-from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import jsonutils
from nova.openstack.common import lockutils
@@ -38,7 +39,6 @@ from nova.openstack.common import log as logging
from nova import utils
from nova.virt.libvirt import utils as virtutils
-
LOG = logging.getLogger(__name__)
imagecache_opts = [
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index a20ab25e0..20af11ddc 100755
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -23,9 +23,9 @@
import os
from lxml import etree
+from oslo.config import cfg
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
from nova.virt import images
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 000c77db9..4be8be33f 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -21,13 +21,13 @@
import copy
+from oslo.config import cfg
+
from nova import exception
from nova.network import linux_net
from nova.network import model as network_model
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import utils
-
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import designer
diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py
index 035087caf..8fefeb41f 100644
--- a/nova/virt/libvirt/volume.py
+++ b/nova/virt/libvirt/volume.py
@@ -22,8 +22,9 @@ import hashlib
import os
import time
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova import paths
diff --git a/nova/virt/netutils.py b/nova/virt/netutils.py
index 70f1544c4..eec2d6467 100644
--- a/nova/virt/netutils.py
+++ b/nova/virt/netutils.py
@@ -23,7 +23,7 @@
import netaddr
-from nova.openstack.common import cfg
+from oslo.config import cfg
CONF = cfg.CONF
CONF.import_opt('use_ipv6', 'nova.netconf')
diff --git a/nova/virt/powervm/blockdev.py b/nova/virt/powervm/blockdev.py
index dc539814e..da28d6c46 100644
--- a/nova/virt/powervm/blockdev.py
+++ b/nova/virt/powervm/blockdev.py
@@ -18,8 +18,9 @@ import hashlib
import os
import re
+from oslo.config import cfg
+
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py
index 9cd6453ab..892ac34ef 100755
--- a/nova/virt/powervm/driver.py
+++ b/nova/virt/powervm/driver.py
@@ -17,13 +17,13 @@
import socket
import time
+from oslo.config import cfg
+
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt import driver
from nova.virt.powervm import operator
-
LOG = logging.getLogger(__name__)
powervm_opts = [
diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py
index 43fa27160..b44e78364 100644
--- a/nova/virt/powervm/operator.py
+++ b/nova/virt/powervm/operator.py
@@ -19,14 +19,13 @@ import random
import re
import time
-from nova import exception as nova_exception
-from nova import utils
+from oslo.config import cfg
from nova.compute import power_state
-from nova.openstack.common import cfg
+from nova import exception as nova_exception
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
-
+from nova import utils
from nova.virt.powervm import blockdev
from nova.virt.powervm import command
from nova.virt.powervm import common
@@ -34,7 +33,6 @@ from nova.virt.powervm import constants
from nova.virt.powervm import exception
from nova.virt.powervm import lpar as LPAR
-
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py
index 63d9e3c57..5e48f4cd3 100755
--- a/nova/virt/vmwareapi/driver.py
+++ b/nova/virt/vmwareapi/driver.py
@@ -40,9 +40,9 @@ A connection to the VMware ESX platform.
import time
from eventlet import event
+from oslo.config import cfg
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/vmwareapi/vif.py b/nova/virt/vmwareapi/vif.py
index e2dfa0427..1a28ca35e 100644
--- a/nova/virt/vmwareapi/vif.py
+++ b/nova/virt/vmwareapi/vif.py
@@ -17,8 +17,9 @@
"""VIF drivers for VMware."""
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.vmwareapi import network_util
diff --git a/nova/virt/vmwareapi/vim.py b/nova/virt/vmwareapi/vim.py
index 83d120df5..f3a47315b 100644
--- a/nova/virt/vmwareapi/vim.py
+++ b/nova/virt/vmwareapi/vim.py
@@ -27,7 +27,8 @@ try:
except ImportError:
suds = None
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.virt.vmwareapi import error_util
RESP_NOT_XML_ERROR = 'Response is "text/html", not "text/xml"'
diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py
index 0aeb58ea3..b70d1583e 100644
--- a/nova/virt/vmwareapi/vmops.py
+++ b/nova/virt/vmwareapi/vmops.py
@@ -27,13 +27,14 @@ import urllib
import urllib2
import uuid
+from oslo.config import cfg
+
from nova import block_device
from nova.compute import api as compute
from nova.compute import power_state
from nova.compute import task_states
from nova import context as nova_context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova.virt import driver
diff --git a/nova/virt/vmwareapi/volumeops.py b/nova/virt/vmwareapi/volumeops.py
index 855106e4a..dd8f60f2a 100644
--- a/nova/virt/vmwareapi/volumeops.py
+++ b/nova/virt/vmwareapi/volumeops.py
@@ -18,14 +18,14 @@
Management class for Storage-related functions (attach, detach, etc).
"""
+from oslo.config import cfg
+
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt.vmwareapi import vim_util
from nova.virt.vmwareapi import vm_util
from nova.virt.vmwareapi import volume_util
-
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
diff --git a/nova/virt/xenapi/agent.py b/nova/virt/xenapi/agent.py
index 8220fb67b..0be26a241 100644
--- a/nova/virt/xenapi/agent.py
+++ b/nova/virt/xenapi/agent.py
@@ -21,10 +21,11 @@ import os
import time
import uuid
+from oslo.config import cfg
+
from nova.api.metadata import password
from nova import context
from nova import crypto
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py
index 6a1cdd6b9..347d36255 100755
--- a/nova/virt/xenapi/driver.py
+++ b/nova/virt/xenapi/driver.py
@@ -44,10 +44,10 @@ import xmlrpclib
from eventlet import queue
from eventlet import timeout
+from oslo.config import cfg
from nova import context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.virt import driver
from nova.virt.xenapi import host
diff --git a/nova/virt/xenapi/imageupload/glance.py b/nova/virt/xenapi/imageupload/glance.py
index adc06f65b..5ea75db16 100644
--- a/nova/virt/xenapi/imageupload/glance.py
+++ b/nova/virt/xenapi/imageupload/glance.py
@@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from nova.image import glance
-from nova.openstack.common import cfg
import nova.openstack.common.log as logging
from nova.virt.xenapi import vm_utils
diff --git a/nova/virt/xenapi/pool.py b/nova/virt/xenapi/pool.py
index 1682f18d1..ee39fb2da 100644
--- a/nova/virt/xenapi/pool.py
+++ b/nova/virt/xenapi/pool.py
@@ -21,9 +21,10 @@ Management class for Pool-related functions (join, eject, etc).
import urlparse
+from oslo.config import cfg
+
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.virt.xenapi import pool_states
diff --git a/nova/virt/xenapi/vif.py b/nova/virt/xenapi/vif.py
index 35cdb201d..f0b9eebbe 100644
--- a/nova/virt/xenapi/vif.py
+++ b/nova/virt/xenapi/vif.py
@@ -19,7 +19,8 @@
"""VIF drivers for XenAPI."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
+
from nova.openstack.common import log as logging
from nova.virt.xenapi import network_utils
from nova.virt.xenapi import vm_utils
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 3bfe6de09..28e83198f 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -33,6 +33,7 @@ from xml.dom import minidom
from xml.parsers import expat
from eventlet import greenthread
+from oslo.config import cfg
from nova.api.metadata import base as instance_metadata
from nova import block_device
@@ -40,7 +41,6 @@ from nova.compute import power_state
from nova.compute import task_states
from nova import exception
from nova.image import glance
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
from nova import utils
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 5dbadc416..bf3f631b3 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -25,6 +25,7 @@ import time
from eventlet import greenthread
import netaddr
+from oslo.config import cfg
from nova import block_device
from nova.compute import api as compute
@@ -34,7 +35,6 @@ from nova.compute import vm_mode
from nova.compute import vm_states
from nova import context as nova_context
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py
index 40451a48e..edf92cee9 100644
--- a/nova/virt/xenapi/volume_utils.py
+++ b/nova/virt/xenapi/volume_utils.py
@@ -23,9 +23,9 @@ and storage repositories
import re
import string
-from nova.openstack.common import cfg
-from nova.openstack.common import log as logging
+from oslo.config import cfg
+from nova.openstack.common import log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
diff --git a/nova/vnc/__init__.py b/nova/vnc/__init__.py
index ffbd509fd..6a4c2eb4a 100644
--- a/nova/vnc/__init__.py
+++ b/nova/vnc/__init__.py
@@ -18,7 +18,7 @@
"""Module for VNC Proxying."""
-from nova.openstack.common import cfg
+from oslo.config import cfg
vnc_opts = [
diff --git a/nova/vnc/xvp_proxy.py b/nova/vnc/xvp_proxy.py
index 9489b949a..3efa23f8b 100644
--- a/nova/vnc/xvp_proxy.py
+++ b/nova/vnc/xvp_proxy.py
@@ -25,10 +25,10 @@ import eventlet
import eventlet.green
import eventlet.greenio
import eventlet.wsgi
+from oslo.config import cfg
from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import version
from nova import wsgi
diff --git a/nova/volume/__init__.py b/nova/volume/__init__.py
index da54a5009..1a1917307 100644
--- a/nova/volume/__init__.py
+++ b/nova/volume/__init__.py
@@ -16,23 +16,24 @@
# License for the specific language governing permissions and limitations
# under the License.
+import oslo.config.cfg
+
# Importing full names to not pollute the namespace and cause possible
# collisions with use of 'from nova.volume import <foo>' elsewhere.
-import nova.openstack.common.cfg
import nova.openstack.common.importutils
_volume_opts = [
- nova.openstack.common.cfg.StrOpt('volume_api_class',
+ oslo.config.cfg.StrOpt('volume_api_class',
default='nova.volume.cinder.API',
help='The full class name of the '
'volume API class to use'),
]
-nova.openstack.common.cfg.CONF.register_opts(_volume_opts)
+oslo.config.cfg.CONF.register_opts(_volume_opts)
def API():
importutils = nova.openstack.common.importutils
- volume_api_class = nova.openstack.common.cfg.CONF.volume_api_class
+ volume_api_class = oslo.config.cfg.CONF.volume_api_class
cls = importutils.import_class(volume_api_class)
return cls()
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index b58e63011..e465daf1c 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -26,10 +26,10 @@ import sys
from cinderclient import exceptions as cinder_exception
from cinderclient import service_catalog
from cinderclient.v1 import client as cinder_client
+from oslo.config import cfg
from nova.db import base
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
cinder_opts = [
diff --git a/nova/wsgi.py b/nova/wsgi.py
index 651dbc4f6..7b85d0a5b 100644
--- a/nova/wsgi.py
+++ b/nova/wsgi.py
@@ -26,6 +26,7 @@ import sys
import eventlet
import eventlet.wsgi
import greenlet
+from oslo.config import cfg
from paste import deploy
import routes.middleware
import ssl
@@ -33,7 +34,6 @@ import webob.dec
import webob.exc
from nova import exception
-from nova.openstack.common import cfg
from nova.openstack.common import log as logging
wsgi_opts = [