diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-06-05 03:15:25 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-06-05 03:15:25 +0000 |
| commit | e5e26541e1885c2883306bba1d58e3a0787dc553 (patch) | |
| tree | 5a132f213f0aa3955964d7d1d6674f9b24f3b646 /nova/objects | |
| parent | 819657b85b5318f609201100c4775e787b9257a4 (diff) | |
| parent | 5d9cb7dd354dc1a1eae9985521c0f4b2ea4d876e (diff) | |
| download | nova-e5e26541e1885c2883306bba1d58e3a0787dc553.tar.gz nova-e5e26541e1885c2883306bba1d58e3a0787dc553.tar.xz nova-e5e26541e1885c2883306bba1d58e3a0787dc553.zip | |
Merge "Make object actions pass positional arguments"
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 |
