Add functions to go from an iScsiDiskDevice to an libiscsi node and the other way around. This is a preparation patch for adding support for writing the necessary dracut cmdline options to grub.conf --- storage/iscsi.py | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/storage/iscsi.py b/storage/iscsi.py index cfe0c55..13ddc08 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -268,13 +268,10 @@ class iscsi(object): # devices used for root get started by the initrd if root.dependsOn(disk): continue - # find the iscsi node matching this disk - for node in self.nodes: - if node.name == disk.iscsi_name and \ - node.address == disk.iscsi_address and \ - node.port == disk.iscsi_port: - node.setParameter("node.startup", "automatic") - break + + node = self.getNode(disk.iscsi_name, disk.iscsi_address, disk.iscsi_port) + if node: + node.setParameter("node.startup", "automatic")
if not os.path.isdir(instPath + "/etc/iscsi"): os.makedirs(instPath + "/etc/iscsi", 0755) @@ -289,4 +286,23 @@ class iscsi(object): shutil.copytree("/var/lib/iscsi", instPath + "/var/lib/iscsi", symlinks=True)
+ def getNode(self, name, address, port): + for node in self.nodes: + if node.name == name and node.address == address and \ + node.port == port: + return node + + return None + + def getNodeDisks(self, node, storage): + nodeDisks = [] + iscsiDisks = storage.devicetree.getDevicesByType("iscsi") + for disk in iscsiDisks: + if node.name == disk.iscsi_name and \ + node.address == disk.iscsi_address and \ + node.port == disk.iscsi_port: + nodeDisks.append(disk) + + return nodeDisks + # vim:tw=78:ts=4:et:sw=4
One iscsi target / node can have multiple LUN's currently we would then set it to autostart if any of the LUN's was not used for /, the correct thing todo is to only set it to autostart if none of the LUN's are used for / --- storage/iscsi.py | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/storage/iscsi.py b/storage/iscsi.py index 13ddc08..51b0eb8 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -261,16 +261,17 @@ class iscsi(object):
if not flags.test: root = anaconda.id.storage.fsset.rootDevice - disks = anaconda.id.storage.devicetree.getDevicesByType("iscsi")
# set iscsi nodes to autostart - for disk in disks: - # devices used for root get started by the initrd - if root.dependsOn(disk): - continue - - node = self.getNode(disk.iscsi_name, disk.iscsi_address, disk.iscsi_port) - if node: + for node in self.nodes: + autostart = True + disks = self.getNodeDisks(node, anaconda.id.storage) + for disk in disks: + # nodes used for root get started by the initrd + if root.dependsOn(disk): + autostart = False + + if autostart: node.setParameter("node.startup", "automatic")
if not os.path.isdir(instPath + "/etc/iscsi"):
When checking if a logical partition dependsOn() another device because that other device is an extended partition also make sure they are on the same disk. --- storage/devices.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/storage/devices.py b/storage/devices.py index 04da8fe..8658e4f 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -1141,7 +1141,8 @@ class PartitionDevice(StorageDevice):
def dependsOn(self, dep): """ Return True if this device depends on dep. """ - if isinstance(dep, PartitionDevice) and dep.isExtended and self.isLogical: + if isinstance(dep, PartitionDevice) and dep.isExtended and \ + self.isLogical and self.disk == dep.disk: return True
return Device.dependsOn(self, dep)
This is a preparation patch for adding support for writing the necessary dracut cmndline options to grub.conf --- storage/__init__.py | 6 ++++-- storage/devices.py | 8 +++----- storage/devicetree.py | 10 ++++++---- storage/iscsi.py | 4 +--- 4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/storage/__init__.py b/storage/__init__.py index 348a155..094c079 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -222,7 +222,8 @@ class Storage(object): protected=self.protectedDevSpecs, zeroMbr=self.zeroMbr, passphrase=self.encryptionPassphrase, - luksDict=self.__luksDevs) + luksDict=self.__luksDevs, + iscsi=self.iscsi) self.fsset = FSSet(self.devicetree)
def doIt(self): @@ -287,7 +288,8 @@ class Storage(object): protected=self.protectedDevSpecs, zeroMbr=self.zeroMbr, passphrase=self.encryptionPassphrase, - luksDict=self.__luksDevs) + luksDict=self.__luksDevs, + iscsi=self.iscsi) self.devicetree.populate() self.fsset = FSSet(self.devicetree) self.anaconda.id.rootParts = None diff --git a/storage/devices.py b/storage/devices.py index 8658e4f..ac1bbda 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -2931,12 +2931,10 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice): _packages = ["iscsi-initiator-utils"]
def __init__(self, device, **kwargs): - self.iscsi_name = kwargs.pop("iscsi_name") - self.iscsi_address = kwargs.pop("iscsi_address") - self.iscsi_port = int(kwargs.pop("iscsi_port")) + self.node = kwargs.pop("node") DiskDevice.__init__(self, device, **kwargs) - NetworkStorageDevice.__init__(self, host_address=self.iscsi_address) - log.debug("created new iscsi disk %s %s:%d" % (self.iscsi_name, self.iscsi_address, self.iscsi_port)) + NetworkStorageDevice.__init__(self, host_address=self.node.address) + log.debug("created new iscsi disk %s %s:%d" % (self.node.name, self.node.address, self.node.port))
class FcoeDiskDevice(DiskDevice, NetworkStorageDevice): diff --git a/storage/devicetree.py b/storage/devicetree.py index 71d7a48..b4634d9 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -203,7 +203,7 @@ class DeviceTree(object):
def __init__(self, intf=None, ignored=[], exclusive=[], type=CLEARPART_TYPE_NONE, clear=[], zeroMbr=None, reinitializeDisks=None, protected=[], - passphrase=None, luksDict=None): + passphrase=None, luksDict=None, iscsi=None): # internal data members self._devices = [] self._actions = [] @@ -217,6 +217,7 @@ class DeviceTree(object): self.clearPartDisks = clear self.zeroMbr = zeroMbr self.reinitializeDisks = reinitializeDisks + self.iscsi = iscsi
# protected device specs as provided by the user self.protectedDevSpecs = protected @@ -1105,9 +1106,10 @@ class DeviceTree(object): kwargs = {} if udev_device_is_iscsi(info): diskType = iScsiDiskDevice - kwargs["iscsi_name"] = udev_device_get_iscsi_name(info) - kwargs["iscsi_address"] = udev_device_get_iscsi_address(info) - kwargs["iscsi_port"] = udev_device_get_iscsi_port(info) + kwargs["node"] = self.iscsi.getNode( + udev_device_get_iscsi_name(info), + udev_device_get_iscsi_address(info), + udev_device_get_iscsi_port(info)) log.debug("%s is an iscsi disk" % name) elif udev_device_is_fcoe(info): diskType = FcoeDiskDevice diff --git a/storage/iscsi.py b/storage/iscsi.py index 51b0eb8..7c2dc36 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -299,9 +299,7 @@ class iscsi(object): nodeDisks = [] iscsiDisks = storage.devicetree.getDevicesByType("iscsi") for disk in iscsiDisks: - if node.name == disk.iscsi_name and \ - node.address == disk.iscsi_address and \ - node.port == disk.iscsi_port: + if disk.node == node: nodeDisks.append(disk)
return nodeDisks
This is a preparation patch for adding support for writing the necessary dracut cmndline options to grub.conf --- storage/devices.py | 1 + storage/devicetree.py | 1 + storage/iscsi.py | 4 ++++ 3 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/storage/devices.py b/storage/devices.py index ac1bbda..f6600b5 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -2932,6 +2932,7 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice):
def __init__(self, device, **kwargs): self.node = kwargs.pop("node") + self.ibft = kwargs.pop("ibft") DiskDevice.__init__(self, device, **kwargs) NetworkStorageDevice.__init__(self, host_address=self.node.address) log.debug("created new iscsi disk %s %s:%d" % (self.node.name, self.node.address, self.node.port)) diff --git a/storage/devicetree.py b/storage/devicetree.py index b4634d9..8f7c4f0 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1110,6 +1110,7 @@ class DeviceTree(object): udev_device_get_iscsi_name(info), udev_device_get_iscsi_address(info), udev_device_get_iscsi_port(info)) + kwargs["ibft"] = kwargs["node"] in self.iscsi.ibftNodes log.debug("%s is an iscsi disk" % name) elif udev_device_is_fcoe(info): diskType = FcoeDiskDevice diff --git a/storage/iscsi.py b/storage/iscsi.py index 7c2dc36..9629596 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -92,7 +92,10 @@ def stabilize(intf = None):
class iscsi(object): def __init__(self): + # This list contains all nodes self.nodes = [] + # This list contains nodes discovered through iBFT (or other firmware) + self.ibftNodes = [] self._initiator = "" self.initiatorSet = False self.started = False @@ -134,6 +137,7 @@ class iscsi(object): try: node.login() self.nodes.append(node) + self.ibftNodes.append(node) except: # FIXME, what to do when we cannot log in to a firmware # provided node ??
Add a dracutSetupString method to devices.py classes, this can be used to ask devices used for / to return a string to add to the kernelcmdline so that dracut can find /. For most devices nothing is needed, but for iscsi some cmdline arguments are needed. --- storage/devices.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/storage/devices.py b/storage/devices.py index f6600b5..9b9fd8e 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -317,6 +317,9 @@ class Device(object):
return False
+ def dracutSetupString(self): + return "" + @property def status(self): """ This device's status. @@ -2937,6 +2940,22 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice): NetworkStorageDevice.__init__(self, host_address=self.node.address) log.debug("created new iscsi disk %s %s:%d" % (self.node.name, self.node.address, self.node.port))
+ def dracutSetupString(self): + if self.ibft: + return "iscsi_firmware" + + netroot="netroot=iscsi:" + auth = self.node.getAuth() + if auth: + netroot += "%s:%s" % (auth.username, auth.password) + if len(auth.reverse_username) or len(auth.reverse_password): + netroot += ":%s:%s" % (auth.reverse_username, + auth.reverse_password) + + netroot += "@%s::%d::%s" % (self.node.address, self.node.port, + self.node.name) + + return netroot
class FcoeDiskDevice(DiskDevice, NetworkStorageDevice): """ An FCoE disk. """
--- booty/bootloaderInfo.py | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py index bdfb1d9..3c1ed06 100644 --- a/booty/bootloaderInfo.py +++ b/booty/bootloaderInfo.py @@ -87,7 +87,15 @@ def rootIsDevice(dev): class KernelArguments:
def get(self): - return self.args + args = self.args + root = self.storage.fsset.rootDevice + for d in self.storage.devices: + if root.dependsOn(d): + dracutSetupString = d.dracutSetupString() + if len(dracutSetupString): + args += " %s" % dracutSetupString + + return args
def set(self, args): self.args = args @@ -107,7 +115,7 @@ class KernelArguments: self.args = self.args + "%s" % (args,)
- def __init__(self): + def __init__(self, storage): newArgs = [] cfgFilename = "/tmp/install.cfg"
@@ -144,6 +152,7 @@ class KernelArguments: newArgs.append(arg)
self.args = " ".join(newArgs) + self.storage = storage
class BootImages: @@ -468,7 +477,7 @@ class bootloaderInfo: drivelist = property(_getDriveList, _setDriveList)
def __init__(self, storage): - self.args = KernelArguments() + self.args = KernelArguments(storage) self.images = BootImages() self.device = None self.defaultDevice = None # XXX hack, used by kickstart
--- storage/iscsi.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/storage/iscsi.py b/storage/iscsi.py index 9629596..974fc89 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -294,7 +294,7 @@ class iscsi(object): def getNode(self, name, address, port): for node in self.nodes: if node.name == name and node.address == address and \ - node.port == port: + node.port == int(port): return node
return None
On a quick scan over the code. Cant see anything wrong. ack, to all the patches.
On Fri, Jul 31, 2009 at 07:22:57PM +0200, Hans de Goede wrote:
Add functions to go from an iScsiDiskDevice to an libiscsi node and the other way around. This is a preparation patch for adding support for writing the necessary dracut cmdline options to grub.conf
storage/iscsi.py | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/storage/iscsi.py b/storage/iscsi.py index cfe0c55..13ddc08 100644 --- a/storage/iscsi.py +++ b/storage/iscsi.py @@ -268,13 +268,10 @@ class iscsi(object): # devices used for root get started by the initrd if root.dependsOn(disk): continue
# find the iscsi node matching this disk
for node in self.nodes:
if node.name == disk.iscsi_name and \
node.address == disk.iscsi_address and \
node.port == disk.iscsi_port:
node.setParameter("node.startup", "automatic")
break
node = self.getNode(disk.iscsi_name, disk.iscsi_address, disk.iscsi_port)
if node:
node.setParameter("node.startup", "automatic") if not os.path.isdir(instPath + "/etc/iscsi"): os.makedirs(instPath + "/etc/iscsi", 0755)
@@ -289,4 +286,23 @@ class iscsi(object): shutil.copytree("/var/lib/iscsi", instPath + "/var/lib/iscsi", symlinks=True)
- def getNode(self, name, address, port):
for node in self.nodes:
if node.name == name and node.address == address and \
node.port == port:
return node
return None
- def getNodeDisks(self, node, storage):
nodeDisks = []
iscsiDisks = storage.devicetree.getDevicesByType("iscsi")
for disk in iscsiDisks:
if node.name == disk.iscsi_name and \
node.address == disk.iscsi_address and \
node.port == disk.iscsi_port:
nodeDisks.append(disk)
return nodeDisks
# vim:tw=78:ts=4:et:sw=4
1.6.2.2
Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list
anaconda-devel@lists.fedoraproject.org