Update expected error message from lvs

drivers/lvm.py uses _volume_not_present() to avoid deleting a snapshot
when it does not exist in the lvm backend. This functions uses brick/
local_dev/lvm.py get_lv_info() which expects "not found" as error message.

Since LVM2 2.102.112, The error message returned by lvs changed
From:
    One or more specified logical volume(s) not found
To:
    Failed to find logical volume \"%s/%s\"

Change-Id: I032a916666918b07d00983a42f10dd8efc17ee8b
Closes-Bug: #1470218
This commit is contained in:
Alberto Murillo 2015-06-30 16:12:55 -05:00 committed by Alberto Murillo
parent b2a752ba98
commit a0e2f994ff
2 changed files with 15 additions and 3 deletions

View File

@ -277,10 +277,10 @@ class LVM(executor.Executor):
run_as_root=True)
except putils.ProcessExecutionError as err:
with excutils.save_and_reraise_exception(reraise=True) as ctx:
if "not found" in err.stderr:
if "not found" in err.stderr or "Failed to find" in err.stderr:
ctx.reraise = False
LOG.info(_LI("'Not found' when querying LVM info. "
"(vg_name=%(vg)s, lv_name=%(lv)s"),
LOG.info(_LI("Logical Volume not found when querying "
"LVM info. (vg_name=%(vg)s, lv_name=%(lv)s"),
{'vg': vg_name, 'lv': lv_name})
out = None

View File

@ -98,6 +98,11 @@ class BrickLvmTestCase(test.TestCase):
'fake-vg/lv-nothere' in cmd_string):
raise processutils.ProcessExecutionError(
stderr="One or more specified logical volume(s) not found.")
elif ('env, LC_ALL=C, lvs, --noheadings, '
'--unit=g, -o, vg_name,name,size, --nosuffix, '
'fake-vg/lv-newerror' in cmd_string):
raise processutils.ProcessExecutionError(
stderr="Failed to find logical volume \"fake-vg/lv-newerror\"")
elif ('env, LC_ALL=C, lvs, --noheadings, '
'--unit=g, -o, vg_name,name,size' in cmd_string):
if 'fake-unknown' in cmd_string:
@ -180,11 +185,18 @@ class BrickLvmTestCase(test.TestCase):
self.assertEqual(self.vg.get_volume('fake-unknown'), None)
def test_get_lv_info_notfound(self):
# lv-nothere will raise lvm < 2.102.112 exception
self.assertEqual(
[],
self.vg.get_lv_info(
'sudo', vg_name='fake-vg', lv_name='lv-nothere')
)
# lv-newerror will raise lvm > 2.102.112 exception
self.assertEqual(
[],
self.vg.get_lv_info(
'sudo', vg_name='fake-vg', lv_name='lv-newerror')
)
def test_get_lv_info_found(self):
lv_info = [{'size': '9.50', 'name': 'test-found-lv-name',