diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-16 23:52:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-16 23:52:59 +0000 |
| commit | 5a21a28b53e436c6fac9f6f58a09ca2007b8d63b (patch) | |
| tree | 3cfe5662f9ba317a52b49a820fa1cd53c1de7b88 | |
| parent | 1e5606f4c26b9b01fddcdc2c62199248f9cef004 (diff) | |
| parent | c8c9a87b240b562d334c6875a1dd7614d4ae58d5 (diff) | |
Merge "Add RPC serialization checking, fix exposed problems."
| -rw-r--r-- | nova/compute/api.py | 20 | ||||
| -rw-r--r-- | nova/rpc/impl_fake.py | 11 |
2 files changed, 21 insertions, 10 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index d93443ea4..78655bed4 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -549,7 +549,7 @@ class API(base.Base): locals()) request_spec = { - 'image': image, + 'image': utils.to_primitive(image), 'instance_properties': base_options, 'instance_type': instance_type, 'num_instances': num_instances, @@ -1384,14 +1384,16 @@ class API(base.Base): if not FLAGS.allow_resize_to_same_host: filter_properties['ignore_hosts'].append(instance['host']) - self._cast_scheduler_message(context, - {"method": "prep_resize", - "args": {"topic": FLAGS.compute_topic, - "instance_uuid": instance['uuid'], - "update_db": False, - "instance_type_id": new_instance_type['id'], - "request_spec": request_spec, - "filter_properties": filter_properties}}) + args = { + "topic": FLAGS.compute_topic, + "instance_uuid": instance['uuid'], + "update_db": False, + "instance_type_id": new_instance_type['id'], + "request_spec": utils.to_primitive(request_spec), + "filter_properties": filter_properties, + } + self._cast_scheduler_message(context, {"method": "prep_resize", + "args": args}) @wrap_check_policy def add_fixed_ip(self, context, instance, network_id): diff --git a/nova/rpc/impl_fake.py b/nova/rpc/impl_fake.py index 44567d6f9..42ed7907d 100644 --- a/nova/rpc/impl_fake.py +++ b/nova/rpc/impl_fake.py @@ -18,6 +18,7 @@ queues. Casts will block, but this is very useful for tests. """ import inspect +import json import signal import sys import time @@ -124,9 +125,16 @@ def create_connection(new=True): return Connection() +def check_serialize(msg): + """Make sure a message intended for rpc can be serialized.""" + json.dumps(msg) + + def multicall(context, topic, msg, timeout=None): """Make a call that returns multiple times.""" + check_serialize(msg) + method = msg.get('method') if not method: return @@ -158,7 +166,7 @@ def cast(context, topic, msg): def notify(context, topic, msg): - pass + check_serialize(msg) def cleanup(): @@ -167,6 +175,7 @@ def cleanup(): def fanout_cast(context, topic, msg): """Cast to all consumers of a topic""" + check_serialize(msg) method = msg.get('method') if not method: return |
