]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixing bug #798262
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Mon, 27 Jun 2011 13:09:52 +0000 (14:09 +0100)
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Mon, 27 Jun 2011 13:09:52 +0000 (14:09 +0100)
.project [new file with mode: 0644]
.pydevproject [new file with mode: 0644]
.pydevproject.moved [new file with mode: 0644]
bin/quantum.py [new file with mode: 0755]
pep8.errors [new file with mode: 0644]
quantum/api/api_common.py
quantum/api/networks.py
quantum/common/wsgi.py
tests/functional/test_service.py

diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..3a156e5
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>quantum-api</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.python.pydev.PyDevBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.python.pydev.pythonNature</nature>
+       </natures>
+</projectDescription>
diff --git a/.pydevproject b/.pydevproject
new file mode 100644 (file)
index 0000000..024d051
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/quantum-api</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/.pydevproject.moved b/.pydevproject.moved
new file mode 100644 (file)
index 0000000..024d051
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/quantum-api</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/bin/quantum.py b/bin/quantum.py
new file mode 100755 (executable)
index 0000000..48abd18
--- /dev/null
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2011 Nicira Neworks, 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.
+
+# If ../quantum/__init__.py exists, add ../ to Python search path, so that
+# it will override what happens to be installed in /usr/(local/)lib/python...
+
+import gettext
+import optparse
+import os
+import sys
+
+
+possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+                                   os.pardir,
+                                   os.pardir))
+if os.path.exists(os.path.join(possible_topdir, 'quantum', '__init__.py')):
+    sys.path.insert(0, possible_topdir)
+
+gettext.install('quantum', unicode=1)
+
+from quantum import service
+from quantum.common import config
+
+
+def create_options(parser):
+    """
+    Sets up the CLI and config-file options that may be
+    parsed and program commands.
+    :param parser: The option parser
+    """
+    config.add_common_options(parser)
+    config.add_log_options(parser)
+
+
+if __name__ == '__main__':
+    oparser = optparse.OptionParser(version='%%prog VERSION')
+    create_options(oparser)
+    (options, args) = config.parse_options(oparser)
+
+    try:
+        service = service.serve_wsgi(service.QuantumApiService,
+                                     options=options,
+                                     args=args)
+        service.wait()
+    except RuntimeError, e:
+        sys.exit("ERROR: %s" % e)
diff --git a/pep8.errors b/pep8.errors
new file mode 100644 (file)
index 0000000..5744ad9
--- /dev/null
@@ -0,0 +1,49 @@
+quantum/cli.py:39:43: W291 trailing whitespace
+quantum/cli.py:92:68: W291 trailing whitespace
+quantum/cli.py:95:62: W291 trailing whitespace
+quantum/cli.py:98:53: W291 trailing whitespace
+quantum/cli.py:110:1: W391 blank line at end of file
+quantum/manager.py:21:80: E501 line too long (94 characters)
+quantum/manager.py:37:22: E231 missing whitespace after ','
+quantum/service.py:91:39: E251 no spaces around keyword / parameter equals
+quantum/service.py:102:1: W293 blank line contains whitespace
+quantum/api/__init__.py:54:41: W291 trailing whitespace
+quantum/api/__init__.py:57:60: E251 no spaces around keyword / parameter equals
+quantum/api/faults.py:55:57: W291 trailing whitespace
+quantum/api/networks.py:81:48: E231 missing whitespace after ','
+quantum/common/exceptions.py:98:1: E302 expected 2 blank lines, found 1
+quantum/common/exceptions.py:103:1: E302 expected 2 blank lines, found 1
+quantum/plugins/SamplePlugin.py:137:30: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:139:47: E203 whitespace before ','
+quantum/plugins/SamplePlugin.py:184:1: W293 blank line contains whitespace
+quantum/plugins/SamplePlugin.py:255:38: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:258:38: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:255:21: E203 whitespace before ':'
+quantum/plugins/SamplePlugin.py:259:37: E231 missing whitespace after ':'
+quantum/plugins/SamplePlugin.py:263:38: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:266:38: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:269:21: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:263:21: E203 whitespace before ':'
+quantum/plugins/SamplePlugin.py:267:37: E231 missing whitespace after ':'
+quantum/plugins/SamplePlugin.py:280:46: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:272:29: E231 missing whitespace after ':'
+quantum/plugins/SamplePlugin.py:270:14: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:284:32: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:300:43: E231 missing whitespace after ','
+quantum/plugins/SamplePlugin.py:309:49: E251 no spaces around keyword / parameter equals
+quantum/plugins/SamplePlugin.py:318:30: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:338:19: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:341:31: E231 missing whitespace after ':'
+quantum/plugins/SamplePlugin.py:341:21: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:344:41: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:373:33: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:373:24: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:401:63: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:404:40: E225 missing whitespace around operator
+quantum/plugins/SamplePlugin.py:405:35: E231 missing whitespace after ':'
+quantum/plugins/SamplePlugin.py:409:29: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:419:20: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:432:46: E231 missing whitespace after ','
+quantum/plugins/SamplePlugin.py:436:25: W291 trailing whitespace
+quantum/plugins/SamplePlugin.py:459:46: E231 missing whitespace after ','
+quantum/plugins/SamplePlugin.py:482:80: E501 line too long (99 characters)
index df8608df3b3158102fe12130646af55ad43d9d8b..4e01e55bf74c3ff74b37328457f35730c3572993 100644 (file)
@@ -58,8 +58,7 @@ class QuantumController(wsgi.Controller):
                         pass
                 if not param_value and param['required']:
                     msg = ("Failed to parse request. " +
-                           "Parameter: %(param_name)s " +
-                           "not specified" % locals())
+                           "Parameter: " + param_name + " not specified")
                     for line in msg.split('\n'):
                         LOG.error(line)
                     raise exc.HTTPBadRequest(msg)
index bcaef0f9ff7cadcd974a9b5c7d26a0b6f6b35946..f9f5df4ed826f8461422d3bbcc4d8f2d7d374317 100644 (file)
@@ -48,17 +48,17 @@ class Controller(common.QuantumController):
     def index(self, request, tenant_id):
         """ Returns a list of network ids """
         #TODO: this should be for a given tenant!!!
-        return self._items(request, tenant_id, net_detail=False)
+        return self._items(request, tenant_id)
 
     def _item(self, req, tenant_id, network_id,
-              net_details, port_details):
+              net_details=True, port_details=False):
         network = self.network_manager.get_network_details(
                             tenant_id, network_id)
         builder = networks_view.get_view_builder(req)
         result = builder.build(network, net_details, port_details)
         return dict(networks=result)
 
-    def _items(self, req, tenant_id, net_details, port_details):
+    def _items(self, req, tenant_id, net_details=False, port_details=False):
         """ Returns a list of networks. """
         networks = self.network_manager.get_all_networks(tenant_id)
         builder = networks_view.get_view_builder(req)
index b1d72c469925056a121fd8ada0921191c09fb4e0..dc4ee1c8f2cd8f40d7b368da3b7aee6e1c9882b2 100644 (file)
 Utility methods for working with WSGI servers
 """
 
-import json
 import logging
 import sys
-import datetime
 
 from xml.dom import minidom
 
-import eventlet
 import eventlet.wsgi
 eventlet.patcher.monkey_patch(all=False, socket=True)
-import routes
 import routes.middleware
 import webob.dec
 import webob.exc
@@ -423,6 +419,7 @@ class Serializer(object):
         The string must be in the format of a supported MIME type.
 
         """
+        LOG.debug("Deserialize invoked:%s", datastring)
         return self.get_deserialize_handler(content_type)(datastring)
 
     def get_deserialize_handler(self, content_type):
@@ -455,7 +452,8 @@ class Serializer(object):
         if len(node.childNodes) == 1 and node.childNodes[0].nodeType == 3:
             return node.childNodes[0].nodeValue
         elif node.nodeName in listnames:
-            return [self._from_xml_node(n, listnames) for n in node.childNodes]
+            return [self._from_xml_node(n, listnames)
+                    for n in node.childNodes if n.nodeType != node.TEXT_NODE]
         else:
             result = dict()
             for attr in node.attributes.keys():
index 6ed728394a993457eba14ca8ca78d14d94dd03f1..29d23cf3fd7f6b1409187e6efa1d71cabdcd55cf 100644 (file)
@@ -49,7 +49,8 @@ def print_response(res):
 class QuantumTest(unittest.TestCase):
     def setUp(self):
         self.client = MiniClient(HOST, PORT, USE_SSL)
-
+        
+    
     def create_network(self, data):
         content_type = "application/" + FORMAT
         body = Serializer().serialize(data, content_type)
@@ -128,7 +129,8 @@ class QuantumTest(unittest.TestCase):
             self.assertEqual(res.status, 202)
 
     def tearDown(self):
-        self.delete_networks()
+        pass
+        #self.delete_networks()
 
 # Standard boilerplate to call the main() function.
 if __name__ == '__main__':