[PATCH] bug fix: Properly list host partitions for Ubuntu 14.04 server

While trying to create a logical pool in a Ubuntu 14.04 server I got the following error: [08/Aug/2014:15:52:38] HTTP Traceback (most recent call last): File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 110, in lookup self.info = lookup(*self.model_args) File "/home/alinefm/kimchi/src/kimchi/model/host.py", line 274, in lookup return disks.get_partition_details(name) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 180, in get_partition_details dev_path = _get_dev_node_path(majmin) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 41, in _get_dev_node_path return _get_friendly_dm_path(maj_min) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 33, in _get_friendly_dm_path with open(dm_name) as dm_f: IOError: [Errno 2] No such file or directory: '/sys/dev/block/253:5/dm/name' It is because, even the maj_min starts with '253:', the file does not exist. So check this file exists in order to use it, otherwise get the dev path from uevent file. Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com> --- src/kimchi/disks.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py index 65d3a1d..a092c17 100644 --- a/src/kimchi/disks.py +++ b/src/kimchi/disks.py @@ -17,6 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +import os.path import re import subprocess @@ -27,18 +28,14 @@ from kimchi.exception import OperationFailed from kimchi.utils import kimchi_log -def _get_friendly_dm_path(maj_min): - """ Returns user friendly dm path given the device number 'major:min' """ - dm_name = "/sys/dev/block/%s/dm/name" % maj_min - with open(dm_name) as dm_f: - content = dm_f.read().rstrip('\n') - return "/dev/mapper/" + content - - def _get_dev_node_path(maj_min): """ Returns device node path given the device number 'major:min' """ - if maj_min.startswith('253:'): - return _get_friendly_dm_path(maj_min) + + dm_name = "/sys/dev/block/%s/dm/name" % maj_min + if os.path.exists(dm_name): + with open(dm_name) as dm_f: + content = dm_f.read().rstrip('\n') + return "/dev/mapper/" + content uevent = "/sys/dev/block/%s/uevent" % maj_min with open(uevent) as ueventf: -- 1.9.3

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> On 08-08-2014 16:52, Aline Manera wrote:
While trying to create a logical pool in a Ubuntu 14.04 server I got the following error:
[08/Aug/2014:15:52:38] HTTP Traceback (most recent call last): File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 110, in lookup self.info = lookup(*self.model_args) File "/home/alinefm/kimchi/src/kimchi/model/host.py", line 274, in lookup return disks.get_partition_details(name) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 180, in get_partition_details dev_path = _get_dev_node_path(majmin) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 41, in _get_dev_node_path return _get_friendly_dm_path(maj_min) File "/home/alinefm/kimchi/src/kimchi/disks.py", line 33, in _get_friendly_dm_path with open(dm_name) as dm_f: IOError: [Errno 2] No such file or directory: '/sys/dev/block/253:5/dm/name'
It is because, even the maj_min starts with '253:', the file does not exist. So check this file exists in order to use it, otherwise get the dev path from uevent file.
Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
participants (2)
-
Aline Manera
-
Crístian Viana