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
=== modified file 'etc/melange.conf.sample'
--- etc/melange.conf.sample 2011-06-02 12:26:41 +0000
+++ etc/melange.conf.sample 2011-06-09 07:21:01 +0000
@@ -5,14 +5,34 @@
5# Show debugging output in logs (sets DEBUG log level output)5# Show debugging output in logs (sets DEBUG log level output)
6debug = False6debug = False
77
8[app:melange]
9paste.app_factory = melange.ipam.service:app_factory
10
11# Address to bind the API server8# Address to bind the API server
12bind_host = 0.0.0.09bind_host = 0.0.0.0
1310
14# Port the bind the API server to11# Port the bind the API server to
15bind_port = 929212bind_port = 9292
1613
14# SQLAlchemy connection string for the reference implementation
15# registry server. Any valid SQLAlchemy connection string is fine.
16# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
17sql_connection = sqlite:///melange_tests.sqlite
18
19# Period in seconds after which SQLAlchemy should reestablish its connection
20# to the database.
21#
22# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
23# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
24# notice this, you can lower this value to ensure that SQLAlchemy reconnects
25# before MySQL can drop the connection.
26sql_idle_timeout = 3600
27
17# Path to the extensions28# Path to the extensions
18api_extensions_path = extensions29api_extensions_path = extensions
30
31[pipeline:melange]
32pipeline = extensions melangeapp
33
34[filter:extensions]
35paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
36
37[app:melangeapp]
38paste.app_factory = melange.ipam.service:app_factory
1939
=== modified file 'etc/melange.conf.test'
--- etc/melange.conf.test 2011-06-03 10:27:12 +0000
+++ etc/melange.conf.test 2011-06-09 07:21:01 +0000
@@ -5,8 +5,8 @@
5# Show debugging output in logs (sets DEBUG log level output)5# Show debugging output in logs (sets DEBUG log level output)
6debug = False6debug = False
77
8[app:melange]8# Path to the extensions
9paste.app_factory = melange.ipam.service:app_factory9api_extensions_path = extensions
1010
11# Address to bind the API server11# Address to bind the API server
12bind_host = 0.0.0.012bind_host = 0.0.0.0
@@ -28,12 +28,14 @@
28# before MySQL can drop the connection.28# before MySQL can drop the connection.
29sql_idle_timeout = 360029sql_idle_timeout = 3600
3030
31[pipeline:extensions_app_with_filter]
32pipeline = extensions extensions_test_app
33
34[filter:extensions]
35paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
3136
32[app:extensions_test_app]37[app:extensions_test_app]
33paste.app_factory = tests.unit.test_extensions:app_factory38paste.app_factory = tests.unit.test_extensions:app_factory
3439
35# Path to the extensions40[app:melange]
36api_extensions_path = extensions41paste.app_factory = melange.ipam.service:app_factory
37
38[filter:extensions]
39paste.filter_factory = melange.common.extensions:ExtensionMiddleware.factory
4042
=== added directory 'extensions'
=== added file 'extensions/__init__.py'
--- extensions/__init__.py 1970-01-01 00:00:00 +0000
+++ extensions/__init__.py 2011-06-09 07:21:01 +0000
@@ -0,0 +1,15 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011 OpenStack LLC
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
016
=== modified file 'melange/common/config.py'
--- melange/common/config.py 2011-06-03 10:27:12 +0000
+++ melange/common/config.py 2011-06-09 07:21:01 +0000
@@ -203,6 +203,7 @@
203203
204 # Handle standard directory search for glance.conf204 # Handle standard directory search for glance.conf
205 config_file_dirs = [fix_path(os.getcwd()),205 config_file_dirs = [fix_path(os.getcwd()),
206 fix_path(os.path.join(os.getcwd(), "etc")),
206 fix_path(os.path.join('~', '.melange')),207 fix_path(os.path.join('~', '.melange')),
207 fix_path('~'),208 fix_path('~'),
208 '/etc/melange/',209 '/etc/melange/',
@@ -301,10 +302,6 @@
301 logger.debug("%(key)-30s %(value)s" % locals())302 logger.debug("%(key)-30s %(value)s" % locals())
302 logger.debug("*" * 80)303 logger.debug("*" * 80)
303 app = deploy.loadapp("config:%s" % conf_file, name=app_name)304 app = deploy.loadapp("config:%s" % conf_file, name=app_name)
304 extension_manager = options.get('extension_manager')
305 app = extensions.ExtensionMiddleware(app, conf,
306 ext_mgr=extension_manager)
307
308 except (LookupError, ImportError), e:305 except (LookupError, ImportError), e:
309 raise RuntimeError("Unable to load %(app_name)s from "306 raise RuntimeError("Unable to load %(app_name)s from "
310 "configuration file %(conf_file)s."307 "configuration file %(conf_file)s."
311308
=== modified file 'melange/common/extensions.py'
--- melange/common/extensions.py 2011-06-03 10:27:12 +0000
+++ melange/common/extensions.py 2011-06-09 07:21:01 +0000
@@ -185,7 +185,7 @@
185 def factory(cls, global_config, **local_config):185 def factory(cls, global_config, **local_config):
186 """Paste factory."""186 """Paste factory."""
187 def _factory(app):187 def _factory(app):
188 return cls(app, **local_config)188 return cls(app, global_config, **local_config)
189 return _factory189 return _factory
190190
191 def _action_ext_controllers(self, application, ext_mgr, mapper):191 def _action_ext_controllers(self, application, ext_mgr, mapper):
@@ -291,7 +291,7 @@
291class ExtensionManager(object):291class ExtensionManager(object):
292 """Load extensions from the configured extension path.292 """Load extensions from the configured extension path.
293293
294 See nova/tests/api/openstack/extensions/foxinsocks/extension.py for an294 See melange/tests/unit/extensions/foxinsocks.py for an
295 example extension implementation.295 example extension implementation.
296296
297 """297 """
@@ -362,7 +362,7 @@
362362
363 In addition, extensions are loaded from the 'contrib' directory.363 In addition, extensions are loaded from the 'contrib' directory.
364364
365 See nova/tests/api/openstack/extensions/foxinsocks.py for an example365 See melange/tests/unit/extensions/foxinsocks.py for an example
366 extension implementation.366 extension implementation.
367367
368 """368 """
@@ -405,10 +405,10 @@
405405
406406
407class RequestExtension(object):407class RequestExtension(object):
408 """Extend requests and responses of core nova OpenStack API controllers.408 """Extend requests and responses of core melange OpenStack API controllers.
409409
410 Provide a way to add data to responses and handle custom request data410 Provide a way to add data to responses and handle custom request data
411 that is sent to core nova OpenStack API controllers.411 that is sent to core melange OpenStack API controllers.
412412
413 """413 """
414 def __init__(self, method, url_route, handler):414 def __init__(self, method, url_route, handler):
@@ -419,7 +419,7 @@
419419
420420
421class ActionExtension(object):421class ActionExtension(object):
422 """Add custom actions to core nova OpenStack API controllers."""422 """Add custom actions to core melange OpenStack API controllers."""
423423
424 def __init__(self, collection, action_name, handler):424 def __init__(self, collection, action_name, handler):
425 self.collection = collection425 self.collection = collection
@@ -428,7 +428,7 @@
428428
429429
430class ResourceExtension(object):430class ResourceExtension(object):
431 """Add top level resources to the OpenStack API in nova."""431 """Add top level resources to the OpenStack API in melange."""
432432
433 def __init__(self, collection, controller, parent=None,433 def __init__(self, collection, controller, parent=None,
434 collection_actions={}, member_actions={}):434 collection_actions={}, member_actions={}):
435435
=== modified file 'tests/unit/test_extensions.py'
--- tests/unit/test_extensions.py 2011-06-03 10:27:12 +0000
+++ tests/unit/test_extensions.py 2011-06-09 07:21:01 +0000
@@ -26,6 +26,9 @@
2626
2727
28response_body = "Try to say this Mr. Knox, sir..."28response_body = "Try to say this Mr. Knox, sir..."
29conf_file = os.path.join(os.path.dirname(__file__),
30 os.pardir, os.pardir,
31 "etc", "melange.conf.test")
2932
3033
31class ExtensionControllerTest(unittest.TestCase):34class ExtensionControllerTest(unittest.TestCase):
@@ -108,7 +111,7 @@
108 self.assertEqual(404, response.status_int)111 self.assertEqual(404, response.status_int)
109112
110113
111class RequestExtensionTest(BaseTest):114class RequestExtensionTest(unittest.TestCase):
112115
113 def test_get_resources_with_stub_mgr(self):116 def test_get_resources_with_stub_mgr(self):
114117
@@ -146,6 +149,17 @@
146 self.assertEqual("Pig Bands!", response_data['big_bands'])149 self.assertEqual("Pig Bands!", response_data['big_bands'])
147150
148151
152class TestExtensionMiddlewareFactory(unittest.TestCase):
153
154 def test_app_configured_with_extensions_as_filter(self):
155 conf, melange_app = config.load_paste_app('extensions_app_with_filter',
156 {"config_file": conf_file},
157 None)
158
159 response = TestApp(melange_app).get("/extensions")
160 self.assertEqual(response.status_int, 200)
161
162
149class ExtensionsTestApp(wsgi.Router):163class ExtensionsTestApp(wsgi.Router):
150164
151 def __init__(self, options={}):165 def __init__(self, options={}):
@@ -175,10 +189,11 @@
175189
176190
177def setup_extensions_test_app(extension_manager=None):191def setup_extensions_test_app(extension_manager=None):
178 options = {'config_file': os.path.abspath("../../etc/melange.conf.test"),192 options = {'config_file': conf_file,
179 'extension_manager': extension_manager}193 'extension_manager': extension_manager}
180 conf, app = config.load_paste_app('extensions_test_app', options, None)194 conf, app = config.load_paste_app('extensions_test_app', options, None)
181 return TestApp(app)195 extended_app = extensions.ExtensionMiddleware(app, conf, extension_manager)
196 return TestApp(extended_app)
182197
183198
184class StubExtensionManager(object):199class StubExtensionManager(object):
185200
=== modified file 'tools/pip-requires'
--- tools/pip-requires 2011-06-07 06:26:52 +0000
+++ tools/pip-requires 2011-06-09 07:21:01 +0000
@@ -2,6 +2,7 @@
2pep8==0.5.02pep8==0.5.0
3eventlet>=0.9.123eventlet>=0.9.12
4PasteDeploy4PasteDeploy
5Paste
5routes6routes
6webob7webob
7webtest8webtest

Subscribers

People subscribed via source and target branches