diff --git a/.project b/.project new file mode 100644 index 0000000000..3a156e5bd1 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + quantum-api + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000000..024d0515ec --- /dev/null +++ b/.pydevproject @@ -0,0 +1,10 @@ + + + + +python +python 2.7 + +/quantum-api + + diff --git a/.pydevproject.moved b/.pydevproject.moved new file mode 100644 index 0000000000..024d0515ec --- /dev/null +++ b/.pydevproject.moved @@ -0,0 +1,10 @@ + + + + +python +python 2.7 + +/quantum-api + + diff --git a/bin/quantum.py b/bin/quantum.py new file mode 100755 index 0000000000..48abd18ae9 --- /dev/null +++ b/bin/quantum.py @@ -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 index 0000000000..5744ad98e5 --- /dev/null +++ b/pep8.errors @@ -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) diff --git a/quantum/api/api_common.py b/quantum/api/api_common.py index df8608df3b..4e01e55bf7 100644 --- a/quantum/api/api_common.py +++ b/quantum/api/api_common.py @@ -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) diff --git a/quantum/api/networks.py b/quantum/api/networks.py index bcaef0f9ff..f9f5df4ed8 100644 --- a/quantum/api/networks.py +++ b/quantum/api/networks.py @@ -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) diff --git a/quantum/common/wsgi.py b/quantum/common/wsgi.py index b1d72c4699..dc4ee1c8f2 100644 --- a/quantum/common/wsgi.py +++ b/quantum/common/wsgi.py @@ -20,17 +20,13 @@ 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(): diff --git a/tests/functional/test_service.py b/tests/functional/test_service.py index 6ed728394a..29d23cf3fd 100644 --- a/tests/functional/test_service.py +++ b/tests/functional/test_service.py @@ -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__':