[PATCH] Stage2 modifications to support ibft method of network setup

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

 



---
 iscsi.py   |    8 ++++++
 network.py |   72 +++++++++++++++++++++++++++++++++++++++++++----------------
 rescue.py  |   71 ++++++++++++++++++++++++++++++++++++++++------------------
 3 files changed, 109 insertions(+), 42 deletions(-)

diff --git a/iscsi.py b/iscsi.py
index bcb54df..30e7294 100644
--- a/iscsi.py
+++ b/iscsi.py
@@ -214,6 +214,14 @@ class iscsi(object):
         # [root@elm3b87 ~]# iscsiadm -m fw
         # iface.initiatorname = iqn.2007-05.com.ibm.beaverton.elm3b87:01
         # iface.hwaddress = 00:14:5e:b3:8e:b2
+
+        # iface.bootproto = DHCP
+        # or
+        # iface.bootproto = STATIC
+        # iface.ipaddress = 192.168.32.72
+        # iface.subnet_mask = 255.255.252.0
+        # iface.gateway = 192.168.35.254
+
         # node.name = iqn.1992-08.com.netapp:sn.84183797
         # node.conn[0].address = 9.47.67.152
         # node.conn[0].port = 3260
diff --git a/network.py b/network.py
index 0ebc6a2..3c531b2 100644
--- a/network.py
+++ b/network.py
@@ -335,28 +335,58 @@ class Network:
 	if not self.primaryNS:
             return
         myns = self.primaryNS
+
+        usemethod = dev.get('bootproto').lower()
+
 	if not self.isConfigured:
 	    for dev in self.netdevices.values():
-                if (dev.get('bootproto').lower() == "dhcp" and
-                    dev.get('onboot') == "yes"):
-		    ret = isys.dhcpNetDevice(dev.get('device'), dev.get('dhcpclass'))
-                    if ret is None:
-                        continue
-                    myns = ret
-                    self.isConfigured = 1
-                    break
-                elif (dev.get('ipaddr') and dev.get('netmask') and
-                      self.gateway is not None and dev.get('onboot') == "yes"):
-                    try:
-                        isys.configNetDevice(dev.get('device'),
-                                             dev.get('ipaddr'),
-                                             dev.get('netmask'),
-                                             self.gateway)
+                while True:
+                    if (usemethod == "ibft" and dev.get('onboot') == "yes"):
+                        try:
+                            if anaconda.id.iscsi.fwinfo["iface.bootproto"].lower() == "dhcp":
+                                usemethod = "dhcp"
+                                continue
+                            else:
+                                hwaddr = isys.getMacAddress(dev)
+                                if hwaddr != anaconda.id.iscsi.fwinfo["iface.hwaddress"]:
+                                    log.error("The iBFT configuration does not belong to device %s,"
+                                              "falling back to dhcp", dev.get('device'))
+                                    usemethod = "dhcp"
+                                    continue
+
+                                isys.configNetDevice(dev.get('device'),
+                                                     anaconda.id.iscsi.fwinfo["iface.ipaddress"],
+                                                     anaconda.id.iscsi.fwinfo["iface.subnet_mask"],
+                                                     anaconda.id.iscsi.fwinfo["iface.gateway"])
+                                self.isConfigured = 1
+                        except:
+                            log.error("failed to configure network device %s using "
+                                      "iBFT information, falling back to dhcp", dev.get('device'))
+                            usemethod = "dhcp"
+                            continue
+                    elif (usemethod == "dhcp" and
+                        dev.get('onboot') == "yes"):
+                        ret = isys.dhcpNetDevice(dev.get('device'), dev.get('dhcpclass'))
+                        if ret is None:
+                            continue
+                        myns = ret
                         self.isConfigured = 1
                         break
-                    except SystemError:
-                        log.error("failed to configure network device %s when "
-                                  "looking up host name", dev.get('device'))
+                    elif (dev.get('ipaddr') and dev.get('netmask') and
+                          self.gateway is not None and dev.get('onboot') == "yes"):
+                        try:
+                            isys.configNetDevice(dev.get('device'),
+                                                 dev.get('ipaddr'),
+                                                 dev.get('netmask'),
+                                                 self.gateway)
+                            self.isConfigured = 1
+                            break
+                        except SystemError:
+                            log.error("failed to configure network device %s when "
+                                      "looking up host name", dev.get('device'))
+
+                    #try it only once
+                    break
 
             if self.isConfigured and not flags.rootpath:
                 f = open("/etc/resolv.conf", "w")
@@ -406,7 +436,7 @@ class Network:
         for devName in devNames:
             dev = self.netdevices[devName]
 
-            if dev.get('bootproto').lower() == 'dhcp' or dev.get('ipaddr'):
+            if dev.get('bootproto').lower() == 'dhcp' or  dev.get('bootproto').lower() == 'ibft' or dev.get('ipaddr'):
                 f.write("network --device %s" % dev.get('device'))
 
                 if dev.get('MTU') and dev.get('MTU') != 0:
@@ -423,6 +453,8 @@ class Network:
 			if (self.hostname and
 			    self.hostname != "localhost.localdomain"):
 			    f.write(" --hostname %s" % self.hostname)
+                elif dev.get('bootproto').lower() == 'ibft':
+                    f.write(" --bootproto ibft")
                 else:
                     f.write(" --bootproto static --ip %s --netmask %s" % 
                        (dev.get('ipaddr'), dev.get('netmask')))
@@ -456,7 +488,7 @@ class Network:
                 f.write("# %s\n" % (dev.get("DESC"),))
 
             # if bootproto is dhcp, unset any static settings (#218489)
-            if dev.get('BOOTPROTO').lower() == 'dhcp':
+            if dev.get('BOOTPROTO').lower() in ['dhcp', 'ibft']:
                 dev.unset('IPADDR')
                 dev.unset('NETMASK')
                 dev.unset('GATEWAY')
diff --git a/rescue.py b/rescue.py
index 828332e..791c8b1 100644
--- a/rescue.py
+++ b/rescue.py
@@ -136,7 +136,7 @@ def methodUsesNetworking(methodstr):
 # XXX
 #     hack to write out something useful for networking and start interfaces
 #
-def startNetworking(network, intf):
+def startNetworking(network, intf, anaconda):
 
     # do lo first
     try:
@@ -153,26 +153,53 @@ def startNetworking(network, intf):
 	waitwin = intf.waitWindow(_("Starting Interface"),
 				  _("Attempting to start %s") % (dev.get('device'),))
 	log.info("Attempting to start %s", dev.get('device'))
-	if dev.get('bootproto') == "dhcp":
-	    try:
-		ns = isys.dhcpNetDevice(dev.get('device'))
-		if ns:
-		    if not dhcpGotNS:
-			dhcpGotNS = 1
-
-			f = open("/etc/resolv.conf", "w")
-			f.write("nameserver %s\n" % ns)
-			f.close()
-	    except:
-		log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device'))
-	elif dev.get('ipaddr') and dev.get('netmask') and network.gateway is not None:
-	    try:
-		isys.configNetDevice(dev.get('device'),
-				     dev.get('ipaddr'),
-				     dev.get('netmask'),
-				     network.gateway)
-	    except:
-		log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device'))
+        method = dev.get('bootproto')
+        while True:
+            if method = "ibft":
+                try:
+                    if anaconda.id.iscsi.fwinfo["iface.bootproto"].lower() == "dhcp":
+                        method = "dhcp"
+                        continue
+                    else:
+                        hwaddr = isys.getMacAddress(dev)
+                        if hwaddr != anaconda.id.iscsi.fwinfo["iface.hwaddress"]:
+                            log.error("The iBFT configuration does not belong to device %s,"
+                                      "falling back to dhcp", dev.get('device'))
+                            method = "dhcp"
+                            continue
+
+                        isys.configNetDevice(dev.get('device'),
+                                             anaconda.id.iscsi.fwinfo["iface.ipaddress"],
+                                             anaconda.id.iscsi.fwinfo["iface.subnet_mask"],
+                                             anaconda.id.iscsi.fwinfo["iface.gateway"])
+                except:
+                    log.error("failed to configure network device %s using "
+                              "iBFT information, falling back to dhcp", dev.get('device'))
+                    usemethod = "dhcp"
+                    continue
+            elif method == "dhcp":
+                try:
+                    ns = isys.dhcpNetDevice(dev.get('device'))
+                    if ns:
+                        if not dhcpGotNS:
+                            dhcpGotNS = 1
+
+                            f = open("/etc/resolv.conf", "w")
+                            f.write("nameserver %s\n" % ns)
+                            f.close()
+                except:
+                    log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device'))
+            elif dev.get('ipaddr') and dev.get('netmask') and network.gateway is not None:
+                try:
+                    isys.configNetDevice(dev.get('device'),
+                                         dev.get('ipaddr'),
+                                         dev.get('netmask'),
+                                         network.gateway)
+                except:
+                    log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device'))
+
+            #do that only once
+            break
 
 	waitwin.pop()
 	
@@ -274,7 +301,7 @@ def runRescue(anaconda):
 		    elif step >= len(classNames):
 			break
 
-		startNetworking(anaconda.id.network, anaconda.intf)
+		startNetworking(anaconda.id.network, anaconda.intf, anaconda)
 		break
 	    else:
 		break
-- 
1.5.4.1

_______________________________________________
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