diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2012-05-31 18:09:23 +0000 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2012-05-31 18:18:01 +0000 |
| commit | 5fcdaf8232d404da0d281173b8f1e885aa0832b1 (patch) | |
| tree | fdd001d5e2be0c356c1109c5febe2feeee8ea2b9 | |
| parent | 9e8007320666797778f4a4e339fb30a681b75a22 (diff) | |
| download | nova-5fcdaf8232d404da0d281173b8f1e885aa0832b1.tar.gz nova-5fcdaf8232d404da0d281173b8f1e885aa0832b1.tar.xz nova-5fcdaf8232d404da0d281173b8f1e885aa0832b1.zip | |
Don't deepcopy RpcContext
Instead of deepcopying the RpcContext, which seems to not work
sometimes, we'll explicitly create a new instance of the class and
deepcopy the required values.
Fixes bug 1007043
Change-Id: I6578c4c82046acf149724a1c5985fa6b46857a7c
| -rw-r--r-- | nova/rpc/amqp.py | 6 | ||||
| -rw-r--r-- | nova/rpc/common.py | 5 | ||||
| -rw-r--r-- | nova/rpc/impl_fake.py | 7 |
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 |
