]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Reqd. core_plugin for plugin agents & show cfg opts loaded.
authorPaul Michali <pcm@cisco.com>
Thu, 24 Jan 2013 13:13:18 +0000 (08:13 -0500)
committerPaul Michali <pcm@cisco.com>
Fri, 25 Jan 2013 19:31:26 +0000 (14:31 -0500)
For the linuxbridge, openvswitch, nec, and ryu plugin agents,
require the core_plugin configuration option, and throw an
exception, if not present. Note: cannot make this a required
option for all agents, as there are agent that include the
core config options, but do not require core_plugin.

In addition, log (as debug) the configuration options that
have been loaded at start-up for these four agents. This will
help with diagnosing start-up issues related to the
configuraiton settings (or lack of).

Tested that exception thrown, when missing core_plugin
value in config file(s) included, for these four agents.

bug 1059923
Change-Id: I813f0c2a3d0ec01be74a34e56ab085979197a16a

quantum/agent/common/validate.py [new file with mode: 0644]
quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py
quantum/plugins/nec/agent/nec_quantum_agent.py
quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
quantum/plugins/ryu/agent/ryu_quantum_agent.py
quantum/tests/unit/test_agent_config.py

diff --git a/quantum/agent/common/validate.py b/quantum/agent/common/validate.py
new file mode 100644 (file)
index 0000000..763f842
--- /dev/null
@@ -0,0 +1,28 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+# Copyright 2013 Cisco Systems, 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.
+# @author: Paul Michali, Cisco Systems, Inc.
+
+
+def core_config_options(options):
+    '''Validate core configuration options.
+
+    Make sure that core configuration options that are needed are present and,
+    if not, generate warnings/errors, based on the severity. Will be used
+    only by the agents that require the option(s).
+    '''
+
+    if options.core_plugin is None:
+        raise Exception(_('Quantum core_plugin not configured!'))
index 56d11ccfd2af2ce56554912daf6edb42dc28402b..64ccaaeaf4168b4b2171bb23815ecb186aab4188 100755 (executable)
@@ -27,12 +27,14 @@ import sys
 import time
 
 import eventlet
+import logging as std_logging
 import pyudev
 
 from quantum.agent.linux import ip_lib
 from quantum.agent.linux import utils
 from quantum.agent import rpc as agent_rpc
 from quantum.agent import securitygroups_rpc as sg_rpc
+from quantum.agent.common import validate
 from quantum.common import config as logging_config
 from quantum.common import topics
 from quantum.common import utils as q_utils
@@ -602,6 +604,10 @@ def main():
     cfg.CONF(project='quantum')
 
     logging_config.setup_logging(cfg.CONF)
+
+    cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
+    validate.core_config_options(cfg.CONF)
+
     try:
         interface_mappings = q_utils.parse_mappings(
             cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
index 8c8786b4e204e645cf68a653ae7f3a5f7a4107fd..5dc306e9b8291290806a6d7d09b7ecae491ee0ec 100755 (executable)
@@ -24,7 +24,9 @@
 import socket
 import sys
 import time
+import logging as std_logging
 
+from quantum.agent.common import validate
 from quantum.agent.linux import ovs_lib
 from quantum.common import config as logging_config
 from quantum.common import topics
@@ -112,6 +114,9 @@ def main():
 
     logging_config.setup_logging(config.CONF)
 
+    config.CONF.log_opt_values(LOG, std_logging.DEBUG)
+    validate.core_config_options(config.CONF)
+
     # Determine which agent type to use.
     integ_br = config.OVS.integration_bridge
     root_helper = config.AGENT.root_helper
index 042aac5b4db43a20c0fdc95285d1588e7eece03e..301c1b8275fcaa93a14d5b3b993459c00e6331e4 100755 (executable)
@@ -24,7 +24,9 @@ import sys
 import time
 
 import eventlet
+import logging as std_logging
 
+from quantum.agent.common import validate
 from quantum.agent.linux import ip_lib
 from quantum.agent.linux import ovs_lib
 from quantum.agent.linux import utils
@@ -690,6 +692,9 @@ def main():
     cfg.CONF(project='quantum')
     logging_config.setup_logging(cfg.CONF)
 
+    cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
+    validate.core_config_options(cfg.CONF)
+
     try:
         agent_config = create_agent_config_map(cfg.CONF)
     except ValueError as e:
index e20dba9ca169adca2bce746a6bec720fbe2b2cb4..bc6e5df04a1e56aef11514dbb3494746f0d9bfcd 100755 (executable)
@@ -24,12 +24,14 @@ import httplib
 import socket
 import sys
 
+import logging as std_logging
 import netifaces
 from ryu.app import client
 from ryu.app import conf_switch_key
 from ryu.app import rest_nw_id
 from sqlalchemy.ext.sqlsoup import SqlSoup
 
+from quantum.agent.common import validate
 from quantum.agent.linux import ovs_lib
 from quantum.agent.linux.ovs_lib import VifPort
 from quantum.common import config as logging_config
@@ -210,6 +212,9 @@ def main():
 
     logging_config.setup_logging(cfg.CONF)
 
+    cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
+    validate.core_config_options(cfg.CONF)
+
     integ_br = cfg.CONF.OVS.integration_bridge
     root_helper = cfg.CONF.AGENT.root_helper
     options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
index 73e10ed01c38a3c8382b6568a9ce9648e594e29b..8c1e4398c7f5936dcaeb1712fa4f8f174458a9cd 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import unittest2 as unittest
+
 from quantum.agent.common import config
+from quantum.agent.common import validate
+from quantum.openstack.common import cfg
 
 
 def test_setup_conf():
     conf = config.setup_conf()
     assert conf.state_path.endswith('/var/lib/quantum')
+
+
+class TestCoreConfigOptions(unittest.TestCase):
+
+    def setUp(self):
+        self._saved_core_plugin = cfg.CONF.core_plugin
+
+    def tearDown(self):
+        cfg.CONF.set_override('core_plugin', self._saved_core_plugin)
+
+    def test_missing_required_core_option(self):
+        with self.assertRaises(Exception) as ex:
+            validate.core_config_options(cfg.CONF)
+
+    def test_have_required_core_option(self):
+        cfg.CONF.set_override('core_plugin', 'some_core_plugin_option')
+        validate.core_config_options(cfg.CONF)