diff options
Diffstat (limited to 'nova/objects')
| -rw-r--r-- | nova/objects/base.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/nova/objects/base.py b/nova/objects/base.py index 0cfd08e6b..1ba0f03b7 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -16,9 +16,11 @@ import collections +from nova import context from nova import exception from nova.objects import utils as obj_utils from nova.openstack.common import log as logging +from nova.openstack.common.rpc import common as rpc_common import nova.openstack.common.rpc.dispatcher import nova.openstack.common.rpc.proxy import nova.openstack.common.rpc.serializer @@ -81,12 +83,13 @@ class NovaObjectMetaclass(type): # requested action and the result will be returned here. def remotable_classmethod(fn): """Decorator for remotable classmethods.""" - def wrapper(cls, context, **kwargs): + def wrapper(cls, context, *args, **kwargs): if NovaObject.indirection_api: result = NovaObject.indirection_api.object_class_action( - context, cls.obj_name(), fn.__name__, cls.version, kwargs) + context, cls.obj_name(), fn.__name__, cls.version, + args, kwargs) else: - result = fn(cls, context, **kwargs) + result = fn(cls, context, *args, **kwargs) if isinstance(result, NovaObject): result._context = context return result @@ -100,22 +103,28 @@ def remotable_classmethod(fn): # "orphaned" and remotable methods cannot be called. def remotable(fn): """Decorator for remotable object methods.""" - def wrapper(self, context=None, **kwargs): - if context is None: - context = self._context - if context is None: + def wrapper(self, *args, **kwargs): + ctxt = self._context + try: + if isinstance(args[0], (context.RequestContext, + rpc_common.CommonRpcContext)): + ctxt = args[0] + args = args[1:] + except IndexError: + pass + if ctxt is None: raise exception.OrphanedObjectError(method=fn.__name__, objtype=self.obj_name()) if NovaObject.indirection_api: updates, result = NovaObject.indirection_api.object_action( - context, self, fn.__name__, kwargs) + ctxt, self, fn.__name__, args, kwargs) for key, value in updates.iteritems(): if key in self.fields: self[key] = self._attr_from_primitive(key, value) self._changed_fields = set(updates.get('obj_what_changed', [])) return result else: - return fn(self, context, **kwargs) + return fn(self, ctxt, *args, **kwargs) return wrapper |
