delete falcon transport

Change-Id: I4f6d62feae10b025e2a6af72016ee235e01d6995
This commit is contained in:
tonytan4ever 2014-08-14 17:48:33 -04:00
parent 9fb747c181
commit 2ed6c94b43
8 changed files with 1 additions and 247 deletions

View File

@ -1,6 +0,0 @@
"""Falcon Transport Driver"""
from poppy.transport.falcon import driver
# Hoist into package namespace
Driver = driver.TransportDriver

View File

@ -1,36 +0,0 @@
# Copyright (c) 2013 Rackspace, Inc.
#
# 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.
"""WSGI App for WSGI Containers
This app should be used by external WSGI
containers. For example:
$ gunicorn poppy.transport.falcon.app:app
NOTE: As for external containers, it is necessary
to put config files in the standard paths. There's
no common way to specify / pass configuration files
to the WSGI app when it is called from other apps.
"""
from oslo.config import cfg
from poppy import bootstrap
conf = cfg.CONF
conf(project='poppy', prog='poppy', args=[])
app = bootstrap.Bootstrap(conf).transport.app

View File

@ -1,84 +0,0 @@
# Copyright (c) 2013 Rackspace, Inc.
#
# 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.
import abc
from wsgiref import simple_server
import falcon
from oslo.config import cfg
import six
import poppy.openstack.common.log as logging
from poppy import transport
from poppy.transport.falcon import services
from poppy.transport.falcon import v1
_WSGI_OPTIONS = [
cfg.StrOpt('bind', default='127.0.0.1',
help='Address on which the self-hosting server will listen'),
cfg.IntOpt('port', default=8888,
help='Port on which the self-hosting server will listen'),
]
_WSGI_GROUP = 'drivers:transport:falcon'
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class TransportDriver(transport.Driver):
def __init__(self, conf, manager):
super(TransportDriver, self).__init__(conf, manager)
self._conf.register_opts(_WSGI_OPTIONS, group=_WSGI_GROUP)
self._wsgi_conf = self._conf[_WSGI_GROUP]
self._setup_app()
def _setup_app(self):
"""Initialize hooks and URI routes to resources."""
self._app = falcon.API()
version_path = "/v1.0"
project_id = "/{project_id}"
prefix = version_path + project_id
# init the controllers
service_controller = self.manager.services_controller
# setup the routes
self._app.add_route(prefix,
v1.V1Resource())
self._app.add_route(prefix + '/services',
services.ServicesResource(service_controller))
self._app.add_route(prefix + '/services/{service_name}',
services.ServiceResource(service_controller))
def listen(self):
"""Self-host using 'bind' and 'port' from the WSGI config group."""
msgtmpl = (u'Serving on host %(bind)s:%(port)s')
LOG.info(msgtmpl,
{'bind': self._wsgi_conf.bind, 'port': self._wsgi_conf.port})
httpd = simple_server.make_server(self._wsgi_conf.bind,
self._wsgi_conf.port,
self.app)
httpd.serve_forever()

View File

@ -1,67 +0,0 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# 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.
import json
import falcon
class ServicesResource:
def __init__(self, services_controller):
self.services_controller = services_controller
def on_get(self, req, resp, project_id):
"""Handles GET requests."""
services = self.services_controller.list(project_id)
resp.status = falcon.HTTP_200
resp.body = json.dumps(services)
class ServiceResource:
def __init__(self, service_controller):
self.service_controller = service_controller
def on_get(self, req, resp, project_id, service_name):
"""Handles GET requests."""
service = self.service_controller.get(project_id, service_name)
resp.status = falcon.HTTP_200
resp.body = json.dumps(service)
def on_put(self, req, resp, project_id, service_name):
"""Handles PUT requests."""
service_json = json.loads(req.stream.read(req.content_length))
service = self.service_controller.create(project_id,
service_name,
service_json)
resp.status = falcon.HTTP_200
resp.body = json.dumps(service)
def on_patch(self, req, resp, project_id, service_name):
"""Handles PATCH requests."""
service = self.service_controller.update(project_id, service_name)
resp.status = falcon.HTTP_200
resp.body = json.dumps(service)
def on_delete(self, req, resp, project_id, service_name):
"""Handles DELETE requests."""
service = self.service_controller.delete(project_id, service_name)
resp.status = falcon.HTTP_204
resp.body = json.dumps(service)

View File

@ -1,52 +0,0 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# 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.
import json
# NOTE(amitgandhinz): http://tools.ietf.org/html/draft-nottingham-json-home-03
JSON_HOME = {
"resources": {
"rel/poppy": {
"href-template": "services{?marker,limit}",
"href-vars": {
"marker": "param/marker",
"limit": "param/limit"
},
"hints": {
"allow": [
"GET"
],
"formats": {
"application/json": {}
}
}
}
}
}
class V1Resource(object):
def __init__(self):
document = json.dumps(JSON_HOME, ensure_ascii=False, indent=4)
self.document_utf8 = document.encode('utf-8')
def on_get(self, req, resp, project_id):
resp.data = self.document_utf8
resp.content_type = 'application/json-home'
resp.cache_control = ['max-age=86400']
# status defaults to 200

View File

@ -20,7 +20,7 @@ import json
try:
import falcon
except ImportError:
import fake_falcon as falcon
from poppy.transport.validators import fake_falcon as falcon
import jsonschema
import pecan

View File

@ -1 +0,0 @@
falcon>=0.1.6,<0.1.7