From 864cd83c5a73cc274ba2193cc757b38a528b0332 Mon Sep 17 00:00:00 2001 From: peter_wang Date: Mon, 21 Dec 2015 05:37:12 -0500 Subject: [PATCH] Remove name_id when creating volume with cache enabled When image_volume_cache_enabled = True, Cinder will create a cached image volume. But when creating this image volume, the name_id is set to id of newly created volume, which causes the image volume is unable to be created in the underlying storage system. This fix will remove the name_id so that volume.name can refer to correct LUN on storage system Also, a minor fix: passing volume.id to delete_volume since it only accept volume id. Change-Id: Ib47b189a525d8a9bd9026cc20f62542aede9c9d4 Closes-bug: 1528087 --- cinder/volume/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 180d20743fd..21d48c0b1c0 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -1073,11 +1073,11 @@ class VolumeManager(manager.SchedulerDependentManager): reserve_opts = {'volumes': 1, 'gigabytes': volume.size} QUOTAS.add_volume_type_opts(ctx, reserve_opts, volume_type_id) reservations = QUOTAS.reserve(ctx, **reserve_opts) - try: new_vol_values = dict(volume.items()) new_vol_values.pop('id', None) new_vol_values.pop('_name_id', None) + new_vol_values.pop('name_id', None) new_vol_values.pop('volume_type', None) new_vol_values.pop('name', None) @@ -1122,7 +1122,7 @@ class VolumeManager(manager.SchedulerDependentManager): {'volume_id': volume.id, 'image_id': image_meta['id']}) try: - self.delete_volume(ctx, image_volume) + self.delete_volume(ctx, image_volume.id) except exception.CinderException: LOG.exception(_LE('Could not delete the image volume %(id)s.'), {'id': volume.id})