From d4a9d2c04664a76b8227491556c06f25a0aa3a97 Mon Sep 17 00:00:00 2001 From: Aradhana Singh Date: Mon, 25 Jul 2016 02:06:04 +0000 Subject: [PATCH] Refactoring config options of agent/common/ovs_lib Refactoring oslo config options for agent/common/ovs_lib in neutron/conf/agent/ovs_conf. This would allow centralization of all configuration options and provides easy way to import. Change-Id: If833a52efc0da406d0ee24fcc5dd4e05898aa094 --- neutron/agent/common/ovs_lib.py | 13 ++----------- neutron/agent/ovsdb/impl_idl.py | 2 +- neutron/conf/agent/ovs_conf.py | 33 +++++++++++++++++++++++++++++++++ neutron/opts.py | 4 ++-- 4 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 neutron/conf/agent/ovs_conf.py diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index 6939fa1d84c..c837b2f3e8b 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -30,15 +30,13 @@ from neutron._i18n import _, _LE, _LI, _LW from neutron.agent.common import utils from neutron.agent.linux import ip_lib from neutron.agent.ovsdb import api as ovsdb +from neutron.conf.agent import ovs_conf from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import constants UINT64_BITMASK = (1 << 64) - 1 -# Default timeout for ovs-vsctl command -DEFAULT_OVS_VSCTL_TIMEOUT = 10 - # Special return value for an invalid OVS ofport INVALID_OFPORT = -1 UNASSIGNED_OFPORT = [] @@ -47,14 +45,7 @@ UNASSIGNED_OFPORT = [] FAILMODE_SECURE = 'secure' FAILMODE_STANDALONE = 'standalone' -OPTS = [ - cfg.IntOpt('ovs_vsctl_timeout', - default=DEFAULT_OVS_VSCTL_TIMEOUT, - help=_('Timeout in seconds for ovs-vsctl commands. ' - 'If the timeout expires, ovs commands will fail with ' - 'ALARMCLOCK error.')), -] -cfg.CONF.register_opts(OPTS) +ovs_conf.register_ovs_agent_opts() LOG = logging.getLogger(__name__) diff --git a/neutron/agent/ovsdb/impl_idl.py b/neutron/agent/ovsdb/impl_idl.py index 9cc93a6fd4f..8e237302b4b 100644 --- a/neutron/agent/ovsdb/impl_idl.py +++ b/neutron/agent/ovsdb/impl_idl.py @@ -28,7 +28,7 @@ from neutron.agent.ovsdb.native import connection from neutron.agent.ovsdb.native import idlutils -cfg.CONF.import_opt('ovs_vsctl_timeout', 'neutron.agent.common.ovs_lib') +cfg.CONF.import_opt('ovs_vsctl_timeout', 'neutron.conf.agent.ovs_conf') LOG = logging.getLogger(__name__) diff --git a/neutron/conf/agent/ovs_conf.py b/neutron/conf/agent/ovs_conf.py new file mode 100644 index 00000000000..85a5ab6549b --- /dev/null +++ b/neutron/conf/agent/ovs_conf.py @@ -0,0 +1,33 @@ +# Copyright 2011 VMware, Inc. +# All Rights Reserved. +# +# 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. + +from oslo_config import cfg + +from neutron._i18n import _ + +# Default timeout for ovs-vsctl command +DEFAULT_OVS_VSCTL_TIMEOUT = 10 + +OPTS = [ + cfg.IntOpt('ovs_vsctl_timeout', + default=DEFAULT_OVS_VSCTL_TIMEOUT, + help=_('Timeout in seconds for ovs-vsctl commands. ' + 'If the timeout expires, ovs commands will fail with ' + 'ALARMCLOCK error.')), +] + + +def register_ovs_agent_opts(cfg=cfg.CONF): + cfg.register_opts(OPTS) diff --git a/neutron/opts.py b/neutron/opts.py index 6489e1c97f3..9847072bde0 100644 --- a/neutron/opts.py +++ b/neutron/opts.py @@ -19,7 +19,6 @@ from oslo_config import cfg import neutron.agent.agent_extensions_manager import neutron.agent.common.config -import neutron.agent.common.ovs_lib import neutron.agent.l3.config import neutron.agent.l3.ha import neutron.agent.linux.interface @@ -31,6 +30,7 @@ import neutron.agent.securitygroups_rpc import neutron.common.cache_utils import neutron.conf.agent.dhcp import neutron.conf.agent.l3.config +import neutron.conf.agent.ovs_conf import neutron.conf.common import neutron.conf.quota import neutron.conf.service @@ -157,7 +157,7 @@ def list_base_agent_opts(): itertools.chain( neutron.agent.linux.interface.OPTS, neutron.agent.common.config.INTERFACE_DRIVER_OPTS, - neutron.agent.common.ovs_lib.OPTS) + neutron.conf.agent.ovs_conf.OPTS) ), ('AGENT', itertools.chain(