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

[PATCH master 1/4] Update ks network command for ipv6 in anaconda.



---
 pyanaconda/kickstart.py |  132 ++++++++++++++++++++++++++--------------------
 pyanaconda/network.py   |    5 ++-
 2 files changed, 79 insertions(+), 58 deletions(-)

diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 880503d..6822afa 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -558,75 +558,93 @@ class Logging(commands.logging.FC6_Logging):
     
 class NetworkData(commands.network.F8_NetworkData):
     def execute(self, anaconda):
-        if self.bootProto:
-            devices = anaconda.network.netdevices
-            if (devices and self.bootProto):
-                if not self.device:
-                    list = devices.keys ()
-                    list.sort()
-                    device = list[0]
-                else:
-                    device = self.device
-
-                # If we were given a network device name, grab the device object.
-                # If we were given a MAC address, resolve that to a device name
-                # and then grab the device object.  Otherwise, errors.
-                dev = None
-
-                if devices.has_key(device):
-                    dev = devices[device]
-                else:
-                    for (key, val) in devices.iteritems():
-                        if val.get("HWADDR").lower() == device.lower():
-                            dev = val
-                            break
-
-                if not dev:
-                    raise KickstartValueError, formatErrorMsg(self.lineno, msg="The provided network interface %s does not exist" % device)
-
-                dev.set (("bootproto", self.bootProto))
-                dev.set (("dhcpclass", self.dhcpclass))
-
-                if self.onboot:
-                    dev.set (("onboot", "yes"))
-                else:
-                    dev.set (("onboot", "no"))
-
-                dev.set(("NM_CONTROLLED", "yes"))
-
-                if self.bootProto == "static":
-                    if (self.ip):
-                        dev.set (("ipaddr", self.ip))
-                    if (self.netmask):
-                        dev.set (("netmask", self.netmask))
-
-                if self.ethtool:
-                    dev.set (("ethtool_opts", self.ethtool))
-
-                if isys.isWirelessDevice(device):
-                    if self.essid:
-                        dev.set(("essid", self.essid))
-                    if self.wepkey:
-                        dev.set(("defaultkey", "1"))
-                        dev.wepkey = self.wepkey
-                        dev.writeWepkeyFile()
+
+        devices = anaconda.network.netdevices
+
+        device = self.device or min(devices.keys())
+
+        # If we were given a network device name, grab the device object.
+        # If we were given a MAC address, resolve that to a device name
+        # and then grab the device object.  Otherwise, errors.
+        dev = None
+
+        if devices.has_key(device):
+            dev = devices[device]
+        else:
+            for (key, val) in devices.iteritems():
+                if val.get("HWADDR").lower() == device.lower():
+                    dev = val
+                    break
 
         if self.hostname != "":
             anaconda.network.setHostname(self.hostname)
             anaconda.network.overrideDHCPhostname = True
+            if not dev:
+                # Only set hostname
+                return
+        else:
+            if not dev:
+                raise KickstartValueError, formatErrorMsg(self.lineno, msg="The provided network interface %s does not exist" % device)
+
+
+        # ipv4 settings
+        if not self.noipv4:
+            dev.set(("BOOTPROTO", self.bootProto))
+            dev.set(("DHCPCLASS", self.dhcpclass))
+
+            if self.bootProto == "static":
+                if (self.ip):
+                    dev.set(("IPADDR", self.ip))
+                if (self.netmask):
+                    dev.set(("NETMASK", self.netmask))
+
+        # ipv6 settings
+        if self.noipv6:
+            dev.set(("IPV6INIT", "no"))
+        else:
+            dev.set(("IPV6INIT", "yes"))
+            if self.ipv6 == "auto":
+                dev.set(("IPV6_AUTOCONF", "yes"))
+            elif self.ipv6 == "dhcp":
+                dev.set(("IPV6_AUTOCONF", "no"))
+                dev.set(("DHCPV6C", "yes"))
+            elif self.ipv6:
+                dev.set(("IPV6_AUTOCONF", "no"))
+                dev.set(("IPV6ADDR", "%s" % self.ipv6))
+        # settings common for ipv4 and ipv6
+        if not self.noipv6 or not self.noipv4:
+            if self.onboot:
+                dev.set (("ONBOOT", "yes"))
+            else:
+                dev.set (("ONBOOT", "no"))
+
+            if self.ethtool:
+                dev.set(("ETHTOOL_OPTS", self.ethtool))
+
+            if isys.isWirelessDevice(device):
+                if self.essid:
+                    dev.set(("ESSID", self.essid))
+                if self.wepkey:
+                    dev.set(("DEFAULTKEY", "1"))
+                    dev.wepkey = self.wepkey
+                    dev.writeWepkeyFile()
 
-        if self.nameserver != "":
-            anaconda.network.setDNS(self.nameserver, device)
+            if self.nameserver != "":
+                anaconda.network.setDNS(self.nameserver, device)
 
-        if self.gateway != "":
-            anaconda.network.setGateway(self.gateway, device)
+            if self.gateway != "":
+                anaconda.network.setGateway(self.gateway, device)
 
         needs_net = (anaconda.methodstr and
                      (anaconda.methodstr.startswith("http:") or
                       anaconda.methodstr.startswith("ftp:") or
                       anaconda.methodstr.startswith("nfs:")))
+        # First kickstart network command wins
+        # TODORV: document
         if needs_net and not network.hasActiveNetDev():
-            log.info("Bringing up network in stage2 kickstart ...")
+            log.info("Bringing up network device %s in stage2 kickstart ..." %
+                     device)
+            dev.set (("onboot", "yes"))
             rc = anaconda.network.bringUp()
             log.info("Network setup %s" % (rc and 'succeeded' or 'failed',))
 
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 5dc81cb..d4c6bb5 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -433,7 +433,10 @@ class Network:
             i += 1
 
     def setGateway(self, gw, device):
-        self.netdevices[device].set(('GATEWAY', gw))
+        if ':' in gw:
+            self.netdevices[device].set(('IPV6_DEFAULTGW', gw))
+        else:
+            self.netdevices[device].set(('GATEWAY', gw))
 
     def lookupHostname(self):
         # can't look things up if they don't exist!
-- 
1.6.0.6


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