FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 05-12-2010, 09:02 PM
Peter Jones
 
Default Handle devices that don't have a /dev/disk/by-path/ symlink (#563242)

Looks like for non-disk devices, udev doesn't build a /dev/disk/by-path/
symlink, so we can't reliably use that. If we're in that case, just use
device.path .
---
storage/devices.py | 9 ++++++---
storage/devicetree.py | 8 ++++----
storage/errors.py | 3 +++
3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 03a8cdf..0b561e8 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -150,12 +150,15 @@ def deviceNameToDiskByPath(deviceName=None):
if not deviceName:
return ""

+ ret = None
for dev in udev_get_block_devices():
if udev_device_get_name(dev) == deviceName:
- return udev_device_get_by_path(dev)
-
- return None
+ ret = udev_device_get_by_path(dev)
+ break

+ if ret:
+ return ret
+ raise DeviceNotFoundError(deviceName)

class Device(object):
""" A generic device.
diff --git a/storage/devicetree.py b/storage/devicetree.py
index c171968..93aa005 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1357,11 +1357,11 @@ class DeviceTree(object):
initcb = lambda: True
else:
description = device.description or device.model
- bypath = deviceNameToDiskByPath(device.name)
- if bypath:
- bypath = os.path.basename(bypath)
+ try:
+ bypath = os.path.basename(deviceNameToDiskByPath(device.nam e))
details = "

Device details:
%s" % (bypath,)
- else:
+ except DeviceNotFoundError:
+ # some devices don't have a /dev/disk/by-path/ #!@#@!@#
bypath = device.name
details = ""

diff --git a/storage/errors.py b/storage/errors.py
index c4d4313..ea7e79c 100644
--- a/storage/errors.py
+++ b/storage/errors.py
@@ -129,6 +129,9 @@ class MPathError(StorageError):
class DeviceTreeError(StorageError):
pass

+class DeviceNotFoundError(StorageError):
+ pass
+
# DeviceAction
class DeviceActionError(StorageError):
pass
--
1.7.0.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-13-2010, 03:17 PM
David Cantrell
 
Default Handle devices that don't have a /dev/disk/by-path/ symlink (#563242)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack.

On Wed, 12 May 2010, Peter Jones wrote:


Looks like for non-disk devices, udev doesn't build a /dev/disk/by-path/
symlink, so we can't reliably use that. If we're in that case, just use
device.path .
---
storage/devices.py | 9 ++++++---
storage/devicetree.py | 8 ++++----
storage/errors.py | 3 +++
3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 03a8cdf..0b561e8 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -150,12 +150,15 @@ def deviceNameToDiskByPath(deviceName=None):
if not deviceName:
return ""

+ ret = None
for dev in udev_get_block_devices():
if udev_device_get_name(dev) == deviceName:
- return udev_device_get_by_path(dev)
-
- return None
+ ret = udev_device_get_by_path(dev)
+ break

+ if ret:
+ return ret
+ raise DeviceNotFoundError(deviceName)

class Device(object):
""" A generic device.
diff --git a/storage/devicetree.py b/storage/devicetree.py
index c171968..93aa005 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1357,11 +1357,11 @@ class DeviceTree(object):
initcb = lambda: True
else:
description = device.description or device.model
- bypath = deviceNameToDiskByPath(device.name)
- if bypath:
- bypath = os.path.basename(bypath)
+ try:
+ bypath = os.path.basename(deviceNameToDiskByPath(device.nam e))
details = "

Device details:
%s" % (bypath,)
- else:
+ except DeviceNotFoundError:
+ # some devices don't have a /dev/disk/by-path/ #!@#@!@#
bypath = device.name
details = ""

diff --git a/storage/errors.py b/storage/errors.py
index c4d4313..ea7e79c 100644
--- a/storage/errors.py
+++ b/storage/errors.py
@@ -129,6 +129,9 @@ class MPathError(StorageError):
class DeviceTreeError(StorageError):
pass

+class DeviceNotFoundError(StorageError):
+ pass
+
# DeviceAction
class DeviceActionError(StorageError):
pass



- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkvsF+8ACgkQ5hsjjIy1VklgAQCfVbJQwPVAnn vTegx+4KGO5prJ
AU0An3uSZIbShMMSDT8nRLDHcFqYf+qb
=CxWl
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 06:35 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org