diff options
Diffstat (limited to 'contrail-agent/scripts/vrouter-interfaces.awk')
-rw-r--r-- | contrail-agent/scripts/vrouter-interfaces.awk | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/contrail-agent/scripts/vrouter-interfaces.awk b/contrail-agent/scripts/vrouter-interfaces.awk new file mode 100644 index 0000000..d8e5851 --- /dev/null +++ b/contrail-agent/scripts/vrouter-interfaces.awk @@ -0,0 +1,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 } |