blob: 59d1cd3ccc7708f82ac9095e4defd41bdf178713 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#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
|