summaryrefslogtreecommitdiffstats
path: root/nova/objects
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-06-04 08:07:24 -0700
committerDan Smith <danms@us.ibm.com>2013-06-04 14:25:38 -0700
commit5d9cb7dd354dc1a1eae9985521c0f4b2ea4d876e (patch)
tree2bc062fca9fe791835d49a2a043015c11923b3e7 /nova/objects
parent820135933168feeb6320a23555ca0ebf5e14fa08 (diff)
downloadnova-5d9cb7dd354dc1a1eae9985521c0f4b2ea4d876e.tar.gz
nova-5d9cb7dd354dc1a1eae9985521c0f4b2ea4d876e.tar.xz
nova-5d9cb7dd354dc1a1eae9985521c0f4b2ea4d876e.zip
Make object actions pass positional arguments
This changes the Object API to also pass positional arguments to remotable methods. Previously, we required only keyword arguments to these methods in order to mirror our current RPC behavior. This is not really necessary and could be confusing. Since there are no actual users of these APIs in the tree right now, we can make this change without needing to bump any versions. Related to blueprint unified-object-model Change-Id: Ifb12843d16500d383d4e9c607121d5584400f247
Diffstat (limited to 'nova/objects')
-rw-r--r--nova/objects/base.py27
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