1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2011 OpenStack LLC.
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
20
from nova.api.openstack import extensions
21
from nova.api.openstack import wsgi
24
class FoxInSocksController(object):
27
return "Try to say this Mr. Knox, sir..."
30
class FoxInSocksServerControllerExtension(wsgi.Controller):
31
@wsgi.action('add_tweedle')
32
def _add_tweedle(self, req, id, body):
34
return "Tweedle Beetle Added."
36
@wsgi.action('delete_tweedle')
37
def _delete_tweedle(self, req, id, body):
39
return "Tweedle Beetle Deleted."
42
def _fail(self, req, id, body):
44
raise webob.exc.HTTPBadRequest(explanation='Tweedle fail')
47
class FoxInSocksFlavorGooseControllerExtension(wsgi.Controller):
49
def show(self, req, resp_obj, id):
50
#NOTE: This only handles JSON responses.
51
# You can use content type header to test for XML.
52
resp_obj.obj['flavor']['googoose'] = req.GET.get('chewing')
55
class FoxInSocksFlavorBandsControllerExtension(wsgi.Controller):
57
def show(self, req, resp_obj, id):
58
#NOTE: This only handles JSON responses.
59
# You can use content type header to test for XML.
60
resp_obj.obj['big_bands'] = 'Pig Bands!'
63
class Foxinsocks(extensions.ExtensionDescriptor):
64
"""The Fox In Socks Extension"""
68
namespace = "http://www.fox.in.socks/api/ext/pie/v1.0"
69
updated = "2011-01-22T13:25:27-06:00"
71
def __init__(self, ext_mgr):
72
ext_mgr.register(self)
74
def get_resources(self):
76
resource = extensions.ResourceExtension('foxnsocks',
77
FoxInSocksController())
78
resources.append(resource)
81
def get_controller_extensions(self):
85
(FoxInSocksServerControllerExtension, 'servers'),
86
(FoxInSocksFlavorGooseControllerExtension, 'flavors'),
87
(FoxInSocksFlavorBandsControllerExtension, 'flavors'),
89
for klass, collection in extension_set:
91
ext = extensions.ControllerExtension(self, collection, controller)
92
extension_list.append(ext)