diff options
author | Hans Lindgren <hanlind@kth.se> | 2013-03-03 16:19:08 +0100 |
---|---|---|
committer | Hans Lindgren <hanlind@kth.se> | 2013-03-04 13:49:00 +0100 |
commit | 4a2c57684c18f90f23263156f952561154751e09 (patch) | |
tree | afee74d0f91c21896dc48c611ea3505410cc6a64 /nova/compute | |
parent | 690d8f3d4061443b149b13f96116ad72e5dcb06c (diff) | |
download | nova-4a2c57684c18f90f23263156f952561154751e09.tar.gz nova-4a2c57684c18f90f23263156f952561154751e09.tar.xz nova-4a2c57684c18f90f23263156f952561154751e09.zip |
Fix an error in compute api snapshot_volume_backed bdm code
Stumbled upon an error similar to the one found in
https://review.openstack.org/#/c/23354/ where a dbm dict
item is tried to be read as an attribute.
Looked at the next couple of lines and discovered more
cases of this error.
Updates to some api tests that contain faulty fakes that
hide this error adds some coverage for this error. Rebased
this patch on the above mentioned review to be able to
change the tests, since the code path is the same and they
now hit both of these errors.
Resolves bug 1142734.
Change-Id: Ie639cd483334b6222085a139159da47ce6fa3671
Diffstat (limited to 'nova/compute')
-rw-r--r-- | nova/compute/api.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 53bba667e..75bbe5264 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1595,17 +1595,10 @@ class API(base.Base): mapping = [] for bdm in bdms: - if bdm.no_device: + if bdm['no_device']: continue - m = {} - for attr in ('device_name', 'snapshot_id', 'volume_id', - 'volume_size', 'delete_on_termination', 'no_device', - 'virtual_name'): - val = getattr(bdm, attr) - if val is not None: - m[attr] = val - - volume_id = m.get('volume_id') + + volume_id = bdm.get('volume_id') if volume_id: # create snapshot based on volume_id volume = self.volume_api.get(context, volume_id) @@ -1615,11 +1608,10 @@ class API(base.Base): name = _('snapshot for %s') % image_meta['name'] snapshot = self.volume_api.create_snapshot_force( context, volume, name, volume['display_description']) - m['snapshot_id'] = snapshot['id'] - del m['volume_id'] + bdm['snapshot_id'] = snapshot['id'] + del bdm['volume_id'] - if m: - mapping.append(m) + mapping.append(bdm) for m in block_device.mappings_prepend_dev(properties.get('mappings', [])): |