Fix BDM legacy usage with objects

When we're doing an upgrade against Havana, our backleveled
compute RPC version will cause us to run block_device.legacy_mapping(),
which attempts to convert a BlockDeviceMapping object into an old-
style dict. This trips over a common problem with objects where
things expecting a list or a dict decide the object is a dict and
try to iterate it as such.

This makes the small tweak necessary and adds a test that verifies
that it works.

Change-Id: I98fe496720ad1c4fce44c0c7fea8bfa1c2721812
This commit is contained in:
Dan Smith
2014-03-06 12:46:11 -08:00
parent bb0445fa92
commit 31a4ffc49c
2 changed files with 14 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ class BlockDeviceDict(dict):
self.update(
dict((field, None)
for field in self._fields - do_not_default))
self.update(bdm_dict)
self.update(list(bdm_dict.iteritems()))
def _validate(self, bdm_dict):
"""Basic data format validations."""