Here we are making two 'requests': First the http_client.get() as a part of images.Contoller.get() itself
and second in schemas.Controller.get() via the images.Controller.model() to fetch glance schema for creating warlock model object.
Inserting 'hook' into the first request is straight forward.
To insert hook in second case we need to pass request ids list to schemas.Controller.get() from model()
and model() will inturn get this list from images.Controller.get() API method.
Now here we have a problem, we cannot pass extra arguements to model() like:
self.model(request_ids=request_ids, **body)
Alternative way: If we cannot pass request ids list to model() let’s try returning one:
diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py
index c065535..b090c02 100644
--- a/glanceclient/v2/images.py
+++ b/glanceclient/v2/images.py
@@ -38,10 +38,11 @@ class Controller(object):
@utils.memoized_property
def unvalidated_model(self):
@@ -183,7 +184,9 @@ class Controller(object):
# NOTE(bcwaldon): remove 'self' for now until we have an elegant
# way to pass it into the model constructor without conflict body.pop('self', None)
- return self.model(**body)
+ model, req_ids = self.model(**body)
+ request_ids.extend(req_ids)
+ return model
But again this approach is also giving problem:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "glanceclient/v2/images.py", line 188, in get
model, req_ids = self.model(**body)
TypeError: 'tuple' object is not callable
>>>
Also this means we need to make lot of changes to every method that uses model().
This is only required if we want the request id for fetching schema from glance. If we do not want to retrieve this particular request id then there will be no issue so please suggest whether
we should exclude this request id or not.
Hi Stuart, Erno,
A potential issue with the current approach:
Let’s take an example here: images.get() API call
Here we are making two 'requests': First the http_client.get() as a part of images. Contoller. get() itself Controller. get() via the images. Controller. model() to fetch glance schema for creating warlock model object.
and second in schemas.
Inserting 'hook' into the first request is straight forward.
To insert hook in second case we need to pass request ids list to schemas. Controller. get() from model() Controller. get() API method.
and model() will inturn get this list from images.
Now here we have a problem, we cannot pass extra arguements to model() like:
self.model( request_ ids=request_ ids, **body)
Alternative way: If we cannot pass request ids list to model() let’s try returning one:
diff --git a/glanceclient/ v2/images. py b/glanceclient/ v2/images. py v2/images. py v2/images. py
index c065535..b090c02 100644
--- a/glanceclient/
+++ b/glanceclient/
@@ -38,10 +38,11 @@ class Controller(object):
@utils. memoized_ property client. get('image' ) client. get('image' , request_ ids=request_ ids)
warlock_ model = warlock. model_factory( schema. raw(),
schemas. SchemaBasedMode l)
def model(self):
- schema = self.schema_
+ request_ids = []
+ schema = self.schema_
- return warlock_model
+ return warlock_model, request_ids
@utils. memoized_ property model(self) :
body. pop('self' , None) ids.extend( req_ids)
def unvalidated_
@@ -183,7 +184,9 @@ class Controller(object):
# NOTE(bcwaldon): remove 'self' for now until we have an elegant
# way to pass it into the model constructor without conflict
- return self.model(**body)
+ model, req_ids = self.model(**body)
+ request_
+ return model
But again this approach is also giving problem: v2/images. py", line 188, in get
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "glanceclient/
model, req_ids = self.model(**body)
TypeError: 'tuple' object is not callable
>>>
Also this means we need to make lot of changes to every method that uses model().
This is only required if we want the request id for fetching schema from glance. If we do not want to retrieve this particular request id then there will be no issue so please suggest whether
we should exclude this request id or not.