New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/760
commit 8e1ce57293b79f0a570e0afc106c4e6e4d252329
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Thu Jul 28 16:22:30 2011 +0300
Related to BZ#701671 - Return ENODEV if device does not exist.
Change-Id: Ibcf14a4d6f3492697d6ba2b9c37de2722de4c6b0
diff --git a/vdsm/storage/devicemapper.py b/vdsm/storage/devicemapper.py
index bf155bc..bb74355 100644
--- a/vdsm/storage/devicemapper.py
+++ b/vdsm/storage/devicemapper.py
@@ -70,7 +70,7 @@ def resolveDevName(devName):
try:
return getDmId(devName)
except Exception:
- raise OSError(errno.ENOENT, "No such block device `%s`" % devName)
+ raise OSError(errno.ENODEV, "No such block device `%s`" % devName)
def isVirtualDevice(devName):
devName = resolveDevName(devName)
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 55e790e..43d73ee 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -13,6 +13,7 @@ Generic LVM interface wrapper
Incapsulates the actual LVM mechanics.
"""
+import errno
import os
import pwd
@@ -703,7 +704,13 @@ def _initpv(device, withmetadata=False):
if isPvPartOfVg(device):
raise se.PhysDevInitializationError(device)
- devicemapper.removeMappingsHoldingDevice(os.path.basename(device))
+ try:
+ devicemapper.removeMappingsHoldingDevice(os.path.basename(device))
+ except OSError, e:
+ if e.errno == errno.ENODEV:
+ raise se.PhysDevInitializationError("%s: %s" % (device,
str(e)))
+ else:
+ raise
rc, out, err = _lvminfo.cmd(cmd)
if rc != 0:
raise se.PhysDevInitializationError(device)