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
'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:
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',