summaryrefslogtreecommitdiffstats
path: root/echo
diff options
context:
space:
mode:
authorJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 05:46:28 -0500
committerJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 05:46:28 -0500
commita3bde4e19f9867f7d297f80b7792a291e69a4f50 (patch)
tree1ab681c3e96f777bb5fe5fb0ad10a5dd3bd53b63 /echo
parentfbdcd8455e2db358c9fddb0b64c7c8ee8a2013ee (diff)
downloadkeystone-a3bde4e19f9867f7d297f80b7792a291e69a4f50.tar.gz
keystone-a3bde4e19f9867f7d297f80b7792a291e69a4f50.tar.xz
keystone-a3bde4e19f9867f7d297f80b7792a291e69a4f50.zip
Initial echo service.
Diffstat (limited to 'echo')
-rw-r--r--echo/echo.py54
-rw-r--r--echo/samples/echo.json11
-rw-r--r--echo/samples/echo.xml8
3 files changed, 73 insertions, 0 deletions
diff --git a/echo/echo.py b/echo/echo.py
new file mode 100644
index 00000000..c3fba48a
--- /dev/null
+++ b/echo/echo.py
@@ -0,0 +1,54 @@
+# Copyright (c) 2010-2011 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.
+
+from eventlet import wsgi
+from lxml import etree
+import simplejson as json
+import eventlet
+
+class EchoApp:
+ def __init__(self, environ, start_response):
+ self.environ = environ
+ self.start = start_response
+ self.method = environ["REQUEST_METHOD"]
+ self.pathInfo = environ["PATH_INFO"]
+ self.queryString = environ["QUERY_STRING"]
+ self.contentType = environ["CONTENT_TYPE"]
+ self.content = ""
+
+ inReq = environ["wsgi.input"]
+ for line in inReq:
+ self.content = self.content + line
+
+ def __iter__(self):
+ return self.toXML()
+
+ def toJSON(self):
+ self.start('200 OK', [('Content-Type', 'application/json')])
+ yield "{'echo' : {}}"
+
+ def toXML(self):
+ echo = etree.Element("{http://docs.openstack.org/echo/api/v1.0}echo",
+ method=self.method,
+ pathInfo=self.pathInfo,
+ queryString=self.queryString)
+ content = etree.Element("{http://docs.openstack.org/echo/api/v1.0}content")
+ content.set ("type", self.contentType)
+ content.text = self.content
+ echo.append (content)
+ self.start('200 OK', [('Content-Type', 'application/xml')])
+ yield etree.tostring (echo, pretty_print=True)
+
+wsgi.server(eventlet.listen(('', 8090)), EchoApp)
diff --git a/echo/samples/echo.json b/echo/samples/echo.json
new file mode 100644
index 00000000..61a8847a
--- /dev/null
+++ b/echo/samples/echo.json
@@ -0,0 +1,11 @@
+{
+ "echo" : {
+ "method" : "GET",
+ "pathInfo" : "/bla/bla",
+ "queryString" : "hello=true",
+ "content" : {
+ "type" : "application/xml",
+ "value" : "This is some content."
+ }
+ }
+}
diff --git a/echo/samples/echo.xml b/echo/samples/echo.xml
new file mode 100644
index 00000000..8cf4b984
--- /dev/null
+++ b/echo/samples/echo.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<echo xmlns="http://docs.openstack.org/echo/api/v1.0"
+ method="GET" pathInfo="/bla/bla" queryString="hello">
+ <content type="application/xml">
+ This is some content.
+ </content>
+</echo>