diff --git a/bin/nova-all b/bin/nova-all index 2553f64878e0..5fb1748e89e7 100755 --- a/bin/nova-all +++ b/bin/nova-all @@ -33,6 +33,7 @@ eventlet.monkey_patch(os=False) import os import sys +from oslo.config import cfg possible_topdir = os.path.normpath(os.path.join(os.path.abspath( sys.argv[0]), os.pardir, os.pardir)) @@ -42,7 +43,6 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): from nova import config from nova.objectstore import s3server -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-api b/bin/nova-api index d957f3e58caa..d21d955cf86c 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -29,6 +29,7 @@ eventlet.monkey_patch(os=False) import os import sys +from oslo.config import cfg possible_topdir = os.path.normpath(os.path.join(os.path.abspath( sys.argv[0]), os.pardir, os.pardir)) @@ -37,7 +38,6 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-baremetal-manage b/bin/nova-baremetal-manage index 35fb83f721fc..42200e5e173f 100755 --- a/bin/nova-baremetal-manage +++ b/bin/nova-baremetal-manage @@ -58,6 +58,7 @@ import gettext import os import sys +from oslo.config import cfg # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... @@ -70,7 +71,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): gettext.install('nova', unicode=1) from nova import config -from nova.openstack.common import cfg from nova.openstack.common import cliutils from nova.openstack.common import log as logging from nova import version diff --git a/bin/nova-cells b/bin/nova-cells index a7e16ef53283..bb955e9ec7d1 100755 --- a/bin/nova-cells +++ b/bin/nova-cells @@ -24,6 +24,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -33,7 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-cert b/bin/nova-cert index 113b06510e44..d309cc0280b8 100755 --- a/bin/nova-cert +++ b/bin/nova-cert @@ -23,6 +23,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -33,7 +35,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-clear-rabbit-queues b/bin/nova-clear-rabbit-queues index e3175876907f..3e8b8e56d609 100755 --- a/bin/nova-clear-rabbit-queues +++ b/bin/nova-clear-rabbit-queues @@ -27,6 +27,8 @@ import gettext import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -39,7 +41,6 @@ gettext.install('nova', unicode=1) from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.openstack.common import rpc diff --git a/bin/nova-compute b/bin/nova-compute index d99a210519c3..26d81d8cc4a6 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -33,6 +33,8 @@ import os import sys import traceback +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -45,7 +47,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config import nova.db.api from nova import exception -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-conductor b/bin/nova-conductor index 5d9e355ddb00..30d426f4279c 100755 --- a/bin/nova-conductor +++ b/bin/nova-conductor @@ -23,6 +23,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -33,7 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-console b/bin/nova-console index 011855a1987b..c567f28b16ee 100755 --- a/bin/nova-console +++ b/bin/nova-console @@ -24,6 +24,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -34,7 +36,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service diff --git a/bin/nova-consoleauth b/bin/nova-consoleauth index 9a6016326d66..776ee9b35f82 100755 --- a/bin/nova-consoleauth +++ b/bin/nova-consoleauth @@ -24,6 +24,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) @@ -33,7 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config from nova.consoleauth import manager -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 33df97b55ece..c00578821f3a 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -25,6 +25,8 @@ import gettext import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -39,7 +41,6 @@ from nova import config from nova import context from nova import db from nova.network import rpcapi as network_rpcapi -from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.openstack.common import rpc diff --git a/bin/nova-manage b/bin/nova-manage index 22549a50d0c2..e3b0ec6f74f3 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -59,6 +59,8 @@ import netaddr import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -77,7 +79,6 @@ from nova import context from nova import db from nova.db import migration from nova import exception -from nova.openstack.common import cfg from nova.openstack.common import cliutils from nova.openstack.common.db.sqlalchemy import session as db_session from nova.openstack.common import importutils diff --git a/bin/nova-network b/bin/nova-network index 03472371ca41..d0ee61ed9a3f 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -25,6 +25,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -35,7 +37,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-novncproxy b/bin/nova-novncproxy index 617e2411d1bf..45f272ada711 100755 --- a/bin/nova-novncproxy +++ b/bin/nova-novncproxy @@ -24,9 +24,10 @@ noVNC consoles. Leverages websockify.py by Joel Martin import os import sys +from oslo.config import cfg + from nova import config from nova.console import websocketproxy -from nova.openstack.common import cfg opts = [ diff --git a/bin/nova-rpc-zmq-receiver b/bin/nova-rpc-zmq-receiver index f89b0b3ba643..13cd05df6b0a 100755 --- a/bin/nova-rpc-zmq-receiver +++ b/bin/nova-rpc-zmq-receiver @@ -22,6 +22,7 @@ import contextlib import os import sys +from oslo.config import cfg import zmq # If ../nova/__init__.py exists, add ../ to Python search path, so that @@ -34,7 +35,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): from nova import config from nova import exception -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.openstack.common import rpc from nova.openstack.common.rpc import impl_zmq diff --git a/bin/nova-scheduler b/bin/nova-scheduler index 507ff3d5a821..ec024d853447 100755 --- a/bin/nova-scheduler +++ b/bin/nova-scheduler @@ -26,6 +26,8 @@ import gettext import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -37,7 +39,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): gettext.install('nova', unicode=1) from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import service from nova import utils diff --git a/bin/nova-spicehtml5proxy b/bin/nova-spicehtml5proxy index 40509294283a..23d250ca3b50 100755 --- a/bin/nova-spicehtml5proxy +++ b/bin/nova-spicehtml5proxy @@ -24,9 +24,10 @@ SPICE HTML5 consoles. Leverages websockify.py by Joel Martin import os import sys +from oslo.config import cfg + from nova import config from nova.console import websocketproxy -from nova.openstack.common import cfg opts = [ diff --git a/nova/api/auth.py b/nova/api/auth.py index 83388d638262..04bb3406619c 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 85b87e3e541d..397190faeb4e 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 b66b15852f79..03bf9f890f12 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 9299a946cc58..f13f26a772a0 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 fca580b29f12..41f36541c1b7 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 cedb273700df..7cccbc324e0f 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 24276b2bd049..979aa74b6281 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 1f479b82e8c1..8b880720b92e 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 92c84c13f62a..6b05dcf5ff39 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 7b21a0be88dd..8e1e8aa85693 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 98c508bd7798..c795568393f4 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 29a9ffcc4cbc..8e31777e24a6 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 4e224be4630d..20ae87fe1709 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 11ab0ec69515..afd42e12ffd0 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 282be19caad3..394d5924ecdf 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 bb8ee553ac46..4d8bcd94e3c8 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 512b58869068..d6ffe367739d 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 03178ab650ef..9848d2320a9e 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 29135418e282..c62ed5894e48 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 2786ad8141f8..0f91bf13f100 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 1d073841775d..4e49482f50cd 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 3b8eb506d587..cc33537aff11 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 77ab4415c2e8..67d459583178 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 8c9d4acf78af..61486517d67c 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 c07a23ebb9f5..55b3dadf7a57 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 5c7247085e35..50a673464f07 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 45b453ebc03a..b66dd6b422c3 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 5e420aa8ebce..0dcf1184cf40 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 e7db2582f434..910c4ab9d11c 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 211bbb48f293..3b69b2eaca21 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 e3886bedb178..53c536888f20 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 fdaa327cb040..7dd84381318a 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 cb7fb8bac7a7..c395a754c996 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 86057b6ae957..f89e4b265d31 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 d1f8cc16c485..f1451aab3eea 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 ' 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 b83e9fa7033e..f29189362ad9 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 4cc5d5d4e51f..73105b33fed6 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 a482d9c05c0d..04aaf9e22571 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 825422e86118..efb95dd7bff9 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 525d1adc741b..b2eac8065c4d 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 35139838dc05..8c1f1d577b94 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 4c702d03702d..b192ca7a7926 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 9026eb8a2cc4..6bc2d3f25c85 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 b82f2b8e1efb..f7b7a78149ef 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 18147bdbb93f..ff6681b44cb2 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 57c5cb0e3e8d..a2bc40ae0af8 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 2045f824deb7..77be2ad4d869 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 5a91a81cb484..78c0c9c1ab60 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 fcd733cf9dce..d7c66a00d4ef 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 bb181894365b..f1ea41796825 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 ce2eb5350848..c090e84d4423 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 c533043f3724..3100ee15c579 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 2dfc72435cf1..74321a27b129 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 64b915ec39b9..813143f76350 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 96e54589374a..4d72aa62449e 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 6b0360f0089e..e38cf18667c2 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 2028e375ee06..1d8433661083 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 9d595408d017..2ac08f6ebdef 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 f0dcd33079c3..95456bf98b4b 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 09b01b342d10..5969d9e5790e 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 78cfc3deed93..79614d6a7b54 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 833fb44f9d47..100d80030857 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 43a18510177e..7f94abcfb67e 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 a0269d30b775..cc7d464cacc1 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 531a9e200c98..f8116ed97e61 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 f0eeb4e84cb2..89c63fcabb94 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 ' 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 2a9218898aa0..47d043e09f57 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 2890573c1735..c35dc85f9a74 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 680b2f435879..df24680b0082 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 317f2a30950c..29b882a02d9b 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 410f7a2cbda2..d7f80dbdaff1 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 dc9dc6f17bb9..b4b5257ea683 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 1b7381e8ee06..5d3cf5770561 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 f3388f2ab21a..19a8070b0109 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 ed8b775fdae9..d0d6b5f99c8b 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 f40fff7f2f95..79d43126aeae 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 6a6d6bf32f39..3ff5fa0032c7 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 baecc0c3b8dd..c35dcb845e22 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 bc889fc36f61..93bfa9b1547f 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 118385427c65..61ceded438e0 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 9bf399f0c7c9..000000000000 --- 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 930e265f6df8..6ee3769293ba 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 32513bb32ac6..796045657552 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 0ec55fbf07cc..70941e243b63 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 a334f92e7b5a..4fe4d74eab03 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 8316f7ab78ab..b348480c9800 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 beb2e9f71ed3..f1158a2f99eb 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 157ecbf445c2..040b721a4f2c 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 b98fef006864..736b25b24585 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 d2f5a7b8f1c4..287986da887a 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 4b5550d6f9a3..298c82d5258a 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 544d337909be..3daf4ba91f5f 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 d562b932ff68..20a7f923dcb8 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 9eec1df83c04..57cc0b34c8ad 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 7405a7409695..8d84289ae00f 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 ac2f2e7302c8..6e500d92697a 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 1856c97c1f1c..3361154ddaee 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 806758e420e9..c639aaf8034b 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 a8531a587d4c..96a3e5e98021 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 905b582cd12a..b886a04ccd60 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 390276ea36de..f6c7472bf7df 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 2cdfb91f4003..f571955d9987 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 54561b8119af..a07a1b39a39e 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 e7a292c45ff0..812b9b212955 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 2780ff25258f..a60be57e2841 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 37a8f440d4dd..89beb0ed0a6b 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 bdc350f95a30..f65fccbf6e71 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 f9d6bb750b13..3345bf386578 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 14f1a37b0ec6..a7bb850bfeeb 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 7203fb735ede..c004b294786e 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 6b47f37f82dd..a9b774a4d7d7 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 a92e0955638a..ec45ad618030 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 5ce8abd7faab..47b1de79bed6 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 e0840dd0147e..1753c897ba1d 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 b979b1e556e9..f96ec929a9db 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 26b9e7a8c7f3..0e617ff42603 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 ea4cfab38e64..3fc15fbdf191 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 3d556a202ef5..0aa66310ab41 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 057a44103ab9..2701329a0dba 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 18b4b74e57de..994015b34a9e 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 c5048a04cfe0..2857185d9325 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 6a98d6dc3b8a..92b49f274869 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 390957e27db7..aa283d5ccff6 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 e5c11081c2a9..e917e6c2aa6d 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 5e5723a08713..d4ce580234e1 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 0eb2b89ae093..07780eb02999 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 4dcdf4e549c0..24d226335592 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 f506890282ce..05463b849af6 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 76351e4899c1..600d258890e2 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 133554abd69e..40b4e6d93e2a 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 f76bf7bcfd1f..9411b5663a85 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 408b17d48094..a36bb32cf4c7 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 44d9e8af3168..fef60f20b14e 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 2719c1339f04..359eafb2ad8c 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 88dee2edfb4c..2b4145764524 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 2823c3e8ff2a..1b254c2a7ac3 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 87da90efe385..6e7d66a0603a 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 175513e7265c..90e226eacb4f 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 63a6b3c9a2ab..bd3fde1f3b1c 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 9a8b75c9e57d..29165b548679 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 d4c93ef39217..101458bf3fef 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 71fa9f3f31de..3ba895953bbe 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 597422ab819b..228d81f45d84 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 9c5ab1a278df..862a0d65f1af 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 37e51fe791dc..499eee32ade3 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 37ef718812f6..a4bcc81286ed 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 87800cb47779..faf800a4667d 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 9703feb4079b..2f3ac515819f 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 689677698d3a..5a38ed87bde7 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 c83277516b3d..24dadac94837 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 e996cbe135e8..c200d3dbaf39 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 1ebbc407d5aa..d53fdbb7f92a 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 811ad17fdfd6..30adfdcd780c 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 a44fe9376589..e5e847c12290 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 d19ce5b2bf3a..f00b1b290f22 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 ecd51c9f738d..c9e626385a19 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 dce325354d53..b743ca1e5f1c 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 c372eef027f2..f06bc05872f6 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 9b865014c7dd..0f96e657de2f 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 27ee7aaba5ce..1a967c5e44c5 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 f1d0d1f0c9db..84dbc69fccb2 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 b81e049bfc1a..a78a13883606 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 230f70a1b7d2..e2ea18f98ede 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 8c2e603aa650..0f95f3d95c61 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 8d9d0514fa77..298c59c4e29a 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 264c4e10bc02..15af5fdcf807 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 38236cd216bc..31b1af23128d 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 f384df27231a..42ce71dedb0f 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 0d8a502a5d0c..607f1444d23d 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 78cd667e4437..51cf30a3e551 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 fb26fa4f1f3b..a7ed4c409a83 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 90e9a806e0bb..0e696a6c4337 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 a61ac3b8d626..8c2723e67423 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 ca5ff83744a5..33499ee5ddb8 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 50c98e78c31f..cba08d9ce992 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 4344aa07b8e5..313321ea799b 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 91d609914733..a37c63efb338 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 33663b8da8dd..a161fe5e0311 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 282a28b44039..91813defdad9 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 53e51668c6a8..009614610c8b 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 d159d8f4c5f4..d920b7255e0f 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 af6a57ba6b0f..62038c722280 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 4192fa08fbbc..85dc1eefd79f 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 27ca1ed8b6fb..cf81cca74a69 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 025d3a454655..5912bb30125b 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 bd88fcd608b1..c3d274da817b 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 389612c64807..8c752bbb9553 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 8ac74aabdafb..80437ede8173 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 749fda33ae68..cb7943ea87ca 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 fa71782ee663..7945329f8052 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 95399e33df7c..3d01f1336444 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 aec6c8f67cef..9b38756c8fab 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 37d8c5d7db9b..0775bb66fd87 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 5cd715552708..4b76581a426b 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 08b33e2017e8..1ea4eea21b9a 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 71beed51ef22..efe84fbb128b 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 9e2d3560c177..759b05e3b6d5 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 bdff108d994b..940ddf6ec489 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 780e5ae12f0c..1536af4c0b3d 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 2a484d8322b8..84c3caa63de2 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 74199eb92f90..9daa72f34678 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 ac658cd5ea35..2dcedb5d55b3 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 722a20e1607c..d54c112be8ca 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 00242533353b..672f14486326 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 06d7773543b0..585096c942f8 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 9160485a6bc5..379eaf04d1fb 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 5d4a87625dbf..7cc272c32bfc 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 14bdab2b0b0a..ce4060a5e5e0 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 08e68c250c11..627155f9ce45 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 f77579dba40d..a18a2f9d34bc 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 e92325b971fc..cc23f90646b6 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 886136460d43..658710e260ac 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 d4f8b6cc06bc..0880af1cb69c 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 72302fb91307..d6414e96c4bc 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 ba0dfbafec2f..5689ad6fc625 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 ad38cd9a4004..6ab4249b1437 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 5b515a0f1247..32221843f40f 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 b3b38aab91c8..4e5cfc6a4810 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 108413b0b829..dca5de0cc06b 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 05cfffaac9f8..1297cd1edb17 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 ab7c96943b38..5bed46665c7e 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 cfe7c6a4c9ef..d49441ceea5f 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 c8acc0fa1dbb..c7a4e54689de 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 d80144b65fe2..6536efe1e148 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 c665cbeb7b02..0d12b93a294f 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 713ace258c78..6d623fca74b3 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 8322d31d3eae..2dc86c2e007c 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 b5ca8fa47bb1..50d89bfb8122 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 9ac5e047b061..2a6d6179c4cd 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 c9a1b1fbbd0f..054ec4c753b4 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 ba75ccf8b730..cc5bfcf3d786 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 adc7691c651a..d66d61415458 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 a20ab25e0946..20af11ddc3e4 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 000c77db974f..4be8be33fd5f 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 035087caff7f..8fefeb41f39c 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 70f1544c48d8..eec2d6467cfb 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 dc539814e205..da28d6c463de 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 9cd6453abf6d..892ac34ef2dc 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 43fa271605df..b44e78364e6f 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 63d9e3c57a68..5e48f4cd3707 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 e2dfa042730f..1a28ca35ea9d 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 83d120df5f3a..f3a47315b88b 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 0aeb58ea3d0a..b70d1583e175 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 855106e4a0fc..dd8f60f2ae68 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 8220fb67bc3c..0be26a241d73 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 6a1cdd6b9d8c..347d362557c0 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 adc06f65b353..5ea75db1674a 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 1682f18d11d4..ee39fb2da5ce 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 35cdb201df0f..f0b9eebbe1c9 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 3bfe6de09e34..28e83198f059 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 5dbadc416d05..bf3f631b3be4 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 40451a48edd4..edf92cee912a 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 ffbd509fd1c9..6a4c2eb4a36a 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 9489b949a3f2..3efa23f8b5f2 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 da54a500993b..1a1917307337 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 ' 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 b58e63011690..e465daf1c380 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 651dbc4f64ab..7b85d0a5bc15 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 = [ diff --git a/openstack-common.conf b/openstack-common.conf index fcff378b50cd..abbc7570eb04 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -1,7 +1,7 @@ [DEFAULT] # The list of modules to copy from openstack-common -modules=cfg,cliutils,context,db,db.sqlalchemy,excutils,eventlet_backdoor,fileutils,gettextutils,importutils,iniparser,jsonutils,local,lockutils,log,network_utils,notifier,plugin,policy,rootwrap,setup,timeutils,rpc,uuidutils,install_venv_common,flakes,version +modules=cliutils,context,db,db.sqlalchemy,excutils,eventlet_backdoor,fileutils,gettextutils,importutils,jsonutils,local,lockutils,log,network_utils,notifier,plugin,policy,rootwrap,setup,timeutils,rpc,uuidutils,install_venv_common,flakes,version # The base module to hold the copy of openstack.common base=nova diff --git a/setup.py b/setup.py index 54d62e409d6e..fd968eeb2601 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ import setuptools from nova.openstack.common import setup as common_setup requires = common_setup.parse_requirements() +depend_links = common_setup.parse_dependency_links() project = 'nova' setuptools.setup( @@ -42,6 +43,7 @@ setuptools.setup( cmdclass=common_setup.get_cmdclass(), packages=setuptools.find_packages(exclude=['bin', 'smoketests']), install_requires=requires, + dependency_links=depend_links, include_package_data=True, test_suite='nose.collector', setup_requires=['setuptools_git>=0.4'], diff --git a/tools/conf/analyze_opts.py b/tools/conf/analyze_opts.py index f78169a8ca7c..3088d6390eb9 100755 --- a/tools/conf/analyze_opts.py +++ b/tools/conf/analyze_opts.py @@ -26,7 +26,7 @@ import os import sys sys.path.append(os.getcwd()) -from nova.openstack.common import iniparser +from oslo.config import iniparser class PropertyCollecter(iniparser.BaseParser): diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py index 4dde53335d95..83d99dd19dcf 100644 --- a/tools/conf/extract_opts.py +++ b/tools/conf/extract_opts.py @@ -26,7 +26,8 @@ import socket import sys import textwrap -from nova.openstack.common import cfg +from oslo.config import cfg + from nova.openstack.common import importutils diff --git a/tools/hacking.py b/tools/hacking.py index 69a4d73993c8..051c2a33c7c6 100755 --- a/tools/hacking.py +++ b/tools/hacking.py @@ -48,7 +48,9 @@ logging.disable('LOG') IMPORT_EXCEPTIONS = ['sqlalchemy', 'migrate', 'nova.db.sqlalchemy.session', 'nova.openstack.common.log.logging', - 'nova.db.sqlalchemy.migration.versioning_api', 'paste'] + 'nova.db.sqlalchemy.migration.versioning_api'] +# imp.find_module() doesn't support namespace packages +IMPORT_EXCEPTIONS += ['oslo', 'paste'] # Paste is missing a __init__ in top level directory START_DOCSTRING_TRIPLE = ['u"""', 'r"""', '"""', "u'''", "r'''", "'''"] END_DOCSTRING_TRIPLE = ['"""', "'''"] diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index 3d47b12b247c..92230dac76ee 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -32,7 +32,7 @@ if os.path.exists(os.path.join(possible_topdir, "nova", sys.path.insert(0, possible_topdir) -from nova.openstack.common import cfg +from oslo.config import cfg class InstallVenv(object): diff --git a/tools/pip-requires b/tools/pip-requires index d7e48ff87bb3..bb4eb7119e60 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -27,3 +27,4 @@ python-glanceclient>=0.5.0,<2 python-keystoneclient>=0.2.0 stevedore>=0.7 websockify +http://tarballs.openstack.org/oslo-config/oslo-config-2013.1b4.tar.gz#egg=oslo-config diff --git a/tools/test-requires b/tools/test-requires index 49ee52809feb..1318ecd9a4a7 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -9,6 +9,7 @@ mox==0.5.3 MySQL-python psycopg2 pep8==1.3.3 +pyflakes pylint==0.25.2 python-subunit sphinx>=1.1.2 diff --git a/tools/xenserver/destroy_cached_images.py b/tools/xenserver/destroy_cached_images.py index fa71c0a680fa..625c765c662d 100644 --- a/tools/xenserver/destroy_cached_images.py +++ b/tools/xenserver/destroy_cached_images.py @@ -16,6 +16,8 @@ eventlet.monkey_patch() import os import sys +from oslo.config import cfg + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -26,7 +28,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): sys.path.insert(0, POSSIBLE_TOPDIR) from nova import config -from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import utils from nova.virt.xenapi import driver as xenapi_driver diff --git a/tools/xenserver/vm_vdi_cleaner.py b/tools/xenserver/vm_vdi_cleaner.py index c9dc0b53d17c..a842282fa095 100755 --- a/tools/xenserver/vm_vdi_cleaner.py +++ b/tools/xenserver/vm_vdi_cleaner.py @@ -19,6 +19,8 @@ import doctest import os import sys + +from oslo.config import cfg import XenAPI @@ -30,7 +32,6 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): from nova import context from nova import db from nova import exception -from nova.openstack.common import cfg from nova.openstack.common import timeutils from nova.virt import virtapi from nova.virt.xenapi import driver as xenapi_driver diff --git a/tox.ini b/tox.ini index a34315a7f471..b4b5ccc20574 100644 --- a/tox.ini +++ b/tox.ini @@ -15,9 +15,6 @@ sitepackages = True downloadcache = ~/cache/pip [testenv:pep8] -deps= - pep8==1.3.3 - pyflakes commands = bash tools/run_pep8.sh [testenv:pylint]