Blob Blame History Raw
--- ./cobbler/field_info.py	2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/field_info.py	2012-01-26 13:43:04.000000000 +0100
@@ -58,6 +58,7 @@ USES_CHECKBOX = [
    "*netboot_enabled",
    "netboot_enabled",
    "*static",
+   "ipv6_autoconfiguration",
    "keep_updated",
    "mirror_locally",
    "virt_auto_boot"
@@ -101,6 +102,7 @@ BLOCK_MAPPINGS = {
    "broadcast"       : "Networking", # ..
    "reserved"        : "Networking", # ..
    "*mac_address"    : "Networking",
+   "*mtu"            : "Networking",
    "*ip_address"     : "Networking",
    "*dhcp_tag"       : "Networking",
    "*static"         : "Networking",
@@ -110,17 +112,24 @@ BLOCK_MAPPINGS = {
    "*dns_name"       : "Networking",
    "*static_routes"  : "Networking",
    "*subnet"         : "Networking",
-   "hostname"        : "Networking (Global)",
-   "gateway"         : "Networking (Global)",
-   "name_servers"         : "Networking (Global)",
-   "name_servers_search"  : "Networking (Global)",
-   "repos"                : "General",
-   "dhcp_tag"             : "Advanced",
-   "mgmt_classes"   : "Management",
-   "template_files"       : "Management",
-   "network_widget_a"     : "Networking",
-   "network_widget_b"     : "Networking",
-   "server"      : "Advanced",
+   "*ipv6_address"   : "Networking",
+   "*ipv6_secondaries"      : "Networking",
+   "*ipv6_mtu"              : "Networking",
+   "*ipv6_static_routes"    : "Networking",
+   "*ipv6_default_gateway"  : "Networking",
+   "hostname"               : "Networking (Global)",
+   "gateway"                : "Networking (Global)",
+   "name_servers"           : "Networking (Global)",
+   "name_servers_search"    : "Networking (Global)",
+   "ipv6_default_device"    : "Networking (Global)",
+   "ipv6_autoconfiguration" : "Networking (Global)",
+   "repos"                  : "General",
+   "dhcp_tag"               : "Advanced",
+   "mgmt_classes"           : "Management",
+   "template_files"         : "Management",
+   "network_widget_a"       : "Networking",
+   "network_widget_b"       : "Networking",
+   "server"                 : "Advanced",
    "redhat_management_key"  : "Management",
    "redhat_management_server" : "Management",
    "createrepo_flags"         : "Advanced",
--- ./cobbler/item_system.py	2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/item_system.py	2012-01-26 13:43:04.000000000 +0100
@@ -59,9 +59,12 @@ FIELDS = [
   ["gateway","",0,"Gateway",True,"",0,"str"],
   ["name_servers",[],0,"Name Servers",True,"space delimited",0,"list"],
   ["name_servers_search",[],0,"Name Servers Search Path",True,"space delimited",0,"list"],
+  ["ipv6_default_device","",0,"IPv6 Default Device",True,"",0,"str"],
+  ["ipv6_autoconfiguration",False,0,"IPv6 Autoconfiguration",True,"",0,"bool"],
   ["network_widget_a","",0,"Add Interface",True,"",0,"str"], # not a real field, a marker for the web app
   ["network_widget_b","",0,"Edit Interface",True,"",0,"str"], # not a real field, a marker for the web app
   ["*mac_address","",0,"MAC Address",True,"(Place \"random\" in this field for a random MAC Address.)",0,"str"],
+  ["*mtu","",0,"MTU",True,"",0,"str"],
   ["*ip_address","",0,"IP Address",True,"",0,"str"],
   ["*bonding","na",0,"Bonding Mode",True,"",["na","master","slave"],"str"],
   ["*bonding_master","",0,"Bonding Master",True,"",0,"str"],
@@ -72,6 +75,11 @@ FIELDS = [
   ["*dns_name","",0,"DNS Name",True,"",0,"str"],
   ["*static_routes",[],0,"Static Routes",True,"",0,"list"],
   ["*virt_bridge","",0,"Virt Bridge",True,"",0,"str"],
+  ["*ipv6_address","",0,"IPv6 Address",True,"",0,"str"],
+  ["*ipv6_secondaries",[],0,"IPv6 Secondaries",True,"space delimited",0,"list"],
+  ["*ipv6_mtu","",0,"IPv6 MTU",True,"",0,"str"],
+  ["*ipv6_static_routes",[],0,"IPv6 Static Routes",True,"",0,"list"],
+  ["*ipv6_default_gateway","",0,"IPv6 Default Gateway",True,"",0,"str"],
   ["mgmt_classes",[],0,"Management Classes",True,"For external config management",0,"list"],
   ["template_files",{},0,"Template Files",True,"File mappings for built-in configuration management",0,"dict"],
   ["redhat_management_key","<<inherit>>",0,"Red Hat Management Key",True,"Registration key for RHN, Satellite, or Spacewalk",0,"str"],
@@ -114,6 +122,7 @@ class System(item.Item):
         if not self.interfaces.has_key(name):
             self.interfaces[name] = {
                 "mac_address"    : "",
+                "mtu"            : "",
                 "ip_address"     : "",
                 "dhcp_tag"       : "",
                 "subnet"         : "",
@@ -124,6 +133,11 @@ class System(item.Item):
                 "bonding_opts"   : "",
                 "dns_name"       : "",
                 "static_routes"  : [],
+                "ipv6_address"   : "",
+                "ipv6_secondaries"  : [],
+                "ipv6_mtu"       : "",
+                "ipv6_static_routes"  : [],
+                "ipv6_default_gateway" : "",
             }
 
         return self.interfaces[name]
@@ -364,6 +378,65 @@ class System(item.Item):
         intf["bonding_opts"] = bonding_opts
         return True
 
+    def set_ipv6_autoconfiguration(self,truthiness):
+        self.ipv6_autoconfiguration = utils.input_boolean(truthiness)
+        return True
+
+    def set_ipv6_default_device(self,interface_name):
+        if interface_name is None:
+           interface_name = ""
+        self.ipv6_default_device = interface_name
+        return True
+
+    def set_ipv6_address(self,address,interface):
+        """
+        Assign a IP or hostname in DHCP when this MAC boots.
+        Only works if manage_dhcp is set in /etc/cobbler/settings
+        """
+        intf = self.__get_interface(interface)
+        if address == "" or utils.is_ip(address):
+           intf["ipv6_address"] = address.strip()
+           return True
+        raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+    def set_ipv6_secondaries(self,addresses,interface):
+        intf = self.__get_interface(interface)
+        data = utils.input_string_or_list(addresses)
+        secondaries = []
+        for address in data:
+           if address == "" or utils.is_ip(address):
+               secondaries.append(address)
+           else:
+               raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+        intf["ipv6_secondaries"] = secondaries
+        return True
+
+    def set_ipv6_default_gateway(self,address,interface):
+        intf = self.__get_interface(interface)
+        if address == "" or utils.is_ip(address):
+           intf["ipv6_default_gateway"] = address.strip()
+           return True
+        raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+    def set_ipv6_static_routes(self,routes,interface):
+        intf = self.__get_interface(interface)
+        data = utils.input_string_or_list(routes)
+        intf["ipv6_static_routes"] = data
+        return True
+
+    def set_ipv6_mtu(self,mtu,interface):
+        intf = self.__get_interface(interface)
+        intf["ipv6_mtu"] = mtu
+        return True
+
+    def set_mtu(self,mtu,interface):
+        intf = self.__get_interface(interface)
+        intf["mtu"] = mtu
+        return True
+
+
+
     def set_profile(self,profile_name):
         """
         Set the system to use a certain named profile.  The profile
@@ -503,17 +576,23 @@ class System(item.Item):
         for (key,value) in hash.iteritems():
             (field,interface) = key.split("-")
             field = field.replace("_","").replace("-","")
-            if field == "macaddress"    : self.set_mac_address(value, interface)
-            if field == "ipaddress"     : self.set_ip_address(value, interface)
-            if field == "dnsname"       : self.set_dns_name(value, interface)
-            if field == "static"        : self.set_static(value, interface)
-            if field == "dhcptag"       : self.set_dhcp_tag(value, interface)
-            if field == "subnet"        : self.set_subnet(value, interface)
-            if field == "virtbridge"    : self.set_virt_bridge(value, interface)
-            if field == "bonding"       : self.set_bonding(value, interface)
-            if field == "bondingmaster" : self.set_bonding_master(value, interface)
-            if field == "bondingopts"   : self.set_bonding_opts(value, interface)
-            if field == "staticroutes"  : self.set_static_routes(value, interface)
+            if field == "macaddress"          : self.set_mac_address(value, interface)
+            if field == "mtu"                 : self.set_mtu(value, interface)
+            if field == "ipaddress"           : self.set_ip_address(value, interface)
+            if field == "dnsname"             : self.set_dns_name(value, interface)
+            if field == "static"              : self.set_static(value, interface)
+            if field == "dhcptag"             : self.set_dhcp_tag(value, interface)
+            if field == "subnet"              : self.set_subnet(value, interface)
+            if field == "virtbridge"          : self.set_virt_bridge(value, interface)
+            if field == "bonding"             : self.set_bonding(value, interface)
+            if field == "bondingmaster"       : self.set_bonding_master(value, interface)
+            if field == "bondingopts"         : self.set_bonding_opts(value, interface)
+            if field == "staticroutes"        : self.set_static_routes(value, interface)
+            if field == "ipv6address"         : self.set_ipv6_address(value, interface)
+            if field == "ipv6secondaries"     : self.set_ipv6_secondaries(value, interface)
+            if field == "ipv6mtu"             : self.set_ipv6_mtu(value, interface)
+            if field == "ipv6staticroutes"    : self.set_ipv6_static_routes(value, interface)
+            if field == "ipv6defaultgateway"  : self.set_ipv6_default_gateway(value, interface)
         return True
 
     def check_if_valid(self):
--- ./snippets/post_install_network_config	2010-07-28 17:48:48.000000000 +0200
+++ ./snippets/post_install_network_config	2012-01-26 15:53:46.000000000 +0100
@@ -14,6 +14,7 @@
     #
     #set $configbymac = True
     #set $numbondingdevs = 0
+    #set $enableipv6 = False
     ## =============================================================================
     #for $iname in $ikeys
         ## look at the interface hash data for the specific interface
@@ -29,6 +30,12 @@
     	#if $idata["bonding"].lower() == "master"
     	    #set $numbondingdevs += 1
     	#end if
+
+        ## enable IPv6 networking if we set an ipv6 address or turn on autoconfiguration
+        #if $idata["ipv6_address"] != "" or $ipv6_autoconfiguration == True
+            #set $enableipv6 = True
+        #end if
+
     #end for
     ## end looping through the interfaces to see which ones we need to configure.
     ## =============================================================================
@@ -64,22 +71,56 @@ mv /etc/sysconfig/network.cobbler /etc/s
     # connecting to Puppet before a reboot).
 /bin/hostname $hostname
     #end if
+
+    #if $enableipv6 == True
+grep -v NETWORKING_IPV6 /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network.cobbler
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+
+        #if $ipv6_autoconfiguration != ""
+grep -v IPV6_AUTOCONF /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+            #if $ipv6_autoconfiguration == True
+echo "IPV6_AUTOCONF=yes" >> /etc/sysconfig/network.cobbler
+            #else
+echo "IPV6_AUTOCONF=no" >> /etc/sysconfig/network.cobbler
+            #end if
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+        #end if
+
+        #if $ipv6_default_device != ""
+grep -v IPV6_DEFAULTDEV /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+echo "IPV6_DEFAULTDEV=$ipv6_default_device" >> /etc/sysconfig/network.cobbler
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+        #end if
+
+    #end if
+
     ## =============================================================================
     ## now create the config file for each interface
     #for $iname in $ikeys
 # Start configuration for $iname
         ## create lots of variables to use later
-        #set $idata          = $interfaces[$iname]
-        #set $mac            = $idata["mac_address"].upper()
-        #set $static         = $idata["static"]
-        #set $ip             = $idata["ip_address"]
-        #set $netmask        = $idata["subnet"]
-        #set $static_routes  = $idata["static_routes"]
-        #set $bonding        = $idata["bonding"]
-        #set $bonding_master = $idata["bonding_master"]
-        #set $bonding_opts   = $idata["bonding_opts"]
-        #set $devfile        = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
-        #set $routesfile     = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
+        #set $idata                = $interfaces[$iname]
+        #set $mac                  = $idata["mac_address"].upper()
+        #set $mtu                  = $idata["mtu"]
+        #set $static               = $idata["static"]
+        #set $ip                   = $idata["ip_address"]
+        #set $netmask              = $idata["subnet"]
+        #set $static_routes        = $idata["static_routes"]
+        #set $bonding              = $idata["bonding"]
+        #set $bonding_master       = $idata["bonding_master"]
+        #set $bonding_opts         = $idata["bonding_opts"]
+        #set $ipv6_address         = $idata["ipv6_address"]
+        #set $ipv6_secondaries     = $idata["ipv6_secondaries"]
+        #set $ipv6_mtu             = $idata["ipv6_mtu"]
+        #set $ipv6_default_gateway = $idata["ipv6_default_gateway"]
+        #set $ipv6_static_routes   = $idata["ipv6_static_routes"]
+        #set $devfile              = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
+        #set $routesfile           = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
+        #set $ipv6_routesfile      = "/etc/sysconfig/network-scripts/cobbler/route6-" + $iname
         ## determine if this interface is for a VLAN
         #if $vlanpattern.match($iname)
             ## If this is a VLAN interface, skip it, anaconda doesn't know
@@ -140,9 +181,37 @@ echo "NETMASK=$netmask" >> $devfile
                     ## we don't have enough info for static configuration
 echo "BOOTPROTO=none" >> $devfile
                 #end if
+                #if $enableipv6 == True and $ipv6_address == "" and $ipv6_secondaries == ""
+echo "IPV6INIT=no" >> $devfile
+                #end if
+                #if $enableipv6 == True and $ipv6_autoconfiguration == False
+                    #if $ipv6_address != ""
+echo "IPV6INIT=yes" >> $devfile
+echo "IPV6ADDR=$ipv6_address" >> $devfile
+                    #end if
+                    #if $ipv6_secondaries != ""
+                        #set ipv6_secondaries = ' '.join(ipv6_secondaries)
+                        ## The quotes around the ipv6 ip's need to be here
+echo 'IPV6ADDR_SECONDARIES="$ipv6_secondaries"' >> $devfile
+                    #end if
+                    #if $ipv6_mtu != ""
+echo "IPV6MTU=$ipv6_mtu" >> $devfile
+                    #end if
+                    #if $ipv6_default_gateway != ""
+echo "IPV6_DEFAULTGW=$ipv6_default_gateway" >> $devfile
+                    #end if
+                #end if
             #else
+                #if $ip == ""
+                ## this interface has no IPv4 address set
+echo "BOOTPROTO=none" >> $devfile
+                #else
                 ## this is a DHCP interface, much less work to do
 echo "BOOTPROTO=dhcp" >> $devfile
+                #end if
+            #end if
+            #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
             #end if
         #else if $is_vlan == "true" or $bonding.lower() == "master"
             ## Handle non-physical interfaces with special care. :)
@@ -178,6 +247,9 @@ echo "BOOTPROTO=none" >> $devfile
             #else
 echo "BOOTPROTO=dhcp" >> $devfile
             #end if
+            #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
+            #end if
         #else if $configbymac == False
             ## We'll end up here when not all physical interfaces present for
             ## this system have MAC-addresses configured for them. We don't
@@ -214,6 +286,9 @@ echo "BOOTPROTO=none" >> $devfile
                 ## this is a DHCP interface, much less work to do
 echo "BOOTPROTO=dhcp" >> $devfile
             #end if
+            #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
+            #end if
         #else
             # If you end up here, please mail the list... This shouldn't
             # happen. ;-) -- jcapel
@@ -225,19 +300,32 @@ echo "BOOTPROTO=dhcp" >> $devfile
                 #set $nct = $nct + 1
 echo "DNS$nct=$nameserver" >> $devfile
             #end for
-	#end if
-	#for $route in $static_routes
-	    #set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
-	    #if $routepattern.match($route)
-                #set $routebits = $route.split(":")
-                #set [$network, $router] = $route.split(":")
+           #end if
+               #for $route in $static_routes
+                       #set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
+                       #if $routepattern.match($route)
+                               #set $routebits = $route.split(":")
+                               #set [$network, $router] = $route.split(":")
 echo "$network via $router" >> $routesfile
-	    #else
+                       #else
+                               # Warning: invalid route "$route"
+                       #end if
+               #end for
+    #if $enableipv6 == True
+        #for $route in $ipv6_static_routes
+            #set routepattern = $re.compile("[0-9a-fA-F:/]+,[0-9a-fA-F:]+")
+            #if $routepattern.match($route)
+                #set $routebits = $route.split(",")
+                #set [$network, $router] = $route.split(",")
+echo "$network via $router dev $iname" >> $ipv6_routesfile
+            #else
                 # Warning: invalid route "$route"
             #end if
 	#end for
+    #end if
 	#set $i = $i + 1
 # End configuration for $iname
+
     #end for	
     ## =============================================================================
     ## Configure name server search path in /etc/resolv.conf