Merge lp:~santhoshkumar/network-service/melange_framework into lp:~rajarammallya/network-service/melange_framework

Proposed by Santhosh Kumar Muniraj
Status: Merged
Merged at revision: 40
Proposed branch: lp:~santhoshkumar/network-service/melange_framework
Merge into: lp:~rajarammallya/network-service/melange_framework
Diff against target: 249 lines (+74/-24)
7 files modified
etc/melange.conf.sample (+23/-3)
etc/melange.conf.test (+9/-7)
extensions/__init__.py (+15/-0)
melange/common/config.py (+1/-4)
melange/common/extensions.py (+7/-7)
tests/unit/test_extensions.py (+18/-3)
tools/pip-requires (+1/-0)
To merge this branch: bzr merge lp:~santhoshkumar/network-service/melange_framework
Reviewer Review Type Date Requested Status
Rajaram Mallya Pending
Review via email: mp+63957@code.launchpad.net

Description of the change

* Modified the way the extensions are loaded. Using Pipeline and Filter features of paste to load the extensions.

To post a comment you must log in.
39. By Rajaram Mallya

Rajaram/Vinkesh | Added API to delete IpBlocks. Changed the way limit, marker and marker_column is applied to any query. Now, db_api.find_all_by method does not add a limit filter to the query

40. By Rajaram Mallya

Vinkesh | Merged from santhosh branch. Fixed conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/melange.conf.sample'
2--- etc/melange.conf.sample 2011-06-02 12:26:41 +0000
3+++ etc/melange.conf.sample 2011-06-09 07:21:01 +0000
4@@ -5,14 +5,34 @@
5 # Show debugging output in logs (sets DEBUG log level output)
6 debug = False
7
8-[app:melange]
9-paste.app_factory = melange.ipam.service:app_factory
10-
11 # Address to bind the API server
12 bind_host = 0.0.0.0
13
14 # Port the bind the API server to
15 bind_port = 9292
16
17+# SQLAlchemy connection string for the reference implementation
18+# registry server. Any valid SQLAlchemy connection string is fine.
19+# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
20+sql_connection = sqlite:///melange_tests.sqlite
21+
22+# Period in seconds after which SQLAlchemy should reestablish its connection
23+# to the database.
24+#
25+# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
26+# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
27+# notice this, you can lower this value to ensure that SQLAlchemy reconnects
28+# before MySQL can drop the connection.
29+sql_idle_timeout = 3600
30+
31 # Path to the extensions
32 api_extensions_path = extensions
33+
34+[pipeline:melange]
35+pipeline = extensions melangeapp
36+
37+[filter:extensions]
38+paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
39+
40+[app:melangeapp]
41+paste.app_factory = melange.ipam.service:app_factory
42
43=== modified file 'etc/melange.conf.test'
44--- etc/melange.conf.test 2011-06-03 10:27:12 +0000
45+++ etc/melange.conf.test 2011-06-09 07:21:01 +0000
46@@ -5,8 +5,8 @@
47 # Show debugging output in logs (sets DEBUG log level output)
48 debug = False
49
50-[app:melange]
51-paste.app_factory = melange.ipam.service:app_factory
52+# Path to the extensions
53+api_extensions_path = extensions
54
55 # Address to bind the API server
56 bind_host = 0.0.0.0
57@@ -28,12 +28,14 @@
58 # before MySQL can drop the connection.
59 sql_idle_timeout = 3600
60
61+[pipeline:extensions_app_with_filter]
62+pipeline = extensions extensions_test_app
63+
64+[filter:extensions]
65+paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
66
67 [app:extensions_test_app]
68 paste.app_factory = tests.unit.test_extensions:app_factory
69
70-# Path to the extensions
71-api_extensions_path = extensions
72-
73-[filter:extensions]
74-paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
75+[app:melange]
76+paste.app_factory = melange.ipam.service:app_factory
77
78=== added directory 'extensions'
79=== added file 'extensions/__init__.py'
80--- extensions/__init__.py 1970-01-01 00:00:00 +0000
81+++ extensions/__init__.py 2011-06-09 07:21:01 +0000
82@@ -0,0 +1,15 @@
83+# vim: tabstop=4 shiftwidth=4 softtabstop=4
84+
85+# Copyright 2011 OpenStack LLC
86+#
87+# Licensed under the Apache License, Version 2.0 (the "License"); you may
88+# not use this file except in compliance with the License. You may obtain
89+# a copy of the License at
90+#
91+# http://www.apache.org/licenses/LICENSE-2.0
92+#
93+# Unless required by applicable law or agreed to in writing, software
94+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
95+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
96+# License for the specific language governing permissions and limitations
97+# under the License.
98
99=== modified file 'melange/common/config.py'
100--- melange/common/config.py 2011-06-03 10:27:12 +0000
101+++ melange/common/config.py 2011-06-09 07:21:01 +0000
102@@ -203,6 +203,7 @@
103
104 # Handle standard directory search for glance.conf
105 config_file_dirs = [fix_path(os.getcwd()),
106+ fix_path(os.path.join(os.getcwd(), "etc")),
107 fix_path(os.path.join('~', '.melange')),
108 fix_path('~'),
109 '/etc/melange/',
110@@ -301,10 +302,6 @@
111 logger.debug("%(key)-30s %(value)s" % locals())
112 logger.debug("*" * 80)
113 app = deploy.loadapp("config:%s" % conf_file, name=app_name)
114- extension_manager = options.get('extension_manager')
115- app = extensions.ExtensionMiddleware(app, conf,
116- ext_mgr=extension_manager)
117-
118 except (LookupError, ImportError), e:
119 raise RuntimeError("Unable to load %(app_name)s from "
120 "configuration file %(conf_file)s."
121
122=== modified file 'melange/common/extensions.py'
123--- melange/common/extensions.py 2011-06-03 10:27:12 +0000
124+++ melange/common/extensions.py 2011-06-09 07:21:01 +0000
125@@ -185,7 +185,7 @@
126 def factory(cls, global_config, **local_config):
127 """Paste factory."""
128 def _factory(app):
129- return cls(app, **local_config)
130+ return cls(app, global_config, **local_config)
131 return _factory
132
133 def _action_ext_controllers(self, application, ext_mgr, mapper):
134@@ -291,7 +291,7 @@
135 class ExtensionManager(object):
136 """Load extensions from the configured extension path.
137
138- See nova/tests/api/openstack/extensions/foxinsocks/extension.py for an
139+ See melange/tests/unit/extensions/foxinsocks.py for an
140 example extension implementation.
141
142 """
143@@ -362,7 +362,7 @@
144
145 In addition, extensions are loaded from the 'contrib' directory.
146
147- See nova/tests/api/openstack/extensions/foxinsocks.py for an example
148+ See melange/tests/unit/extensions/foxinsocks.py for an example
149 extension implementation.
150
151 """
152@@ -405,10 +405,10 @@
153
154
155 class RequestExtension(object):
156- """Extend requests and responses of core nova OpenStack API controllers.
157+ """Extend requests and responses of core melange OpenStack API controllers.
158
159 Provide a way to add data to responses and handle custom request data
160- that is sent to core nova OpenStack API controllers.
161+ that is sent to core melange OpenStack API controllers.
162
163 """
164 def __init__(self, method, url_route, handler):
165@@ -419,7 +419,7 @@
166
167
168 class ActionExtension(object):
169- """Add custom actions to core nova OpenStack API controllers."""
170+ """Add custom actions to core melange OpenStack API controllers."""
171
172 def __init__(self, collection, action_name, handler):
173 self.collection = collection
174@@ -428,7 +428,7 @@
175
176
177 class ResourceExtension(object):
178- """Add top level resources to the OpenStack API in nova."""
179+ """Add top level resources to the OpenStack API in melange."""
180
181 def __init__(self, collection, controller, parent=None,
182 collection_actions={}, member_actions={}):
183
184=== modified file 'tests/unit/test_extensions.py'
185--- tests/unit/test_extensions.py 2011-06-03 10:27:12 +0000
186+++ tests/unit/test_extensions.py 2011-06-09 07:21:01 +0000
187@@ -26,6 +26,9 @@
188
189
190 response_body = "Try to say this Mr. Knox, sir..."
191+conf_file = os.path.join(os.path.dirname(__file__),
192+ os.pardir, os.pardir,
193+ "etc", "melange.conf.test")
194
195
196 class ExtensionControllerTest(unittest.TestCase):
197@@ -108,7 +111,7 @@
198 self.assertEqual(404, response.status_int)
199
200
201-class RequestExtensionTest(BaseTest):
202+class RequestExtensionTest(unittest.TestCase):
203
204 def test_get_resources_with_stub_mgr(self):
205
206@@ -146,6 +149,17 @@
207 self.assertEqual("Pig Bands!", response_data['big_bands'])
208
209
210+class TestExtensionMiddlewareFactory(unittest.TestCase):
211+
212+ def test_app_configured_with_extensions_as_filter(self):
213+ conf, melange_app = config.load_paste_app('extensions_app_with_filter',
214+ {"config_file": conf_file},
215+ None)
216+
217+ response = TestApp(melange_app).get("/extensions")
218+ self.assertEqual(response.status_int, 200)
219+
220+
221 class ExtensionsTestApp(wsgi.Router):
222
223 def __init__(self, options={}):
224@@ -175,10 +189,11 @@
225
226
227 def setup_extensions_test_app(extension_manager=None):
228- options = {'config_file': os.path.abspath("../../etc/melange.conf.test"),
229+ options = {'config_file': conf_file,
230 'extension_manager': extension_manager}
231 conf, app = config.load_paste_app('extensions_test_app', options, None)
232- return TestApp(app)
233+ extended_app = extensions.ExtensionMiddleware(app, conf, extension_manager)
234+ return TestApp(extended_app)
235
236
237 class StubExtensionManager(object):
238
239=== modified file 'tools/pip-requires'
240--- tools/pip-requires 2011-06-07 06:26:52 +0000
241+++ tools/pip-requires 2011-06-09 07:21:01 +0000
242@@ -2,6 +2,7 @@
243 pep8==0.5.0
244 eventlet>=0.9.12
245 PasteDeploy
246+Paste
247 routes
248 webob
249 webtest

Subscribers

People subscribed via source and target branches