[PATCH] 03/05 add iscsi.py and add call to init the iscsi class

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

 



Add and reference the main iscsi.py module that has common code used by
the iscsi gui and text install.

diff -uprN -X /home/patman/dontdiff anaconda-10.91.12/dispatch.py iscsi-anaconda-10.91.12/dispatch.py
--- anaconda-10.91.12/dispatch.py	2006-01-31 07:51:55.000000000 -0800
+++ iscsi-anaconda-10.91.12/dispatch.py	2006-02-06 14:01:16.000000000 -0800
@@ -65,6 +65,7 @@ installSteps = [
     ("findrootparts", findRootParts, ("intf", "id", "dispatch", "dir", "instPath")),
     ("findinstall", ("dispatch", "intf", "id", "instPath")),
     ("installtype", ("dispatch", "id", "method", "intf")),
+    ("iscsi", ("id.iscsi", "intf")),
     ("zfcpconfig", ("id.zfcp", "id.diskset", "intf")),
     ("partitionobjinit", partitionObjectsInitialize, ("id.diskset",
                                                       "id.partitions",
diff -uprN -X /home/patman/dontdiff anaconda-10.91.12/instdata.py iscsi-anaconda-10.91.12/instdata.py
--- anaconda-10.91.12/instdata.py	2006-01-30 13:13:06.000000000 -0800
+++ iscsi-anaconda-10.91.12/instdata.py	2006-02-06 14:05:29.000000000 -0800
@@ -26,6 +26,7 @@ import fsset
 import bootloader
 import partitions
 import partedUtils
+import iscsi
 import zfcp
 import urllib
 import iutil
@@ -51,6 +52,7 @@ class InstallData:
 
 	self.instClass = None
 	self.network = network.Network()
+	self.iscsi = iscsi.iscsi()
 	self.zfcp = zfcp.ZFCP()
 	self.firewall = firewall.Firewall()
         self.security = security.Security()
diff -uprN -X /home/patman/dontdiff anaconda-10.91.12/iscsi.py iscsi-anaconda-10.91.12/iscsi.py
--- anaconda-10.91.12/iscsi.py	1969-12-31 16:00:00.000000000 -0800
+++ iscsi-anaconda-10.91.12/iscsi.py	2006-02-07 13:52:37.000000000 -0800
@@ -0,0 +1,124 @@
+#
+# iscsi.py - iscsi class
+#
+# Copyright 2005, 2006 IBM, Inc.
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+import os
+import string
+import signal
+import iutil
+from flags import flags
+import logging
+log = logging.getLogger("anaconda")
+
+
+# Note that stage2 copies all files under /sbin to /usr/sbin
+ISCSID="iscsid"
+ISCSIADM = "iscsiadm"
+ISCSID_DB_DIR="/var/db/iscsi"
+INITIATOR_FILE="/etc/initiatorname.iscsi"
+
+class iscsi:
+
+    def __init__(self):
+        if flags.iscsi:
+            self.ipaddr = ""
+            self.port = "3260"
+            self.initiator = ""
+            self.iscsidStarted = False
+        return
+
+    def action(self, action):
+        #
+        # run action for all iSCSI targets.
+        #
+        # For each record (line of output) in:
+        #     iscsiadm -m node
+        #
+        # Where each line in the output is of the form:
+        #     [recnum] stuff
+        #
+        # Issue the "action" request to recnum.
+        #
+        argv = [ ISCSIADM, "-m", "node" ]
+        records = iutil.execWithCapture(argv[0], argv, searchPath = 1)
+        for line in records.split("\n"):
+            if line:
+                recnum = line.split()[0][1:-1]
+                argv = [ ISCSIADM, "-m", "node", "-r", "%s" % (recnum,),
+                         "%s" % (action,) ]
+                iutil.execWithRedirect(argv[0], argv, searchPath = 1)
+
+    def shutdown(self):
+
+        if not self.iscsidStarted:
+            return
+
+        log.info("iSCSI shutdown")
+        self.action("--logout")
+
+        # XXX use iscsiadm shutdown when it's available.
+        argv = [ "ps", "--no-headers", "-C", "%s" % (ISCSID,) ]
+        psout = iutil.execWithCapture(argv[0], argv, searchPath = 1)
+        for line in psout.split("\n"):
+            if line:
+                pid = string.atoi(string.split(line)[0])
+                log.info("Killing %s %d" % (ISCSID, pid))
+                os.kill(pid, signal.SIGKILL)
+        self.iscsidStarted = False;
+
+        return
+
+    def startup(self):
+
+        log.info("iSCSI IP address %s, port %s" % (self.ipaddr, self.port))
+        log.info("iSCSI initiator name %s", self.initiator)
+
+        if flags.test:
+            return
+
+        self.shutdown()
+
+        if not self.ipaddr:
+            log.info("iSCSI: Not starting, no iscsi IP address specified")
+            return
+
+        log.debug("Setting up %s" % (INITIATOR_FILE, ))
+        if os.path.exists(INITIATOR_FILE):
+            os.unlink(INITIATOR_FILE)
+        fd = os.open(INITIATOR_FILE, os.O_RDWR | os.O_CREAT)
+        os.write(fd, "InitiatorName=%s\n" %(self.initiator))
+        os.close(fd)
+
+        if not os.path.exists(ISCSID_DB_DIR):
+            iutil.mkdirChain(ISCSID_DB_DIR)
+
+        argv = [ ISCSID ]
+        iutil.execWithRedirect(argv[0], argv, searchPath = 1)
+
+        argv = [ ISCSIADM, "-m", "discovery", "-t", "st", "-p", 
+                 "%s:%s" % (self.ipaddr, self.port) ]
+        iutil.execWithRedirect(argv[0], argv, searchPath = 1)
+
+        self.action("--login")
+        self.iscsidStarted = True;
+        return
+
+    def writeKS(self):
+        # XXX Useful if we have auto-generated kickstart files.
+        return
+
+    def write(self):
+        # XXX copy config files and any files needed by mkinitrd, depends on
+        # mkinitrd and open-iscsi work in progress.
+        return
+
+# vim:tw=78:ts=4:et:sw=4


[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