Deactivation happens in correct order and synchronizes with udev_settle. Error cases are handled gracefully and report user readable error messages. Supports both old (RHEL 5) and new sysfs zfcp device driver interface. --- storage/zfcp.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 51 insertions(+), 5 deletions(-) diff --git a/storage/zfcp.py b/storage/zfcp.py index 2584268..ee72580 100644 --- a/storage/zfcp.py +++ b/storage/zfcp.py @@ -158,18 +158,64 @@ class ZFCPDevice: def offlineDevice(self): offline = "%s/%s/online" %(zfcpsysfs, self.devnum) + portadd = "%s/%s/port_add" %(zfcpsysfs, self.devnum) portremove = "%s/%s/port_remove" %(zfcpsysfs, self.devnum) unitremove = "%s/%s/%s/unit_remove" %(zfcpsysfs, self.devnum, self.wwpn) + portdir = "%s/%s/%s" %(zfcpsysfs, self.devnum, self.wwpn) + devdir = "%s/%s" %(zfcpsysfs, self.devnum) try: self.offlineSCSIDevice() - loggedWriteLineToFile(offline, "0") + except Exception, e: + raise ValueError, _( + "could not delete scsi device of zfcp %s %s %s (%s)" + %(self.devnum, self.wwpn, self.fcplun, e)) + + try: loggedWriteLineToFile(unitremove, self.fcplun) - loggedWriteLineToFile(portremove, self.wwpn) except Exception, e: - log.warn("error bringing zfcp device %s offline: %s" - %(self.devnum, e)) - return False + raise ValueError, _( + "could not remove lun %s at wwpn %s on zfcp device %s (%s)" + %(self.fcplun, self.wwpn, self.devnum, e)) + + if os.path.exists(portadd): + # only try to remove ports with older zfcp sysfs interface + for lun in os.listdir(portdir): + if lun.startswith("0x") and \ + os.path.isdir(os.path.join(portdir, lun)): + log.info("not removing wwpn %s at zfcp device %s since port still has other luns, e.g. %s" + %(self.wwpn, self.devnum, lun)) + return True + + try: + loggedWriteLineToFile(portremove, self.wwpn) + except Exception, e: + raise ValueError, _("could not remove wwpn %s on zfcp device %s (%s)" + %(self.wwpn, self.devnum, e)) + + if os.path.exists(portadd): + # older zfcp sysfs interface + for port in os.listdir(devdir): + if port.startswith("0x") and \ + os.path.isdir(os.path.join(devdir, port)): + log.info("not setting zfcp device %s offline since it still has other ports, e.g. %s" + %(self.devnum, port)) + return True + else: + # newer zfcp sysfs interface with auto port scan + import glob + luns = glob.glob("%s/0x????????????????/0x????????????????" + %(devdir,)) + if len(luns) != 0: + log.info("not setting zfcp device %s offline since it still has other luns, e.g. %s" + %(self.devnum, luns[0])) + return True + + try: + loggedWriteLineToFile(offline, "0") + except Exception, e: + raise ValueError, _("could not set zfcp device %s offline (%s)" + %(self.devnum, e)) return True -- 1.6.3.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list