Re: [PATCH] Fix iscsi udev info parsing (#811426)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/11/2012 05:06 PM, Chris Lumens wrote:
diff --git a/storage/udev.py b/storage/udev.py
index 7890c17..493c03e 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -554,7 +554,7 @@ def udev_device_get_iscsi_port(info):
      return path_components[address_field].split(":")[-1]

  def udev_device_get_iscsi_nic(info):
-    session = info["sysfs_path"].split("/")[4]
+    session = re.match('/.*/(session\d+)', info["sysfs_path"]).groups()[0]
      iface = open("/sys/class/iscsi_session/%s/ifacename" %
                   session).read().strip()
      return iface
Ugh, regular expressions.


Generally I am trying to avoid using REs when not
necessary but I see it more suitable than filtering
path segments with startswith in this case. Beside that
it is already used in similar case in the module.

In the case where re.match doesn't match anything, it'll return None in
which case we'll get a "NoneType has no attribute groups" here.


Alright, I'll return None in the case. Sending new version.



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


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux