Skip to content

Commit

Permalink
FIX: Fail to remove the logical volume
Browse files Browse the repository at this point in the history
The logical volume can not be removed when delete VM error. I look at the
code, found that parameter is a list in the libvirt's lvm, but in
imagebackend, parameters passed is a string.

Change-Id: I222f6c5cfe5be63105f2fd8afd7ccd209ca2e5f7
Closes-Bug: #1358552
  • Loading branch information
ware2009 committed Sep 18, 2014
1 parent 42e4c04 commit ce2031a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions nova/tests/virt/libvirt/test_imagebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def test_create_image_negative(self):
self.disk.get_disk_size(self.TEMPLATE_PATH
).AndReturn(self.TEMPLATE_SIZE)
self.mox.StubOutWithMock(self.lvm, 'remove_volumes')
self.lvm.remove_volumes(self.PATH)
self.lvm.remove_volumes([self.PATH])
self.mox.ReplayAll()

image = self.image_class(self.INSTANCE, self.NAME)
Expand All @@ -633,7 +633,7 @@ def test_create_image_generated_negative(self):
self.SIZE,
sparse=False)
self.mox.StubOutWithMock(self.lvm, 'remove_volumes')
self.lvm.remove_volumes(self.PATH)
self.lvm.remove_volumes([self.PATH])
self.mox.ReplayAll()

image = self.image_class(self.INSTANCE, self.NAME)
Expand Down Expand Up @@ -878,7 +878,7 @@ def test_create_image_negative(self):
sparse=False)
self.dmcrypt.delete_volume.assert_called_with(
self.PATH.rpartition('/')[2])
self.lvm.remove_volumes.assert_called_with(self.LV_PATH)
self.lvm.remove_volumes.assert_called_with([self.LV_PATH])

def test_create_image_encrypt_negative(self):
with contextlib.nested(
Expand Down Expand Up @@ -925,7 +925,7 @@ def test_create_image_encrypt_negative(self):
self.KEY)
self.dmcrypt.delete_volume.assert_called_with(
self.PATH.rpartition('/')[2])
self.lvm.remove_volumes.assert_called_with(self.LV_PATH)
self.lvm.remove_volumes.assert_called_with([self.LV_PATH])

def test_create_image_generated_negative(self):
with contextlib.nested(
Expand Down Expand Up @@ -971,7 +971,7 @@ def test_create_image_generated_negative(self):
context=self.CONTEXT)
self.dmcrypt.delete_volume.assert_called_with(
self.PATH.rpartition('/')[2])
self.lvm.remove_volumes.assert_called_with(self.LV_PATH)
self.lvm.remove_volumes.assert_called_with([self.LV_PATH])

def test_create_image_generated_encrypt_negative(self):
with contextlib.nested(
Expand Down Expand Up @@ -1014,7 +1014,7 @@ def test_create_image_generated_encrypt_negative(self):
self.KEY)
self.dmcrypt.delete_volume.assert_called_with(
self.PATH.rpartition('/')[2])
self.lvm.remove_volumes.assert_called_with(self.LV_PATH)
self.lvm.remove_volumes.assert_called_with([self.LV_PATH])

def test_prealloc_image(self):
self.flags(preallocate_images='space')
Expand Down
4 changes: 2 additions & 2 deletions nova/virt/libvirt/imagebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ def remove_volume_on_error(self, path):
except Exception:
with excutils.save_and_reraise_exception():
if self.ephemeral_key_uuid is None:
lvm.remove_volumes(path)
lvm.remove_volumes([path])
else:
dmcrypt.delete_volume(path.rpartition('/')[2])
lvm.remove_volumes(self.lv_path)
lvm.remove_volumes([self.lv_path])

def snapshot_extract(self, target, out_format):
images.convert_image(self.path, target, out_format,
Expand Down

0 comments on commit ce2031a

Please sign in to comment.