Skip to content

Instantly share code, notes, and snippets.

@cp16net
Created January 21, 2014 19:57
Show Gist options
  • Save cp16net/8547197 to your computer and use it in GitHub Desktop.
Save cp16net/8547197 to your computer and use it in GitHub Desktop.
diff --git a/trove/common/context.py b/trove/common/context.py
index 014aa50..c9dd1a6 100644
--- a/trove/common/context.py
+++ b/trove/common/context.py
@@ -34,6 +34,7 @@ class TroveContext(context.RequestContext):
def __init__(self, **kwargs):
self.limit = kwargs.pop('limit', None)
self.marker = kwargs.pop('marker', None)
+ self.datastore = kwargs.pop('datastore', None)
super(TroveContext, self).__init__(**kwargs)
if not hasattr(local.store, 'context'):
diff --git a/trove/common/wsgi.py b/trove/common/wsgi.py
index 5868c86..3bbbe12 100644
--- a/trove/common/wsgi.py
+++ b/trove/common/wsgi.py
@@ -482,7 +482,7 @@ class Controller(object):
def _extract_limits(self, params):
return dict([(key, params[key]) for key in params.keys()
- if key in ["limit", "marker"]])
+ if key in ["limit", "marker", "datastore"]])
class TroveRequestDeserializer(RequestDeserializer):
@@ -689,7 +689,7 @@ class ContextMiddleware(openstack_wsgi.Middleware):
def _extract_limits(self, params):
return dict([(key, params[key]) for key in params.keys()
- if key in ["limit", "marker"]])
+ if key in ["limit", "marker", "datastore"]])
def process_request(self, request):
tenant_id = request.headers.get('X-Tenant-Id', None)
@@ -706,6 +706,7 @@ class ContextMiddleware(openstack_wsgi.Middleware):
tenant=tenant_id,
user=user_id,
is_admin=is_admin,
+ datastore=limits.get('datastore'),
limit=limits.get('limit'),
marker=limits.get('marker'))
request.environ[CONTEXT_KEY] = context
diff --git a/trove/configuration/service.py b/trove/configuration/service.py
index 0841771..66931a1 100644
--- a/trove/configuration/service.py
+++ b/trove/configuration/service.py
@@ -252,11 +252,15 @@ class ConfigurationsController(wsgi.Controller):
class ParametersController(wsgi.Controller):
def index(self, req, tenant_id):
+ context = req.environ[wsgi.CONTEXT_KEY]
+ LOG.debug("ParametersController index context %s" % context.__dict__)
rules = configurations.get_validation_rules()
return wsgi.Result(views.ConfigurationParametersView(rules).data(),
200)
def show(self, req, tenant_id, id):
+ context = req.environ[wsgi.CONTEXT_KEY]
+ LOG.debug("ParametersController show context %s" % context.__dict__)
rules = configurations.get_validation_rules()
for rule in rules['configuration-parameters']:
if rule['name'] == id:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment