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 quantum.common import wsgi
21
from quantum.common import extensions
22
from abc import abstractmethod
25
class FoxInSocksController(wsgi.Controller):
27
def index(self, request):
28
return "Try to say this Mr. Knox, sir..."
31
class FoxInSocksPluginInterface(extensions.PluginInterface):
34
def method_to_support_foxnsox_extension(self):
38
class Foxinsocks(object):
43
def get_plugin_interface(self):
44
return FoxInSocksPluginInterface
52
def get_description(self):
53
return "The Fox In Socks Extension"
55
def get_namespace(self):
56
return "http://www.fox.in.socks/api/ext/pie/v1.0"
58
def get_updated(self):
59
return "2011-01-22T13:25:27-06:00"
61
def get_resources(self):
63
resource = extensions.ResourceExtension('foxnsocks',
64
FoxInSocksController())
65
resources.append(resource)
68
def get_actions(self):
69
return [extensions.ActionExtension('dummy_resources',
70
'FOXNSOX:add_tweedle',
71
self._add_tweedle_handler),
72
extensions.ActionExtension('dummy_resources',
73
'FOXNSOX:delete_tweedle',
74
self._delete_tweedle_handler)]
76
def get_request_extensions(self):
79
def _goose_handler(req, res):
80
#NOTE: This only handles JSON responses.
81
# You can use content type header to test for XML.
82
data = json.loads(res.body)
83
data['FOXNSOX:googoose'] = req.GET.get('chewing')
84
res.body = json.dumps(data)
87
req_ext1 = extensions.RequestExtension('GET', '/dummy_resources/:(id)',
89
request_exts.append(req_ext1)
91
def _bands_handler(req, res):
92
#NOTE: This only handles JSON responses.
93
# You can use content type header to test for XML.
94
data = json.loads(res.body)
95
data['FOXNSOX:big_bands'] = 'Pig Bands!'
96
res.body = json.dumps(data)
99
req_ext2 = extensions.RequestExtension('GET', '/dummy_resources/:(id)',
101
request_exts.append(req_ext2)
104
def _add_tweedle_handler(self, input_dict, req, id):
105
return "Tweedle {0} Added.".format(
106
input_dict['FOXNSOX:add_tweedle']['name'])
108
def _delete_tweedle_handler(self, input_dict, req, id):
109
return "Tweedle {0} Deleted.".format(
110
input_dict['FOXNSOX:delete_tweedle']['name'])