From db8da4942f1bf6c506701be5a98e55cd11d11052 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 18 Jun 2018 13:23:14 +0000 Subject: [PATCH] Revert "Re-using the code of os brick cinder" This reverts commit 8b8c5da59efb087295b676d4261f84dfadf62503. The new LVM.delete() call results in a TypeError because the LVM.delete() method isn't a classmethod and the LVM object was not properly instantiated. Change-Id: Iace04233220f281576251760ebe59dd584c2b637 Closes-Bug: #1777448 --- nova/privsep/fs.py | 5 +++++ nova/tests/unit/virt/libvirt/storage/test_lvm.py | 2 +- nova/virt/libvirt/storage/lvm.py | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/privsep/fs.py b/nova/privsep/fs.py index 9bd7a326d0..638fd50ad4 100644 --- a/nova/privsep/fs.py +++ b/nova/privsep/fs.py @@ -75,6 +75,11 @@ def lvinfo(path): '--separator', '|', path) +@nova.privsep.sys_admin_pctxt.entrypoint +def lvremove(path): + processutils.execute('lvremove', '-f', path, attempts=3) + + @nova.privsep.sys_admin_pctxt.entrypoint def blockdev_size(path): return processutils.execute('blockdev', '--getsize64', path) diff --git a/nova/tests/unit/virt/libvirt/storage/test_lvm.py b/nova/tests/unit/virt/libvirt/storage/test_lvm.py index b58a16b1f9..fbec2dcae9 100644 --- a/nova/tests/unit/virt/libvirt/storage/test_lvm.py +++ b/nova/tests/unit/virt/libvirt/storage/test_lvm.py @@ -118,7 +118,7 @@ class LvmTestCase(test.NoDBTestCase): lvm.clear_volume('/dev/foo') @mock.patch.object(lvm, 'clear_volume') - @mock.patch('os_brick.local_dev.lvm.LVM.delete', + @mock.patch('nova.privsep.fs.lvremove', side_effect=processutils.ProcessExecutionError('Error')) def test_fail_remove_all_logical_volumes(self, mock_clear, mock_lvremove): self.assertRaises(exception.VolumesNotRemoved, diff --git a/nova/virt/libvirt/storage/lvm.py b/nova/virt/libvirt/storage/lvm.py index c6eff1108f..5f032b5cea 100644 --- a/nova/virt/libvirt/storage/lvm.py +++ b/nova/virt/libvirt/storage/lvm.py @@ -21,7 +21,6 @@ import os -from os_brick.local_dev import lvm as brick_lvm from oslo_concurrency import processutils from oslo_log import log as logging from oslo_utils import units @@ -187,7 +186,7 @@ def remove_volumes(paths): for path in paths: clear_volume(path) try: - brick_lvm.LVM.delete(path) + nova.privsep.fs.lvremove(path) except processutils.ProcessExecutionError as exp: errors.append(six.text_type(exp)) if errors: