aboutsummaryrefslogtreecommitdiffstats
path: root/contrail-agent/scripts/vrouter-interfaces.awk
blob: d8e585147a26f4d5f24d3db3eccbd58166918df1 (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
function strip(s)
{
    sub(/^[[:blank:]]+/, "", s)
    sub(/[[:blank:]]+$/, "", s)
    return s
}

/^[[:blank:]]*(iface|mapping|auto|allow-[^ ]+|source) / {
    s_iface = 0; iface = 0
}

$0 ~ "^[[:blank:]]*auto (" interface "|vhost0)[[:blank:]]*$" { print "#" $0; next }

$0 ~ "^[[:blank:]]*iface (" interface "|vhost0) " {
    s_iface = 1
    if ($2 == interface) {
        iface = 1
        print "iface", interface, $3, "manual" > interface_cfg
        print "iface vhost0", $3, $4 > vrouter_cfg
    }
    print "#" $0
    next
}

s_iface == 1 {
    if (iface == 1) {
        if (match($1, "^address|netmask|broadcast|metric|gateway$")) {
            cfg = vrouter_cfg
        } else {
            cfg = interface_cfg
        }
        print "    " strip($0) > cfg
    }
    print "#" $0
    next
}

{ print $0 }