summaryrefslogtreecommitdiffstats
path: root/snippets/network_config
blob: ec1c9aca2079b2f43ddca51a960428a290968418 (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
## start of cobbler network_config generated code
#if $getVar("system_name","") != ""
    #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 = -1
    #if $configbymac
# Using "new" style networking config, by matching networking information to the physical interface's 
# MAC-address
%include /tmp/pre_install_network_config
    #else
# Using "old" style networking config. Make sure all MAC-addresses are in cobbler to use the new-style config
        #set $vlanpattern = $re.compile("[a-zA-Z0-9]+\.[0-9]+")
        #for $iname in $ikeys
            #set $idata    = $interfaces[$iname]
            #set $mac      = $idata["mac_address"]
            #set $static   = $idata["static"]
            #set $ip       = $idata["ip_address"]
            #set $netmask  = $idata["subnet"]
            #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"
                ## Only up the counter on physical interfaces!
                #set $i = $i + 1 
            #end if
            #if $mac != "" or $ip != "" and $is_vlan == "false"
                #if $static == "True":
                    #if $ip != "":
                        #set $network_str = "--bootproto=static"
                        #set $network_str = $network_str + " --ip=" + $ip 
                        #if $netmask != "":
                            #set $network_str = $network_str + " --netmask=" + $netmask 
                        #end if
                        #if $gateway != "":
                            #set $network_str = $network_str + " --gateway=" + $gateway
                        #end if
                        #if $name_servers and $name_servers[0] != "":
                            ## Anaconda only allows one nameserver
                            #set $network_str = $network_str + " --nameserver=" + $name_servers[0]
                        #end if
                    #else
                        #set $network_str = "--bootproto=none"
                    #end if
                #else
                    #set $network_str = "--bootproto=dhcp"
                #end if
                #if $hostname != ""
                    #set $network_str = $network_str + " --hostname=" + $hostname
                #end if
            #else
                #set $network_str = "--bootproto=dhcp"
            #end if
    ## network details are populated from the cobbler system object
            #if $is_vlan == "false"
network $network_str --device=$iname --onboot=on
            #end if
        #end for
    #end if
#else
## profile based install so just provide one interface for starters
network --bootproto=dhcp --device=eth0 --onboot=on  
#end if
## end of cobbler network_config generated code