From b5990a7bd73684a73af7b9cb6a939493d60e6393 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Sun, 10 Feb 2013 19:00:19 -0500 Subject: [PATCH] Use oslo-config-2013.1b3 The cfg API is now available via the oslo-config library, so switch to it and remove the copied-and-pasted version. Add the 2013.1b3 tarball to tools/pip-requires - this will be changed to 'oslo-config>=2013.1' when oslo-config is published to pypi. This will happen in time for grizzly final. Remove the 'deps = pep8' from tox.ini as it means all the other deps get installed with easy_install which can't install oslo-config from the URL. Retain dummy cfg.py file until keystoneclient middleware has been updated (I18c450174277c8e2d15ed93879da6cd92074c27a). Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc --- bin/quantum-usage-audit | 3 +- openstack-common.conf | 2 +- quantum/agent/common/config.py | 2 +- quantum/agent/dhcp_agent.py | 2 +- quantum/agent/l3_agent.py | 2 +- quantum/agent/linux/dhcp.py | 2 +- quantum/agent/linux/external_process.py | 3 +- quantum/agent/linux/interface.py | 2 +- quantum/agent/linux/iptables_firewall.py | 2 +- quantum/agent/linux/iptables_manager.py | 3 +- quantum/agent/metadata/agent.py | 2 +- quantum/agent/metadata/namespace_proxy.py | 2 +- quantum/agent/netns_cleanup_util.py | 2 +- quantum/agent/ovs_cleanup_util.py | 3 +- quantum/agent/securitygroups_rpc.py | 3 +- quantum/api/extensions.py | 2 +- quantum/api/v2/router.py | 2 +- quantum/auth.py | 2 +- quantum/common/config.py | 2 +- quantum/common/utils.py | 2 +- quantum/db/api.py | 2 +- quantum/db/db_base_plugin_v2.py | 2 +- quantum/db/loadbalancer/loadbalancer_db.py | 2 +- quantum/db/migration/cli.py | 2 +- quantum/db/securitygroups_db.py | 2 +- quantum/db/servicetype_db.py | 2 +- quantum/debug/debug_agent.py | 2 +- quantum/debug/shell.py | 3 +- quantum/extensions/l3.py | 3 +- quantum/extensions/quotasv2.py | 2 +- quantum/extensions/securitygroup.py | 3 +- quantum/manager.py | 3 +- quantum/openstack/common/cfg.py | 1736 +---------------- quantum/openstack/common/eventlet_backdoor.py | 3 +- quantum/openstack/common/iniparser.py | 130 -- quantum/openstack/common/lockutils.py | 2 +- quantum/openstack/common/log.py | 3 +- quantum/openstack/common/notifier/api.py | 3 +- .../openstack/common/notifier/log_notifier.py | 3 +- .../openstack/common/notifier/rpc_notifier.py | 3 +- .../common/notifier/rpc_notifier2.py | 3 +- quantum/openstack/common/rpc/__init__.py | 3 +- quantum/openstack/common/rpc/common.py | 3 +- quantum/openstack/common/rpc/impl_kombu.py | 2 +- quantum/openstack/common/rpc/impl_qpid.py | 2 +- quantum/openstack/common/rpc/impl_zmq.py | 2 +- quantum/openstack/common/rpc/matchmaker.py | 3 +- quantum/openstack/common/service.py | 2 +- quantum/plugins/bigswitch/plugin.py | 3 +- quantum/plugins/brocade/QuantumPlugin.py | 4 +- .../cisco/tests/unit/v2/test_api_v2.py | 5 +- .../hyperv/agent/hyperv_quantum_agent.py | 3 +- quantum/plugins/hyperv/agent/utils.py | 3 +- .../plugins/hyperv/hyperv_quantum_plugin.py | 3 +- .../agent/linuxbridge_quantum_agent.py | 2 +- quantum/plugins/linuxbridge/common/config.py | 3 +- .../plugins/linuxbridge/lb_quantum_plugin.py | 3 +- quantum/plugins/metaplugin/common/config.py | 2 +- .../plugins/metaplugin/meta_quantum_plugin.py | 3 +- .../metaplugin/proxy_quantum_plugin.py | 3 +- quantum/plugins/nec/common/config.py | 3 +- .../plugins/nec/extensions/packetfilter.py | 3 +- .../nicira/nicira_nvp_plugin/QuantumPlugin.py | 2 +- .../nicira/nicira_nvp_plugin/common/config.py | 3 +- .../openvswitch/agent/ovs_quantum_agent.py | 2 +- quantum/plugins/openvswitch/common/config.py | 3 +- quantum/plugins/openvswitch/ovs_db_v2.py | 3 +- .../plugins/openvswitch/ovs_quantum_plugin.py | 3 +- .../plumgrid_nos_plugin/plumgrid_plugin.py | 3 +- .../plugins/ryu/agent/ryu_quantum_agent.py | 8 +- quantum/plugins/ryu/common/config.py | 3 +- quantum/plugins/ryu/ryu_quantum_plugin.py | 2 +- quantum/policy.py | 3 +- quantum/quota.py | 3 +- quantum/server/__init__.py | 3 +- quantum/service.py | 3 +- quantum/tests/unit/__init__.py | 2 +- .../unit/_test_extension_portbindings.py | 3 +- .../tests/unit/bigswitch/test_router_db.py | 2 +- .../db/loadbalancer/test_db_loadbalancer.py | 2 +- .../unit/hyperv/test_hyperv_quantum_agent.py | 2 +- .../unit/hyperv/test_hyperv_quantum_plugin.py | 3 +- .../tests/unit/linuxbridge/test_defaults.py | 2 +- .../unit/linuxbridge/test_lb_quantum_agent.py | 2 +- .../tests/unit/metaplugin/test_metaplugin.py | 2 +- quantum/tests/unit/nicira/test_defaults.py | 3 +- .../tests/unit/nicira/test_nicira_plugin.py | 2 +- .../unit/openvswitch/test_ovs_defaults.py | 3 +- .../openvswitch/test_ovs_quantum_agent.py | 2 +- .../tests/unit/openvswitch/test_ovs_tunnel.py | 2 +- quantum/tests/unit/ryu/test_defaults.py | 2 +- quantum/tests/unit/ryu/test_ryu_db.py | 3 +- .../tests/unit/test_agent_netns_cleanup.py | 2 +- quantum/tests/unit/test_agent_ovs_cleanup.py | 2 +- quantum/tests/unit/test_agent_rpc.py | 2 +- quantum/tests/unit/test_api_v2.py | 2 +- quantum/tests/unit/test_config.py | 3 +- quantum/tests/unit/test_db.py | 5 +- quantum/tests/unit/test_db_plugin.py | 2 +- quantum/tests/unit/test_debug_commands.py | 2 +- quantum/tests/unit/test_dhcp_agent.py | 2 +- .../unit/test_extension_extended_attribute.py | 2 +- .../unit/test_extension_security_group.py | 2 +- quantum/tests/unit/test_l3_agent.py | 2 +- quantum/tests/unit/test_l3_plugin.py | 2 +- quantum/tests/unit/test_linux_dhcp.py | 2 +- quantum/tests/unit/test_linux_interface.py | 2 +- .../tests/unit/test_loadbalancer_plugin.py | 2 +- quantum/tests/unit/test_quantum_manager.py | 3 +- .../tests/unit/test_quota_per_tenant_ext.py | 2 +- .../tests/unit/test_security_groups_rpc.py | 2 +- quantum/tests/unit/test_servicetype.py | 2 +- tools/install_venv_common.py | 2 +- tools/pip-requires | 1 + tox.ini | 2 - 115 files changed, 164 insertions(+), 1986 deletions(-) delete mode 100644 quantum/openstack/common/iniparser.py diff --git a/bin/quantum-usage-audit b/bin/quantum-usage-audit index 1d121f0668..fd841e77cf 100755 --- a/bin/quantum-usage-audit +++ b/bin/quantum-usage-audit @@ -21,10 +21,11 @@ subnets. """ +from oslo.config import cfg + from quantum import context from quantum import manager from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common.notifier import api as notifier_api if __name__ == '__main__': diff --git a/openstack-common.conf b/openstack-common.conf index 0d738376ed..91eea907b7 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -1,5 +1,5 @@ [DEFAULT] # The list of modules to copy from openstack-common -modules=cfg,context,eventlet_backdoor,exception,excutils,fileutils,gettextutils,importutils,iniparser,install_venv_common,jsonutils,local,lockutils,log,loopingcall,network_utils,notifier,periodic_task,policy,processutils,rpc,service,setup,threadgroup,timeutils,uuidutils,version +modules=context,eventlet_backdoor,exception,excutils,fileutils,gettextutils,importutils,install_venv_common,jsonutils,local,lockutils,log,loopingcall,network_utils,notifier,periodic_task,policy,processutils,rpc,service,setup,threadgroup,timeutils,uuidutils,version # The base module to hold the copy of openstack.common base=quantum diff --git a/quantum/agent/common/config.py b/quantum/agent/common/config.py index f9b8eb1472..1b11780266 100644 --- a/quantum/agent/common/config.py +++ b/quantum/agent/common/config.py @@ -15,9 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging diff --git a/quantum/agent/dhcp_agent.py b/quantum/agent/dhcp_agent.py index 0167e55e7e..463bec563a 100644 --- a/quantum/agent/dhcp_agent.py +++ b/quantum/agent/dhcp_agent.py @@ -21,6 +21,7 @@ import uuid import eventlet import netaddr +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.linux import dhcp @@ -31,7 +32,6 @@ from quantum.agent import rpc as agent_rpc from quantum.common import exceptions from quantum.common import topics from quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import jsonutils from quantum.openstack.common import log as logging diff --git a/quantum/agent/l3_agent.py b/quantum/agent/l3_agent.py index 129efcb942..f5730fde4e 100644 --- a/quantum/agent/l3_agent.py +++ b/quantum/agent/l3_agent.py @@ -24,6 +24,7 @@ import sys import eventlet from eventlet import semaphore import netaddr +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.linux import external_process @@ -35,7 +36,6 @@ from quantum.common import constants as l3_constants from quantum.common import topics from quantum import context from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging from quantum.openstack.common import periodic_task diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 7d9c4b02a9..0c05fcaabb 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -24,10 +24,10 @@ import sys import tempfile import netaddr +from oslo.config import cfg from quantum.agent.linux import ip_lib from quantum.agent.linux import utils -from quantum.openstack.common import cfg from quantum.openstack.common import jsonutils from quantum.openstack.common import log as logging diff --git a/quantum/agent/linux/external_process.py b/quantum/agent/linux/external_process.py index f0a59d4758..874aba1615 100644 --- a/quantum/agent/linux/external_process.py +++ b/quantum/agent/linux/external_process.py @@ -18,9 +18,10 @@ import os +from oslo.config import cfg + from quantum.agent.linux import ip_lib from quantum.agent.linux import utils -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/quantum/agent/linux/interface.py b/quantum/agent/linux/interface.py index e32e375e58..21a251a0d0 100644 --- a/quantum/agent/linux/interface.py +++ b/quantum/agent/linux/interface.py @@ -18,6 +18,7 @@ import abc import netaddr +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.linux import ip_lib @@ -25,7 +26,6 @@ from quantum.agent.linux import ovs_lib from quantum.agent.linux import utils from quantum.common import exceptions from quantum.extensions.flavor import (FLAVOR_NETWORK) -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging diff --git a/quantum/agent/linux/iptables_firewall.py b/quantum/agent/linux/iptables_firewall.py index 057ee9685f..246fd87566 100644 --- a/quantum/agent/linux/iptables_firewall.py +++ b/quantum/agent/linux/iptables_firewall.py @@ -16,11 +16,11 @@ # under the License. import netaddr +from oslo.config import cfg from quantum.agent import firewall from quantum.agent.linux import iptables_manager from quantum.common import constants -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging diff --git a/quantum/agent/linux/iptables_manager.py b/quantum/agent/linux/iptables_manager.py index 67942bed7d..8c63d8d68d 100644 --- a/quantum/agent/linux/iptables_manager.py +++ b/quantum/agent/linux/iptables_manager.py @@ -24,8 +24,9 @@ import inspect import os +from oslo.config import cfg + from quantum.agent.linux import utils -from quantum.openstack.common import cfg from quantum.openstack.common import lockutils from quantum.openstack.common import log as logging diff --git a/quantum/agent/metadata/agent.py b/quantum/agent/metadata/agent.py index ec144f2065..773f31a4c9 100644 --- a/quantum/agent/metadata/agent.py +++ b/quantum/agent/metadata/agent.py @@ -24,11 +24,11 @@ import urlparse import eventlet import httplib2 +from oslo.config import cfg from quantumclient.v2_0 import client import webob from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import wsgi diff --git a/quantum/agent/metadata/namespace_proxy.py b/quantum/agent/metadata/namespace_proxy.py index d97bff0432..b289464537 100644 --- a/quantum/agent/metadata/namespace_proxy.py +++ b/quantum/agent/metadata/namespace_proxy.py @@ -22,11 +22,11 @@ import urlparse import eventlet import httplib2 +from oslo.config import cfg import webob from quantum.agent.linux import daemon from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import wsgi diff --git a/quantum/agent/netns_cleanup_util.py b/quantum/agent/netns_cleanup_util.py index b3442c8db3..ea44ad461b 100644 --- a/quantum/agent/netns_cleanup_util.py +++ b/quantum/agent/netns_cleanup_util.py @@ -18,6 +18,7 @@ import re import eventlet +from oslo.config import cfg from quantum.agent import dhcp_agent from quantum.agent import l3_agent @@ -27,7 +28,6 @@ from quantum.agent.linux import ip_lib from quantum.agent.linux import ovs_lib from quantum.api.v2 import attributes from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging diff --git a/quantum/agent/ovs_cleanup_util.py b/quantum/agent/ovs_cleanup_util.py index d9ee645919..819bcab090 100644 --- a/quantum/agent/ovs_cleanup_util.py +++ b/quantum/agent/ovs_cleanup_util.py @@ -15,13 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from quantum.agent import l3_agent from quantum.agent.common import config as agent_config from quantum.agent.linux import interface from quantum.agent.linux import ip_lib from quantum.agent.linux import ovs_lib from quantum.common import config -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging diff --git a/quantum/agent/securitygroups_rpc.py b/quantum/agent/securitygroups_rpc.py index 01b4e110fe..1b84c788cc 100644 --- a/quantum/agent/securitygroups_rpc.py +++ b/quantum/agent/securitygroups_rpc.py @@ -16,8 +16,9 @@ # under the License. # +from oslo.config import cfg + from quantum.common import topics -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging diff --git a/quantum/api/extensions.py b/quantum/api/extensions.py index 3d99111862..1679ebfcea 100644 --- a/quantum/api/extensions.py +++ b/quantum/api/extensions.py @@ -21,6 +21,7 @@ from abc import ABCMeta import imp import os +from oslo.config import cfg import routes import webob.dec import webob.exc @@ -30,7 +31,6 @@ from quantum.common import constants from quantum.common import exceptions import quantum.extensions from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import wsgi diff --git a/quantum/api/v2/router.py b/quantum/api/v2/router.py index 77e0070063..dae677b280 100644 --- a/quantum/api/v2/router.py +++ b/quantum/api/v2/router.py @@ -15,6 +15,7 @@ import urlparse +from oslo.config import cfg import routes as routes_mapper import webob import webob.dec @@ -24,7 +25,6 @@ from quantum.api import extensions from quantum.api.v2 import attributes from quantum.api.v2 import base from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import wsgi diff --git a/quantum/auth.py b/quantum/auth.py index 9146761f0f..7279f279fb 100644 --- a/quantum/auth.py +++ b/quantum/auth.py @@ -14,11 +14,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 quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import wsgi diff --git a/quantum/common/config.py b/quantum/common/config.py index 7fde3f9edc..a33f319e97 100644 --- a/quantum/common/config.py +++ b/quantum/common/config.py @@ -21,11 +21,11 @@ Routines for configuring Quantum import os +from oslo.config import cfg from paste import deploy from quantum.api.v2 import attributes from quantum.common import utils -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.version import version_info as quantum_version diff --git a/quantum/common/utils.py b/quantum/common/utils.py index 76cdd1c926..da0e019153 100644 --- a/quantum/common/utils.py +++ b/quantum/common/utils.py @@ -26,8 +26,8 @@ import signal import socket from eventlet.green import subprocess +from oslo.config import cfg -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging diff --git a/quantum/db/api.py b/quantum/db/api.py index 6dcd8f3b25..d27a0c21c1 100644 --- a/quantum/db/api.py +++ b/quantum/db/api.py @@ -25,6 +25,7 @@ try: import MySQLdb except ImportError: MySQLdb = None +from oslo.config import cfg import sqlalchemy as sql from sqlalchemy import create_engine from sqlalchemy.exc import DisconnectionError @@ -32,7 +33,6 @@ from sqlalchemy.interfaces import PoolListener from sqlalchemy.orm import sessionmaker from quantum.db import model_base -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index fb34bf835f..f129cf0ac4 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -19,6 +19,7 @@ import datetime import random import netaddr +from oslo.config import cfg from sqlalchemy import orm from sqlalchemy.orm import exc @@ -27,7 +28,6 @@ from quantum.common import constants from quantum.common import exceptions as q_exc from quantum.db import api as db from quantum.db import models_v2 -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import timeutils from quantum.openstack.common import uuidutils diff --git a/quantum/db/loadbalancer/loadbalancer_db.py b/quantum/db/loadbalancer/loadbalancer_db.py index 6259201c84..7a9ab82a00 100644 --- a/quantum/db/loadbalancer/loadbalancer_db.py +++ b/quantum/db/loadbalancer/loadbalancer_db.py @@ -15,6 +15,7 @@ # under the License. # +from oslo.config import cfg import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.orm import exc @@ -28,7 +29,6 @@ from quantum.db import model_base from quantum.db import models_v2 from quantum.extensions import loadbalancer from quantum.extensions.loadbalancer import LoadBalancerPluginBase -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import uuidutils from quantum.plugins.common import constants diff --git a/quantum/db/migration/cli.py b/quantum/db/migration/cli.py index dc9ec18178..25e0ce09f6 100644 --- a/quantum/db/migration/cli.py +++ b/quantum/db/migration/cli.py @@ -22,9 +22,9 @@ import sys from alembic import command as alembic_command from alembic import config as alembic_config from alembic import util as alembic_util +from oslo.config import cfg from quantum import manager -from quantum.openstack.common import cfg _core_opts = [ cfg.StrOpt('core_plugin', diff --git a/quantum/db/securitygroups_db.py b/quantum/db/securitygroups_db.py index 7eba36cf53..6468f11175 100644 --- a/quantum/db/securitygroups_db.py +++ b/quantum/db/securitygroups_db.py @@ -16,6 +16,7 @@ # # @author: Aaron Rosen, Nicira, Inc +from oslo.config import cfg import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.orm import exc @@ -25,7 +26,6 @@ from quantum.api.v2 import attributes as attr from quantum.db import model_base from quantum.db import models_v2 from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils diff --git a/quantum/db/servicetype_db.py b/quantum/db/servicetype_db.py index 04318a3650..1f619bc874 100644 --- a/quantum/db/servicetype_db.py +++ b/quantum/db/servicetype_db.py @@ -17,6 +17,7 @@ # @author: Salvatore Orlando, VMware # +from oslo.config import cfg import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.orm import exc as orm_exc @@ -27,7 +28,6 @@ from quantum import context from quantum.db import api as db from quantum.db import model_base from quantum.db import models_v2 -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum import policy diff --git a/quantum/debug/debug_agent.py b/quantum/debug/debug_agent.py index de874f1d50..156eec416d 100644 --- a/quantum/debug/debug_agent.py +++ b/quantum/debug/debug_agent.py @@ -19,12 +19,12 @@ import shlex import socket import netaddr +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.dhcp_agent import DictModel from quantum.agent.linux import ip_lib from quantum.agent.linux import utils -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging diff --git a/quantum/debug/shell.py b/quantum/debug/shell.py index 327012554d..ed7f09fa06 100644 --- a/quantum/debug/shell.py +++ b/quantum/debug/shell.py @@ -17,10 +17,11 @@ import sys +from oslo.config import cfg + from quantum.agent.common import config from quantum.agent.linux import interface from quantum.debug.debug_agent import QuantumDebugAgent -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantumclient.common import exceptions as exc from quantumclient.common import utils diff --git a/quantum/extensions/l3.py b/quantum/extensions/l3.py index e3a1263d25..2b251f6017 100644 --- a/quantum/extensions/l3.py +++ b/quantum/extensions/l3.py @@ -20,12 +20,13 @@ from abc import abstractmethod +from oslo.config import cfg + from quantum.api import extensions from quantum.api.v2 import attributes as attr from quantum.api.v2 import base from quantum.common import exceptions as qexception from quantum import manager -from quantum.openstack.common import cfg from quantum import quota diff --git a/quantum/extensions/quotasv2.py b/quantum/extensions/quotasv2.py index d1e1cc605b..87015d39ba 100644 --- a/quantum/extensions/quotasv2.py +++ b/quantum/extensions/quotasv2.py @@ -15,13 +15,13 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg import webob from quantum.api import extensions from quantum.api.v2 import base from quantum.common import exceptions from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum import quota from quantum import wsgi diff --git a/quantum/extensions/securitygroup.py b/quantum/extensions/securitygroup.py index cd3ee9c18c..6c43ac48b8 100644 --- a/quantum/extensions/securitygroup.py +++ b/quantum/extensions/securitygroup.py @@ -17,12 +17,13 @@ from abc import abstractmethod +from oslo.config import cfg + from quantum.api import extensions from quantum.api.v2 import attributes as attr from quantum.api.v2 import base from quantum.common import exceptions as qexception from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils from quantum import quota diff --git a/quantum/manager.py b/quantum/manager.py index c9053c44ea..74057dc5f9 100644 --- a/quantum/manager.py +++ b/quantum/manager.py @@ -16,8 +16,9 @@ # under the License. # @author: Somik Behera, Nicira Networks, Inc. +from oslo.config import cfg + from quantum.common.exceptions import ClassNotFound -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging from quantum.openstack.common import periodic_task diff --git a/quantum/openstack/common/cfg.py b/quantum/openstack/common/cfg.py index 9eaaf1ac32..c35dcb845e 100644 --- a/quantum/openstack/common/cfg.py +++ b/quantum/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 quantum.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 quantum.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/quantum/openstack/common/eventlet_backdoor.py b/quantum/openstack/common/eventlet_backdoor.py index 6af0f9da49..61ceded438 100644 --- a/quantum/openstack/common/eventlet_backdoor.py +++ b/quantum/openstack/common/eventlet_backdoor.py @@ -24,8 +24,7 @@ import traceback import eventlet import eventlet.backdoor import greenlet - -from quantum.openstack.common import cfg +from oslo.config import cfg eventlet_backdoor_opts = [ cfg.IntOpt('backdoor_port', diff --git a/quantum/openstack/common/iniparser.py b/quantum/openstack/common/iniparser.py deleted file mode 100644 index 9bf399f0c7..0000000000 --- a/quantum/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/quantum/openstack/common/lockutils.py b/quantum/openstack/common/lockutils.py index 750a47bc72..973607e200 100644 --- a/quantum/openstack/common/lockutils.py +++ b/quantum/openstack/common/lockutils.py @@ -25,8 +25,8 @@ import time import weakref from eventlet import semaphore +from oslo.config import cfg -from quantum.openstack.common import cfg from quantum.openstack.common import fileutils from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import local diff --git a/quantum/openstack/common/log.py b/quantum/openstack/common/log.py index e6e8414c39..ef7e27e8ad 100644 --- a/quantum/openstack/common/log.py +++ b/quantum/openstack/common/log.py @@ -40,7 +40,8 @@ import stat import sys import traceback -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import jsonutils from quantum.openstack.common import local diff --git a/quantum/openstack/common/notifier/api.py b/quantum/openstack/common/notifier/api.py index 09ab447a36..13cfea2e25 100644 --- a/quantum/openstack/common/notifier/api.py +++ b/quantum/openstack/common/notifier/api.py @@ -15,7 +15,8 @@ import uuid -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common import context from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils diff --git a/quantum/openstack/common/notifier/log_notifier.py b/quantum/openstack/common/notifier/log_notifier.py index 225cbd1e10..bc8f61865e 100644 --- a/quantum/openstack/common/notifier/log_notifier.py +++ b/quantum/openstack/common/notifier/log_notifier.py @@ -14,7 +14,8 @@ # under the License. -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common import jsonutils from quantum.openstack.common import log as logging diff --git a/quantum/openstack/common/notifier/rpc_notifier.py b/quantum/openstack/common/notifier/rpc_notifier.py index 213779777b..8d84aa69c0 100644 --- a/quantum/openstack/common/notifier/rpc_notifier.py +++ b/quantum/openstack/common/notifier/rpc_notifier.py @@ -14,7 +14,8 @@ # under the License. -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common import context as req_context from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import log as logging diff --git a/quantum/openstack/common/notifier/rpc_notifier2.py b/quantum/openstack/common/notifier/rpc_notifier2.py index b0b9e66756..6d725f0160 100644 --- a/quantum/openstack/common/notifier/rpc_notifier2.py +++ b/quantum/openstack/common/notifier/rpc_notifier2.py @@ -15,7 +15,8 @@ '''messaging based notification driver, with message envelopes''' -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common import context as req_context from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import log as logging diff --git a/quantum/openstack/common/rpc/__init__.py b/quantum/openstack/common/rpc/__init__.py index 9d0fede6ff..bd10bb777d 100644 --- a/quantum/openstack/common/rpc/__init__.py +++ b/quantum/openstack/common/rpc/__init__.py @@ -28,7 +28,8 @@ For some wrappers that add message versioning to rpc, see: import inspect import logging -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils from quantum.openstack.common import local diff --git a/quantum/openstack/common/rpc/common.py b/quantum/openstack/common/rpc/common.py index 4be74d651e..4377eaac50 100644 --- a/quantum/openstack/common/rpc/common.py +++ b/quantum/openstack/common/rpc/common.py @@ -21,7 +21,8 @@ import copy import sys import traceback -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils from quantum.openstack.common import jsonutils diff --git a/quantum/openstack/common/rpc/impl_kombu.py b/quantum/openstack/common/rpc/impl_kombu.py index 70c2b87ae2..1635e166e1 100644 --- a/quantum/openstack/common/rpc/impl_kombu.py +++ b/quantum/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 quantum.openstack.common import cfg from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import network_utils from quantum.openstack.common.rpc import amqp as rpc_amqp diff --git a/quantum/openstack/common/rpc/impl_qpid.py b/quantum/openstack/common/rpc/impl_qpid.py index 70b11d2147..689c9704e2 100644 --- a/quantum/openstack/common/rpc/impl_qpid.py +++ b/quantum/openstack/common/rpc/impl_qpid.py @@ -22,8 +22,8 @@ import uuid import eventlet import greenlet +from oslo.config import cfg -from quantum.openstack.common import cfg from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils from quantum.openstack.common import jsonutils diff --git a/quantum/openstack/common/rpc/impl_zmq.py b/quantum/openstack/common/rpc/impl_zmq.py index 532708ab85..caa89c88ea 100644 --- a/quantum/openstack/common/rpc/impl_zmq.py +++ b/quantum/openstack/common/rpc/impl_zmq.py @@ -23,8 +23,8 @@ import uuid import eventlet import greenlet +from oslo.config import cfg -from quantum.openstack.common import cfg from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils from quantum.openstack.common import jsonutils diff --git a/quantum/openstack/common/rpc/matchmaker.py b/quantum/openstack/common/rpc/matchmaker.py index 2d97ac5e69..874e022ab1 100644 --- a/quantum/openstack/common/rpc/matchmaker.py +++ b/quantum/openstack/common/rpc/matchmaker.py @@ -22,7 +22,8 @@ import contextlib import itertools import json -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import log as logging diff --git a/quantum/openstack/common/service.py b/quantum/openstack/common/service.py index d702506627..3e8514475a 100644 --- a/quantum/openstack/common/service.py +++ b/quantum/openstack/common/service.py @@ -28,8 +28,8 @@ import time import eventlet import logging as std_logging +from oslo.config import cfg -from quantum.openstack.common import cfg from quantum.openstack.common import eventlet_backdoor from quantum.openstack.common.gettextutils import _ from quantum.openstack.common import importutils diff --git a/quantum/plugins/bigswitch/plugin.py b/quantum/plugins/bigswitch/plugin.py index 8566e72099..dfb0b5c252 100644 --- a/quantum/plugins/bigswitch/plugin.py +++ b/quantum/plugins/bigswitch/plugin.py @@ -50,6 +50,8 @@ import httplib import json import socket +from oslo.config import cfg + from quantum.common import constants as const from quantum.common import exceptions from quantum.common import rpc as q_rpc @@ -61,7 +63,6 @@ from quantum.db import db_base_plugin_v2 from quantum.db import dhcp_rpc_base from quantum.db import l3_db from quantum.extensions import l3 -from quantum.openstack.common import cfg from quantum.openstack.common import lockutils from quantum.openstack.common import log as logging from quantum.openstack.common import rpc diff --git a/quantum/plugins/brocade/QuantumPlugin.py b/quantum/plugins/brocade/QuantumPlugin.py index 6e1dd6156c..9bd879cbe9 100644 --- a/quantum/plugins/brocade/QuantumPlugin.py +++ b/quantum/plugins/brocade/QuantumPlugin.py @@ -26,6 +26,9 @@ """ Implentation of Brocade Quantum Plugin. """ + +from oslo.config import cfg + from quantum.agent import securitygroups_rpc as sg_rpc from quantum.common import rpc as q_rpc from quantum.common import topics @@ -38,7 +41,6 @@ from quantum.db import l3_rpc_base from quantum.db import securitygroups_rpc_base as sg_db_rpc from quantum.extensions import portbindings from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common import context from quantum.openstack.common import importutils from quantum.openstack.common import log as logging diff --git a/quantum/plugins/cisco/tests/unit/v2/test_api_v2.py b/quantum/plugins/cisco/tests/unit/v2/test_api_v2.py index 289fd2306f..bf3cb6b4d9 100644 --- a/quantum/plugins/cisco/tests/unit/v2/test_api_v2.py +++ b/quantum/plugins/cisco/tests/unit/v2/test_api_v2.py @@ -17,15 +17,16 @@ import inspect import logging -import mock import os + +import mock +from oslo.config import cfg import webtest from quantum.api.extensions import PluginAwareExtensionManager from quantum.api.v2 import router from quantum.common import config from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.tests.unit import test_api_v2 diff --git a/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py b/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py index 81e50437f9..3ce925551e 100644 --- a/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py +++ b/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py @@ -24,11 +24,12 @@ import re import sys import time +from oslo.config import cfg + from quantum.agent import rpc as agent_rpc from quantum.common import config as logging_config from quantum.common import topics from quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common.rpc import dispatcher from quantum.plugins.hyperv.agent import utils diff --git a/quantum/plugins/hyperv/agent/utils.py b/quantum/plugins/hyperv/agent/utils.py index 15829417fc..84c318d615 100644 --- a/quantum/plugins/hyperv/agent/utils.py +++ b/quantum/plugins/hyperv/agent/utils.py @@ -21,8 +21,9 @@ import sys import time +from oslo.config import cfg + from quantum.common import exceptions as q_exc -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging # Check needed for unit testing on Unix diff --git a/quantum/plugins/hyperv/hyperv_quantum_plugin.py b/quantum/plugins/hyperv/hyperv_quantum_plugin.py index 10fd7580b6..8f2fae99d4 100644 --- a/quantum/plugins/hyperv/hyperv_quantum_plugin.py +++ b/quantum/plugins/hyperv/hyperv_quantum_plugin.py @@ -16,6 +16,8 @@ # under the License. # @author: Alessandro Pilotti, Cloudbase Solutions Srl +from oslo.config import cfg + from quantum.api.v2 import attributes from quantum.common import exceptions as q_exc from quantum.common import topics @@ -25,7 +27,6 @@ from quantum.db import l3_db from quantum.db import quota_db from quantum.extensions import portbindings from quantum.extensions import providernet as provider -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.plugins.hyperv import agent_notifier_api diff --git a/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py b/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py index 11d849f0dc..96c9ac32c4 100755 --- a/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py +++ b/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py @@ -27,6 +27,7 @@ import sys import time import eventlet +from oslo.config import cfg import pyudev from quantum.agent.linux import ip_lib @@ -37,7 +38,6 @@ from quantum.common import config as logging_config from quantum.common import topics from quantum.common import utils as q_utils from quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common.rpc import dispatcher # NOTE (e0ne): this import is needed for config init diff --git a/quantum/plugins/linuxbridge/common/config.py b/quantum/plugins/linuxbridge/common/config.py index af56d5b9c7..43b1e68a31 100644 --- a/quantum/plugins/linuxbridge/common/config.py +++ b/quantum/plugins/linuxbridge/common/config.py @@ -17,8 +17,9 @@ # @author: Sumit Naiksatam, Cisco Systems, Inc. # @author: Rohit Agarwalla, Cisco Systems, Inc. +from oslo.config import cfg + from quantum.agent.common import config -from quantum.openstack.common import cfg DEFAULT_VLAN_RANGES = [] DEFAULT_INTERFACE_MAPPINGS = [] diff --git a/quantum/plugins/linuxbridge/lb_quantum_plugin.py b/quantum/plugins/linuxbridge/lb_quantum_plugin.py index b098284b1a..668e319e2a 100644 --- a/quantum/plugins/linuxbridge/lb_quantum_plugin.py +++ b/quantum/plugins/linuxbridge/lb_quantum_plugin.py @@ -15,6 +15,8 @@ import sys +from oslo.config import cfg + from quantum.agent import securitygroups_rpc as sg_rpc from quantum.api.v2 import attributes from quantum.common import constants as q_const @@ -33,7 +35,6 @@ from quantum.db import securitygroups_rpc_base as sg_db_rpc from quantum.extensions import portbindings from quantum.extensions import providernet as provider from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.openstack.common.rpc import proxy diff --git a/quantum/plugins/metaplugin/common/config.py b/quantum/plugins/metaplugin/common/config.py index b92541c691..1fe8eb7901 100644 --- a/quantum/plugins/metaplugin/common/config.py +++ b/quantum/plugins/metaplugin/common/config.py @@ -15,7 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. -from quantum.openstack.common import cfg +from oslo.config import cfg meta_plugin_opts = [ diff --git a/quantum/plugins/metaplugin/meta_quantum_plugin.py b/quantum/plugins/metaplugin/meta_quantum_plugin.py index 15de8a9c84..ef173eede9 100644 --- a/quantum/plugins/metaplugin/meta_quantum_plugin.py +++ b/quantum/plugins/metaplugin/meta_quantum_plugin.py @@ -15,13 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from quantum.common import exceptions as exc from quantum.db import api as db from quantum.db import db_base_plugin_v2 from quantum.db import l3_db from quantum.db import models_v2 from quantum.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER) -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging # NOTE (e0ne): this import is needed for config init diff --git a/quantum/plugins/metaplugin/proxy_quantum_plugin.py b/quantum/plugins/metaplugin/proxy_quantum_plugin.py index 9217b76468..48f3cb5b8b 100644 --- a/quantum/plugins/metaplugin/proxy_quantum_plugin.py +++ b/quantum/plugins/metaplugin/proxy_quantum_plugin.py @@ -15,10 +15,11 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from quantum.db import api as db from quantum.db import db_base_plugin_v2 from quantum.db import l3_db -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantumclient.common import exceptions from quantumclient.v2_0 import client diff --git a/quantum/plugins/nec/common/config.py b/quantum/plugins/nec/common/config.py index e778251695..d2de49866b 100644 --- a/quantum/plugins/nec/common/config.py +++ b/quantum/plugins/nec/common/config.py @@ -15,8 +15,9 @@ # under the License. # @author: Ryota MIBU +from oslo.config import cfg + from quantum.agent.common import config -from quantum.openstack.common import cfg # import rpc config options from quantum.openstack.common import rpc diff --git a/quantum/plugins/nec/extensions/packetfilter.py b/quantum/plugins/nec/extensions/packetfilter.py index cb510374c5..fe3bb6f92a 100644 --- a/quantum/plugins/nec/extensions/packetfilter.py +++ b/quantum/plugins/nec/extensions/packetfilter.py @@ -18,11 +18,12 @@ # @author: Ryota MIBU # +from oslo.config import cfg + from quantum.api import extensions from quantum.api.v2 import attributes from quantum.api.v2 import base from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum import quota diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py index 83956d76d6..a8e2de004c 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py @@ -23,6 +23,7 @@ import hashlib import logging +from oslo.config import cfg from sqlalchemy.orm import exc as sa_exc import webob.exc @@ -45,7 +46,6 @@ from quantum.extensions import l3 from quantum.extensions import portsecurity as psec from quantum.extensions import providernet as pnet from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common import rpc from quantum.plugins.nicira.nicira_nvp_plugin.common import (securitygroups as nvp_sec) diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/common/config.py b/quantum/plugins/nicira/nicira_nvp_plugin/common/config.py index d801b2eda2..fc98c7e8de 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/common/config.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/common/config.py @@ -14,8 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -from quantum.openstack.common import cfg - +from oslo.config import cfg core_opts = [ cfg.BoolOpt('metadata_dhcp_host_route', default=False), diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index 6123ab13a4..be34a86cbd 100644 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -24,6 +24,7 @@ import sys import time import eventlet +from oslo.config import cfg from quantum.agent.linux import ip_lib from quantum.agent.linux import ovs_lib @@ -34,7 +35,6 @@ from quantum.common import config as logging_config from quantum.common import topics from quantum.common import utils as q_utils from quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common.rpc import dispatcher from quantum.plugins.openvswitch.common import config diff --git a/quantum/plugins/openvswitch/common/config.py b/quantum/plugins/openvswitch/common/config.py index 4ffe588419..82f9c0b143 100644 --- a/quantum/plugins/openvswitch/common/config.py +++ b/quantum/plugins/openvswitch/common/config.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from quantum.agent.common import config -from quantum.openstack.common import cfg DEFAULT_BRIDGE_MAPPINGS = [] diff --git a/quantum/plugins/openvswitch/ovs_db_v2.py b/quantum/plugins/openvswitch/ovs_db_v2.py index 3485756a6f..c6984e9a32 100644 --- a/quantum/plugins/openvswitch/ovs_db_v2.py +++ b/quantum/plugins/openvswitch/ovs_db_v2.py @@ -18,13 +18,14 @@ from sqlalchemy.orm import exc +from oslo.config import cfg + from quantum.common import exceptions as q_exc import quantum.db.api as db from quantum.db import models_v2 from quantum.db import securitygroups_db as sg_db from quantum.extensions import securitygroup as ext_sg from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.plugins.openvswitch.common import constants from quantum.plugins.openvswitch import ovs_models_v2 diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index ce489b7442..76754e7430 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -22,6 +22,8 @@ import sys +from oslo.config import cfg + from quantum.agent import securitygroups_rpc as sg_rpc from quantum.api.v2 import attributes from quantum.common import constants as q_const @@ -38,7 +40,6 @@ from quantum.db import securitygroups_rpc_base as sg_db_rpc from quantum.extensions import portbindings from quantum.extensions import providernet as provider from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.openstack.common.rpc import proxy diff --git a/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py b/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py index 22e31f9626..f3e299ab8c 100644 --- a/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py +++ b/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py @@ -23,9 +23,10 @@ to the Network Operating System by PLUMgrid called NOS import sys +from oslo.config import cfg + from quantum.db import api as db from quantum.db import db_base_plugin_v2 -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.plugins.plumgrid.common import exceptions as plum_excep from quantum.plugins.plumgrid.plumgrid_nos_plugin import plumgrid_nos_snippets diff --git a/quantum/plugins/ryu/agent/ryu_quantum_agent.py b/quantum/plugins/ryu/agent/ryu_quantum_agent.py index 4ac440380a..dbcab7cb3f 100755 --- a/quantum/plugins/ryu/agent/ryu_quantum_agent.py +++ b/quantum/plugins/ryu/agent/ryu_quantum_agent.py @@ -25,6 +25,7 @@ import socket import sys import netifaces +from oslo.config import cfg from ryu.app import client from ryu.app import conf_switch_key from ryu.app import rest_nw_id @@ -36,9 +37,6 @@ from quantum.common import config as logging_config from quantum.common import exceptions as q_exc from quantum.common import topics from quantum import context as q_context -from quantum.openstack.common import cfg -from quantum.openstack.common.cfg import NoSuchGroupError -from quantum.openstack.common.cfg import NoSuchOptError from quantum.openstack.common import log from quantum.plugins.ryu.common import config @@ -68,7 +66,7 @@ def _get_ip(cfg_ip_str, cfg_interface_str): ip = None try: ip = getattr(cfg.CONF.OVS, cfg_ip_str) - except (NoSuchOptError, NoSuchGroupError): + except (cfg.NoSuchOptError, cfg.NoSuchGroupError): pass if ip: return ip @@ -76,7 +74,7 @@ def _get_ip(cfg_ip_str, cfg_interface_str): iface = None try: iface = getattr(cfg.CONF.OVS, cfg_interface_str) - except (NoSuchOptError, NoSuchGroupError): + except (cfg.NoSuchOptError, cfg.NoSuchGroupError): pass if iface: iface = netifaces.ifaddresses(iface)[netifaces.AF_INET][0] diff --git a/quantum/plugins/ryu/common/config.py b/quantum/plugins/ryu/common/config.py index db2c19f2d0..e8bc999880 100644 --- a/quantum/plugins/ryu/common/config.py +++ b/quantum/plugins/ryu/common/config.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from quantum.agent.common import config -from quantum.openstack.common import cfg ovs_opts = [ diff --git a/quantum/plugins/ryu/ryu_quantum_plugin.py b/quantum/plugins/ryu/ryu_quantum_plugin.py index fbb48f8351..8b09afb76b 100644 --- a/quantum/plugins/ryu/ryu_quantum_plugin.py +++ b/quantum/plugins/ryu/ryu_quantum_plugin.py @@ -16,6 +16,7 @@ # under the License. # @author: Isaku Yamahata +from oslo.config import cfg from ryu.app import client from ryu.app import rest_nw_id @@ -29,7 +30,6 @@ from quantum.db import dhcp_rpc_base from quantum.db import l3_db from quantum.db import l3_rpc_base from quantum.db import models_v2 -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.plugins.ryu.common import config diff --git a/quantum/policy.py b/quantum/policy.py index 84490132e2..f9dc76df20 100644 --- a/quantum/policy.py +++ b/quantum/policy.py @@ -19,10 +19,11 @@ Policy engine for quantum. Largely copied from nova. """ +from oslo.config import cfg + from quantum.api.v2 import attributes from quantum.common import exceptions import quantum.common.utils as utils -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common import policy diff --git a/quantum/quota.py b/quantum/quota.py index ec08effcb6..217fdeec5f 100644 --- a/quantum/quota.py +++ b/quantum/quota.py @@ -16,8 +16,9 @@ """Quotas for instances, volumes, and floating ips.""" +from oslo.config import cfg + from quantum.common import exceptions -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging diff --git a/quantum/server/__init__.py b/quantum/server/__init__.py index 2f5ae0e076..69f3391320 100755 --- a/quantum/server/__init__.py +++ b/quantum/server/__init__.py @@ -21,8 +21,9 @@ import sys +from oslo.config import cfg + from quantum.common import config -from quantum.openstack.common import cfg from quantum import service diff --git a/quantum/service.py b/quantum/service.py index bb61aa6811..fa88c7bc65 100644 --- a/quantum/service.py +++ b/quantum/service.py @@ -20,9 +20,10 @@ import logging as std_logging import os import random +from oslo.config import cfg + from quantum.common import config from quantum import context -from quantum.openstack.common import cfg from quantum.openstack.common import importutils from quantum.openstack.common import log as logging from quantum.openstack.common import loopingcall diff --git a/quantum/tests/unit/__init__.py b/quantum/tests/unit/__init__.py index 203b3cf3f7..84a08f086f 100644 --- a/quantum/tests/unit/__init__.py +++ b/quantum/tests/unit/__init__.py @@ -24,7 +24,7 @@ import unittest setattr(__builtin__, '_', lambda x: x) -from quantum.openstack.common import cfg +from oslo.config import cfg reldir = os.path.join(os.path.dirname(__file__), '..', '..', '..') diff --git a/quantum/tests/unit/_test_extension_portbindings.py b/quantum/tests/unit/_test_extension_portbindings.py index b6891c1522..15ed8ab6cb 100644 --- a/quantum/tests/unit/_test_extension_portbindings.py +++ b/quantum/tests/unit/_test_extension_portbindings.py @@ -20,10 +20,11 @@ import contextlib +from oslo.config import cfg + from quantum import context from quantum.extensions import portbindings from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.tests.unit import test_db_plugin diff --git a/quantum/tests/unit/bigswitch/test_router_db.py b/quantum/tests/unit/bigswitch/test_router_db.py index e829eb85de..52502737b2 100644 --- a/quantum/tests/unit/bigswitch/test_router_db.py +++ b/quantum/tests/unit/bigswitch/test_router_db.py @@ -21,12 +21,12 @@ import os from mock import patch +from oslo.config import cfg from webob import exc from quantum.common.test_lib import test_config from quantum.extensions import l3 from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common.notifier import api as notifier_api from quantum.openstack.common.notifier import test_notifier from quantum.tests.unit import test_l3_plugin diff --git a/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py b/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py index 0349f04b28..27453b4eda 100644 --- a/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py +++ b/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py @@ -17,6 +17,7 @@ import contextlib import logging import os +from oslo.config import cfg import webob.exc from quantum.api.extensions import ExtensionMiddleware @@ -29,7 +30,6 @@ from quantum.db import api as db import quantum.extensions from quantum.extensions import loadbalancer from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.plugins.common import constants from quantum.plugins.services.loadbalancer import loadbalancerPlugin from quantum.tests.unit import testlib_api diff --git a/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py b/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py index f58fe232ff..53fee9772a 100644 --- a/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py +++ b/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py @@ -23,9 +23,9 @@ Unit tests for Windows Hyper-V virtual switch quantum driver import sys import mock +from oslo.config import cfg import unittest2 as unittest -from quantum.openstack.common import cfg from quantum.plugins.hyperv.agent import hyperv_quantum_agent diff --git a/quantum/tests/unit/hyperv/test_hyperv_quantum_plugin.py b/quantum/tests/unit/hyperv/test_hyperv_quantum_plugin.py index c6911b8855..8ebea7fe88 100644 --- a/quantum/tests/unit/hyperv/test_hyperv_quantum_plugin.py +++ b/quantum/tests/unit/hyperv/test_hyperv_quantum_plugin.py @@ -18,10 +18,11 @@ import contextlib +from oslo.config import cfg + from quantum import context from quantum.extensions import portbindings from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.tests.unit import test_db_plugin as test_plugin diff --git a/quantum/tests/unit/linuxbridge/test_defaults.py b/quantum/tests/unit/linuxbridge/test_defaults.py index ac9840ffc0..7c6457059c 100644 --- a/quantum/tests/unit/linuxbridge/test_defaults.py +++ b/quantum/tests/unit/linuxbridge/test_defaults.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo.config import cfg import unittest2 as unittest -from quantum.openstack.common import cfg #NOTE this import loads tests required options from quantum.plugins.linuxbridge.common import config diff --git a/quantum/tests/unit/linuxbridge/test_lb_quantum_agent.py b/quantum/tests/unit/linuxbridge/test_lb_quantum_agent.py index be394f13f4..8ce3fc4095 100644 --- a/quantum/tests/unit/linuxbridge/test_lb_quantum_agent.py +++ b/quantum/tests/unit/linuxbridge/test_lb_quantum_agent.py @@ -15,9 +15,9 @@ # under the License. import mock +from oslo.config import cfg import unittest2 as unittest -from quantum.openstack.common import cfg from quantum.plugins.linuxbridge.agent import linuxbridge_quantum_agent from quantum.plugins.linuxbridge.common import constants as lconst diff --git a/quantum/tests/unit/metaplugin/test_metaplugin.py b/quantum/tests/unit/metaplugin/test_metaplugin.py index 1f47eaee99..53480e277f 100644 --- a/quantum/tests/unit/metaplugin/test_metaplugin.py +++ b/quantum/tests/unit/metaplugin/test_metaplugin.py @@ -19,6 +19,7 @@ import os import mock import mox +from oslo.config import cfg import stubout import unittest2 as unittest @@ -26,7 +27,6 @@ from quantum import context from quantum.db import api as db from quantum.db import models_v2 from quantum.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER) -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils from quantum.plugins.metaplugin.meta_quantum_plugin import FlavorNotFound from quantum.plugins.metaplugin.meta_quantum_plugin import MetaPluginV2 diff --git a/quantum/tests/unit/nicira/test_defaults.py b/quantum/tests/unit/nicira/test_defaults.py index fabd030716..62a48ef2b8 100644 --- a/quantum/tests/unit/nicira/test_defaults.py +++ b/quantum/tests/unit/nicira/test_defaults.py @@ -15,7 +15,8 @@ import unittest2 as unittest -from quantum.openstack.common import cfg +from oslo.config import cfg + from quantum.plugins.nicira.nicira_nvp_plugin.common import config diff --git a/quantum/tests/unit/nicira/test_nicira_plugin.py b/quantum/tests/unit/nicira/test_nicira_plugin.py index 94375c59bf..261120fc42 100644 --- a/quantum/tests/unit/nicira/test_nicira_plugin.py +++ b/quantum/tests/unit/nicira/test_nicira_plugin.py @@ -18,6 +18,7 @@ import logging import os import mock +from oslo.config import cfg import webob.exc import quantum.common.test_lib as test_lib @@ -25,7 +26,6 @@ from quantum import context from quantum.extensions import providernet as pnet from quantum.extensions import securitygroup as secgrp from quantum import manager -from quantum.openstack.common import cfg from quantum.plugins.nicira.nicira_nvp_plugin.extensions import (nvp_qos as ext_qos) from quantum.plugins.nicira.nicira_nvp_plugin import nvplib diff --git a/quantum/tests/unit/openvswitch/test_ovs_defaults.py b/quantum/tests/unit/openvswitch/test_ovs_defaults.py index 919863b923..60c13e4f10 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_defaults.py +++ b/quantum/tests/unit/openvswitch/test_ovs_defaults.py @@ -15,7 +15,8 @@ import unittest -from quantum.openstack.common import cfg +from oslo.config import cfg + #NOTE this import loads tests required options from quantum.plugins.openvswitch.common import config diff --git a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py index 675b5665d0..b11b4ce7e1 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py +++ b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py @@ -15,9 +15,9 @@ # under the License. import mock +from oslo.config import cfg import unittest2 as unittest -from quantum.openstack.common import cfg from quantum.plugins.openvswitch.agent import ovs_quantum_agent diff --git a/quantum/tests/unit/openvswitch/test_ovs_tunnel.py b/quantum/tests/unit/openvswitch/test_ovs_tunnel.py index dcc1d0fd15..5571f81865 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/quantum/tests/unit/openvswitch/test_ovs_tunnel.py @@ -19,12 +19,12 @@ import unittest import mox +from oslo.config import cfg from quantum.agent.linux import ip_lib from quantum.agent.linux import ovs_lib from quantum.agent.linux import utils from quantum.agent import rpc -from quantum.openstack.common import cfg from quantum.openstack.common import log from quantum.plugins.openvswitch.agent import ovs_quantum_agent from quantum.plugins.openvswitch.common import constants diff --git a/quantum/tests/unit/ryu/test_defaults.py b/quantum/tests/unit/ryu/test_defaults.py index 7da846bcd3..53e5a959a1 100644 --- a/quantum/tests/unit/ryu/test_defaults.py +++ b/quantum/tests/unit/ryu/test_defaults.py @@ -15,9 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg import unittest2 -from quantum.openstack.common import cfg #NOTE this import loads tests required options from quantum.plugins.ryu.common import config diff --git a/quantum/tests/unit/ryu/test_ryu_db.py b/quantum/tests/unit/ryu/test_ryu_db.py index c93a8b15f9..234e44cdc0 100644 --- a/quantum/tests/unit/ryu/test_ryu_db.py +++ b/quantum/tests/unit/ryu/test_ryu_db.py @@ -18,8 +18,9 @@ from contextlib import nested import operator +from oslo.config import cfg + from quantum.db import api as db -from quantum.openstack.common import cfg # NOTE: this import is needed for correct plugin code work from quantum.plugins.ryu.common import config from quantum.plugins.ryu.db import api_v2 as db_api_v2 diff --git a/quantum/tests/unit/test_agent_netns_cleanup.py b/quantum/tests/unit/test_agent_netns_cleanup.py index 2bf6254b29..1bbd80d5bd 100644 --- a/quantum/tests/unit/test_agent_netns_cleanup.py +++ b/quantum/tests/unit/test_agent_netns_cleanup.py @@ -16,10 +16,10 @@ # under the License. import mock +from oslo.config import cfg import unittest2 as unittest from quantum.agent import netns_cleanup_util as util -from quantum.openstack.common import cfg class TestNullDelegate(unittest.TestCase): diff --git a/quantum/tests/unit/test_agent_ovs_cleanup.py b/quantum/tests/unit/test_agent_ovs_cleanup.py index b607a99aeb..d5cfb64db3 100644 --- a/quantum/tests/unit/test_agent_ovs_cleanup.py +++ b/quantum/tests/unit/test_agent_ovs_cleanup.py @@ -18,12 +18,12 @@ import contextlib import itertools import mock +from oslo.config import cfg import unittest2 as unittest from quantum.agent.linux import ip_lib from quantum.agent.linux import ovs_lib from quantum.agent import ovs_cleanup_util as util -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils diff --git a/quantum/tests/unit/test_agent_rpc.py b/quantum/tests/unit/test_agent_rpc.py index de53ecfda8..e210d9d5d4 100644 --- a/quantum/tests/unit/test_agent_rpc.py +++ b/quantum/tests/unit/test_agent_rpc.py @@ -18,9 +18,9 @@ import unittest import mock +from oslo.config import cfg from quantum.agent import rpc -from quantum.openstack.common import cfg from quantum.openstack.common import context diff --git a/quantum/tests/unit/test_api_v2.py b/quantum/tests/unit/test_api_v2.py index db2b6d6454..95cd6d4a3a 100644 --- a/quantum/tests/unit/test_api_v2.py +++ b/quantum/tests/unit/test_api_v2.py @@ -18,6 +18,7 @@ import os import mock +from oslo.config import cfg import unittest2 as unittest import webob from webob import exc @@ -32,7 +33,6 @@ from quantum.common import constants from quantum.common import exceptions as q_exc from quantum import context from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common.notifier import api as notifer_api from quantum.openstack.common import uuidutils from quantum.tests.unit import testlib_api diff --git a/quantum/tests/unit/test_config.py b/quantum/tests/unit/test_config.py index 2960778c3c..3f814a40cf 100644 --- a/quantum/tests/unit/test_config.py +++ b/quantum/tests/unit/test_config.py @@ -16,8 +16,9 @@ import os import unittest +from oslo.config import cfg + from quantum.common import config -from quantum.openstack.common import cfg class ConfigurationTest(unittest.TestCase): diff --git a/quantum/tests/unit/test_db.py b/quantum/tests/unit/test_db.py index 1b8cc003f4..fad7b4d436 100644 --- a/quantum/tests/unit/test_db.py +++ b/quantum/tests/unit/test_db.py @@ -15,12 +15,11 @@ """Test of DB API""" +import mock +from oslo.config import cfg import unittest2 as unittest -import mock - import quantum.db.api as db -from quantum.openstack.common import cfg class DBTestCase(unittest.TestCase): diff --git a/quantum/tests/unit/test_db_plugin.py b/quantum/tests/unit/test_db_plugin.py index 48a85da2bb..032ad06a2d 100644 --- a/quantum/tests/unit/test_db_plugin.py +++ b/quantum/tests/unit/test_db_plugin.py @@ -22,6 +22,7 @@ import os import random import mock +from oslo.config import cfg import sqlalchemy as sa import unittest2 import webob.exc @@ -39,7 +40,6 @@ from quantum.db import api as db from quantum.db import db_base_plugin_v2 from quantum.db import models_v2 from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common import timeutils from quantum.tests.unit import test_extensions from quantum.tests.unit import testlib_api diff --git a/quantum/tests/unit/test_debug_commands.py b/quantum/tests/unit/test_debug_commands.py index 0f5a4d340b..0049d4e78e 100644 --- a/quantum/tests/unit/test_debug_commands.py +++ b/quantum/tests/unit/test_debug_commands.py @@ -18,13 +18,13 @@ import socket import mock +from oslo.config import cfg import unittest2 as unittest from quantum.agent.common import config from quantum.agent.linux import interface from quantum.debug import commands from quantum.debug.debug_agent import DEVICE_OWNER_PROBE, QuantumDebugAgent -from quantum.openstack.common import cfg class MyApp(object): diff --git a/quantum/tests/unit/test_dhcp_agent.py b/quantum/tests/unit/test_dhcp_agent.py index 26b5bf89e9..e04d350037 100644 --- a/quantum/tests/unit/test_dhcp_agent.py +++ b/quantum/tests/unit/test_dhcp_agent.py @@ -21,13 +21,13 @@ import sys import uuid import mock +from oslo.config import cfg import unittest2 as unittest from quantum.agent.common import config from quantum.agent import dhcp_agent from quantum.agent.linux import interface from quantum.common import exceptions -from quantum.openstack.common import cfg from quantum.openstack.common import jsonutils diff --git a/quantum/tests/unit/test_extension_extended_attribute.py b/quantum/tests/unit/test_extension_extended_attribute.py index 62d46ced42..2a63d07d98 100644 --- a/quantum/tests/unit/test_extension_extended_attribute.py +++ b/quantum/tests/unit/test_extension_extended_attribute.py @@ -19,6 +19,7 @@ Unit tests for extension extended attribute """ +from oslo.config import cfg import unittest2 as unittest import webob.exc as webexc @@ -26,7 +27,6 @@ import quantum from quantum.api import extensions from quantum.common import config from quantum import manager -from quantum.openstack.common import cfg from quantum.plugins.common import constants from quantum.plugins.openvswitch import ovs_quantum_plugin from quantum.tests.unit.extensions import extendedattribute as extattr diff --git a/quantum/tests/unit/test_extension_security_group.py b/quantum/tests/unit/test_extension_security_group.py index cc70b1f54d..4666264bc3 100644 --- a/quantum/tests/unit/test_extension_security_group.py +++ b/quantum/tests/unit/test_extension_security_group.py @@ -17,6 +17,7 @@ import contextlib import os import mock +from oslo.config import cfg import webob.exc from quantum.api.v2 import attributes as attr @@ -25,7 +26,6 @@ from quantum import context from quantum.db import db_base_plugin_v2 from quantum.db import securitygroups_db from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.tests.unit import test_db_plugin DB_PLUGIN_KLASS = ('quantum.tests.unit.test_extension_security_group.' diff --git a/quantum/tests/unit/test_l3_agent.py b/quantum/tests/unit/test_l3_agent.py index dcf3f46633..fbb3dfad6d 100644 --- a/quantum/tests/unit/test_l3_agent.py +++ b/quantum/tests/unit/test_l3_agent.py @@ -19,13 +19,13 @@ import copy import unittest2 import mock +from oslo.config import cfg from quantum.agent import l3_agent from quantum.agent.common import config as agent_config from quantum.agent.linux import interface from quantum.common import config as base_config from quantum.common import constants as l3_constants -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils diff --git a/quantum/tests/unit/test_l3_plugin.py b/quantum/tests/unit/test_l3_plugin.py index e905b3dc01..368a333739 100644 --- a/quantum/tests/unit/test_l3_plugin.py +++ b/quantum/tests/unit/test_l3_plugin.py @@ -24,6 +24,7 @@ import itertools import unittest2 as unittest import mock +from oslo.config import cfg from webob import exc import webtest @@ -40,7 +41,6 @@ from quantum.db import l3_rpc_agent_api from quantum.db import models_v2 from quantum.extensions import l3 from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.openstack.common.notifier import api as notifier_api from quantum.openstack.common.notifier import test_notifier diff --git a/quantum/tests/unit/test_linux_dhcp.py b/quantum/tests/unit/test_linux_dhcp.py index 95ecd892c3..00950b2db8 100644 --- a/quantum/tests/unit/test_linux_dhcp.py +++ b/quantum/tests/unit/test_linux_dhcp.py @@ -20,10 +20,10 @@ import socket import unittest2 as unittest import mock +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.linux import dhcp -from quantum.openstack.common import cfg from quantum.openstack.common import jsonutils diff --git a/quantum/tests/unit/test_linux_interface.py b/quantum/tests/unit/test_linux_interface.py index 4f5007f22f..97d03936cb 100644 --- a/quantum/tests/unit/test_linux_interface.py +++ b/quantum/tests/unit/test_linux_interface.py @@ -18,6 +18,7 @@ import unittest import mock +from oslo.config import cfg from quantum.agent.common import config from quantum.agent.dhcp_agent import DeviceManager @@ -25,7 +26,6 @@ from quantum.agent.linux import interface from quantum.agent.linux import ip_lib from quantum.agent.linux import utils from quantum.extensions.flavor import (FLAVOR_NETWORK) -from quantum.openstack.common import cfg class BaseChild(interface.LinuxInterfaceDriver): diff --git a/quantum/tests/unit/test_loadbalancer_plugin.py b/quantum/tests/unit/test_loadbalancer_plugin.py index 172c271402..e5fb94fe92 100644 --- a/quantum/tests/unit/test_loadbalancer_plugin.py +++ b/quantum/tests/unit/test_loadbalancer_plugin.py @@ -17,6 +17,7 @@ import copy import mock +from oslo.config import cfg import unittest2 from webob import exc import webtest @@ -26,7 +27,6 @@ from quantum.api.v2 import attributes from quantum.common import config from quantum.extensions import loadbalancer from quantum import manager -from quantum.openstack.common import cfg from quantum.openstack.common import uuidutils from quantum.plugins.common import constants from quantum.tests.unit import test_api_v2 diff --git a/quantum/tests/unit/test_quantum_manager.py b/quantum/tests/unit/test_quantum_manager.py index 120d2174e8..990e06e5ef 100644 --- a/quantum/tests/unit/test_quantum_manager.py +++ b/quantum/tests/unit/test_quantum_manager.py @@ -19,10 +19,11 @@ import os import types import unittest2 +from oslo.config import cfg + from quantum.common import config from quantum.common.test_lib import test_config from quantum.manager import QuantumManager -from quantum.openstack.common import cfg from quantum.openstack.common import log as logging from quantum.plugins.common import constants from quantum.tests.unit import dummy_plugin diff --git a/quantum/tests/unit/test_quota_per_tenant_ext.py b/quantum/tests/unit/test_quota_per_tenant_ext.py index fa13b11a3f..321c184326 100644 --- a/quantum/tests/unit/test_quota_per_tenant_ext.py +++ b/quantum/tests/unit/test_quota_per_tenant_ext.py @@ -2,6 +2,7 @@ import unittest2 as unittest import webtest import mock +from oslo.config import cfg from quantum.api import extensions from quantum.api.v2 import attributes @@ -10,7 +11,6 @@ from quantum.common import exceptions from quantum import context from quantum.db import api as db from quantum import manager -from quantum.openstack.common import cfg from quantum.plugins.linuxbridge.db import l2network_db_v2 from quantum import quota from quantum.tests.unit import test_api_v2 diff --git a/quantum/tests/unit/test_security_groups_rpc.py b/quantum/tests/unit/test_security_groups_rpc.py index 34177ef3bc..f955ca9c61 100644 --- a/quantum/tests/unit/test_security_groups_rpc.py +++ b/quantum/tests/unit/test_security_groups_rpc.py @@ -21,6 +21,7 @@ from mock import call import unittest2 as unittest import mox +from oslo.config import cfg from quantum.agent import firewall as firewall_base from quantum.agent.linux import iptables_manager @@ -29,7 +30,6 @@ from quantum.agent import securitygroups_rpc as sg_rpc from quantum import context from quantum.db import securitygroups_rpc_base as sg_db_rpc from quantum.extensions import securitygroup as ext_sg -from quantum.openstack.common import cfg from quantum.openstack.common.rpc import proxy from quantum.tests.unit import test_extension_security_group as test_sg from quantum.tests.unit import test_iptables_firewall as test_fw diff --git a/quantum/tests/unit/test_servicetype.py b/quantum/tests/unit/test_servicetype.py index 78d7e28bec..bfac2c8b4e 100644 --- a/quantum/tests/unit/test_servicetype.py +++ b/quantum/tests/unit/test_servicetype.py @@ -22,6 +22,7 @@ import logging import unittest2 as unittest import mock +from oslo.config import cfg import webob.exc as webexc import webtest @@ -32,7 +33,6 @@ from quantum.db import api as db_api from quantum.db import servicetype_db from quantum.extensions import servicetype from quantum import manager -from quantum.openstack.common import cfg from quantum.plugins.common import constants from quantum.tests.unit import dummy_plugin as dp from quantum.tests.unit import test_api_v2 diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index 8dfc4cf012..38b413cd82 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, "quantum", sys.path.insert(0, possible_topdir) -from quantum.openstack.common import cfg +from oslo.config import cfg class InstallVenv(object): diff --git a/tools/pip-requires b/tools/pip-requires index ee1136de47..1f91e1ec17 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -16,6 +16,7 @@ sqlalchemy==0.7.9 WebOb>=1.2 python-keystoneclient>=0.2.0 alembic>=0.4.1 +http://tarballs.openstack.org/oslo-config/oslo-config-2013.1b3.tar.gz#egg=oslo-config # Cisco plugin dependencies python-novaclient diff --git a/tox.ini b/tox.ini index e3b17ecdb1..45261b2f0b 100644 --- a/tox.ini +++ b/tox.ini @@ -19,8 +19,6 @@ sitepackages = True downloadcache = ~/cache/pip [testenv:pep8] -deps = pep8 - setuptools_git>=0.4 commands = pep8 --repeat --show-source --ignore=E125 --exclude=.venv,.tox,dist,doc,openstack,*egg . pep8 --repeat --show-source --ignore=E125 --filename=quantum* bin