summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/rpc/amqp.py6
-rw-r--r--nova/rpc/common.py5
-rw-r--r--nova/rpc/impl_fake.py7
3 files changed, 17 insertions, 1 deletions
diff --git a/nova/rpc/amqp.py b/nova/rpc/amqp.py
index 8df16ff9d..8e5d685d5 100644
--- a/nova/rpc/amqp.py
+++ b/nova/rpc/amqp.py
@@ -175,6 +175,12 @@ class RpcContext(rpc_common.CommonRpcContext):
self.conf = kwargs.pop('conf')
super(RpcContext, self).__init__(**kwargs)
+ def deepcopy(self):
+ values = self.to_dict()
+ values['conf'] = self.conf
+ values['msg_id'] = self.msg_id
+ return self.__class__(**values)
+
def reply(self, reply=None, failure=None, ending=False,
connection_pool=None):
if self.msg_id:
diff --git a/nova/rpc/common.py b/nova/rpc/common.py
index c5f88f90b..0b927a0ee 100644
--- a/nova/rpc/common.py
+++ b/nova/rpc/common.py
@@ -287,6 +287,9 @@ class CommonRpcContext(object):
def from_dict(cls, values):
return cls(**values)
+ def deepcopy(self):
+ return self.from_dict(self.to_dict())
+
def update_store(self):
local.store.context = self
@@ -299,7 +302,7 @@ class CommonRpcContext(object):
# convert the RpcContext back to its native RequestContext doing
# something like nova.context.RequestContext.from_dict(ctxt.to_dict())
- context = copy.deepcopy(self)
+ context = self.deepcopy()
context.values['is_admin'] = True
context.values.setdefault('roles', [])
diff --git a/nova/rpc/impl_fake.py b/nova/rpc/impl_fake.py
index 54bd2497b..24ef0e7c1 100644
--- a/nova/rpc/impl_fake.py
+++ b/nova/rpc/impl_fake.py
@@ -34,6 +34,13 @@ class RpcContext(rpc_common.CommonRpcContext):
self._response = []
self._done = False
+ def deepcopy(self):
+ values = self.to_dict()
+ new_inst = self.__class__(**values)
+ new_inst._response = self._response
+ new_inst._done = self._done
+ return new_inst
+
def reply(self, reply=None, failure=None, ending=False):
if ending:
self._done = True