#if $getVar("system_name","") != "" # Start pre_install_network_config generated code #set ikeys = $interfaces.keys() #import re #set $vlanpattern = $re.compile("[a-zA-Z0-9]+\.[0-9]+") ## ## Determine if we should use the MAC address to configure the interfaces first ## Only physical interfaces are required to have a MAC address #set $configbymac = True #for $iname in $ikeys #set $idata = $interfaces[$iname] #if $idata["mac_address"] == "" and not $vlanpattern.match($iname) and not $idata["bonding"].lower() == "master" #set $configbymac = False #end if #end for #set $i = 0 #if $configbymac ## Output diagnostic message # Start of code to match cobbler system interfaces to physical interfaces by their mac addresses #end if #for $iname in $ikeys # Start $iname #set $idata = $interfaces[$iname] #set $mac = $idata["mac_address"] #set $static = $idata["static"] #set $ip = $idata["ip_address"] #set $netmask = $idata["subnet"] #set $bonding = $idata["bonding"] #set $bonding_master = $idata["bonding_master"] #set $bonding_opts = $idata["bonding_opts"] #set $devfile = "/etc/sysconfig/network-scripts/ifcfg-" + $iname #if $vlanpattern.match($iname) ## If this is a VLAN interface, skip it, anaconda doesn't know ## about VLANs. #set $is_vlan = "true" #else #set $is_vlan = "false" #end if #if ($configbymac and $is_vlan == "false" and $bonding.lower() != "slave") or $bonding.lower() == "master" ## This is a physical interface, hand it to anaconda. Do not ## process bonding slaves here. #if $bonding.lower() == "master" ## Find a slave for this interface #for $tiname in $ikeys #set $tidata = $interfaces[$tiname] #if $tidata["bonding"].lower() == "slave" and $tidata["bonding_master"].lower() == $iname #set $mac = $tidata["mac_address"] # Found a slave for this interface: $tiname ($mac) #break #end if #end for #end if #if $static and $ip != "" #if $netmask == "" ## Netmask not provided, default to /24. #set $netmask = "255.255.255.0" #end if #set $netinfo = "--bootproto=static --ip=%s --netmask=%s" % ($ip, $netmask) #if $gateway != "" #set $netinfo = "%s --gateway=%s" % ($netinfo, $gateway) #end if #else if not $static #set $netinfo = "--bootproto=dhcp" #else ## Skip this interface, it's set as static, but without ## networking info. # Skipping (no configuration)... #continue #end if #if $hostname != "" #set $netinfo = "%s --hostname=%s" % ($netinfo, $hostname) #end if # Configuring $iname ($mac) if ifconfig -a | grep -i $mac then IFNAME=\$(ifconfig -a | grep -i '$mac' | cut -d " " -f 1) echo "network --device=\$IFNAME $netinfo" >> /tmp/pre_install_network_config fi #else #if $bonding.lower() == "slave" # Skipping (slave-interface) #else # Skipping (not a physical interface)... #end if #end if #end for # End pre_install_network_config generated code #end if