summaryrefslogtreecommitdiffstats
path: root/echo
diff options
context:
space:
mode:
authorKhaled Hussein <khaled.hussein@gmail.com>2011-04-18 18:39:38 +0000
committerKhaled Hussein <khaled.hussein@gmail.com>2011-04-18 18:39:38 +0000
commit6bb28b0d44a444f766b5cfb446e07c3407a99aab (patch)
treec644c4f7c0eece16d5b81caf6f6173ef0c50eea3 /echo
parentb124c4d1478952c7d3fc0890cc78db67f6824631 (diff)
Setup PasteDeploy and configured PAPIAuth.
Diffstat (limited to 'echo')
-rw-r--r--echo/echo/__init__.py0
-rw-r--r--echo/echo/echo.ini23
-rw-r--r--echo/echo/echo.py48
-rw-r--r--echo/setup.py41
4 files changed, 79 insertions, 33 deletions
diff --git a/echo/echo/__init__.py b/echo/echo/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/echo/echo/__init__.py
diff --git a/echo/echo/echo.ini b/echo/echo/echo.ini
index 3446aa8d..0d38c6e7 100644
--- a/echo/echo/echo.ini
+++ b/echo/echo/echo.ini
@@ -1,7 +1,20 @@
-
-[composite:main]
-use = egg:Paste#urlmap
-/ = echo
+[DEFAULT]
[app:echo]
-use egg:echo
+use = egg:echo
+#use = egg:Paste#urlmap
+#/ = echo
+
+[pipeline:main]
+pipeline = papiauth echo
+
+[filter:papiauth]
+use = egg:keystone#papiauth
+ip = 127.0.0.1
+port = 1234
+pass = dTpw
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 8090
diff --git a/echo/echo/echo.py b/echo/echo/echo.py
index 5cb4b2b7..efe24445 100644
--- a/echo/echo/echo.py
+++ b/echo/echo/echo.py
@@ -25,7 +25,6 @@ import urllib
from httplib2 import Http
-
class EchoApp:
def __init__(self, environ, start_response):
@@ -37,35 +36,25 @@ class EchoApp:
def __iter__(self):
accept = self.envr.get("HTTP_ACCEPT","application/json")
if accept == "application/xml":
-
return self.toXML()
else:
return self.toJSON()
def toJSON(self):
-
self.start('200 OK', [('Content-Type', 'application/json')])
token = str(self.envr.get("HTTP_X_AUTH_TOKEN",""))
if token !='':
-
res=self.ValidateToken({'type':'json','token':token})
-
if int(res['response']['status'])==200 :
-
yield str(res['content'])
else:
pass
# Need to Do Something Here
else:
-
yield str(self.transform(self.dom))
-
-
-
def toXML(self):
-
self.start('200 OK', [('Content-Type', 'application/xml')])
yield etree.tostring (self.dom)
@@ -74,7 +63,8 @@ class EchoApp:
method=environ["REQUEST_METHOD"],
pathInfo=environ["PATH_INFO"],
queryString=environ.get('QUERY_STRING', ""))
- content = etree.Element("{http://docs.openstack.org/echo/api/v1.0}content")
+ content = etree.Element(
+ "{http://docs.openstack.org/echo/api/v1.0}content")
content.set ("type", environ["CONTENT_TYPE"])
content.text = ""
inReq = environ["wsgi.input"]
@@ -83,22 +73,24 @@ class EchoApp:
echo.append (content)
return echo
-
- def ValidateToken(self,params):
-
-
- if params['token']:
-
- http=Http()
-
- url = "http://localhost:8080/token/"+str(params['token'])
- body = {}
- headers = {"Accept" : "application/json", "Content-Type": "application/json"}
- response, content = http.request(url, 'GET', headers=headers, body=urllib.urlencode(body))
- return {'response':response,'content':content}
- else:
- return abort(401, "No Token Found!")
+
+ #def ValidateToken(self,params):
+ # if params['token']:
+ # http=Http()
+ # url = "http://localhost:8080/token/"+str(params['token'])
+ # body = {}
+ # headers = {
+ # "Accept" : "application/json",
+ # "Content-Type": "application/json"}
+ # response, content = http.request(url, 'GET', headers=headers,
+ # body=urllib.urlencode(body))
+ # return {'response':response,'content':content}
+ # else:
+ # return abort(401, "No Token Found!")
-wsgi.server(eventlet.listen(('127.0.0.1', 8090)), EchoApp)
+def app_factory (global_conf, **local_conf):
+ return EchoApp
+
+#wsgi.server(eventlet.listen(('127.0.0.1', 8090)), EchoApp)
#wsgi.server(eventlet.listen(('', 8090)), loadapp("config:echo.ini", relative_to="."))
diff --git a/echo/setup.py b/echo/setup.py
new file mode 100644
index 00000000..4aaca425
--- /dev/null
+++ b/echo/setup.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+# 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 setuptools import setup, find_packages
+
+version = '1.0'
+
+setup(
+ name='echo',
+ version=version,
+ description="",
+ license='Apache License (2.0)',
+ classifiers=[ "Programming Language :: Python", ],
+ keywords='',
+ author='OpenStack, LLC.',
+ author_email='none of your beeswax@somehost.com',
+ url='http://lionfacelemonface.wordpress.com',
+ include_package_data=True,
+ packages=find_packages(exclude=['test', 'bin']),
+ zip_safe=False,
+ install_requires=['setuptools', 'keystone'],
+ entry_points={
+ 'paste.app_factory': ['main=echo.echo:app_factory'],
+ 'paste.filter_factory': [
+ 'papiauth=keystone.middleware.papiauth:filter_factory',
+ ],
+ },
+ )