aboutsummaryrefslogtreecommitdiffstats
path: root/charms/trusty/neutron-contrail/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'charms/trusty/neutron-contrail/scripts')
-rwxr-xr-xcharms/trusty/neutron-contrail/scripts/create-vrouter.sh133
-rw-r--r--charms/trusty/neutron-contrail/scripts/interfaces7
-rw-r--r--charms/trusty/neutron-contrail/scripts/juju-header5
-rwxr-xr-xcharms/trusty/neutron-contrail/scripts/remove-juju-bridge.sh17
-rwxr-xr-xcharms/trusty/neutron-contrail/scripts/vhost-phys.sh6
-rw-r--r--charms/trusty/neutron-contrail/scripts/vrouter-interfaces.awk38
6 files changed, 0 insertions, 206 deletions
diff --git a/charms/trusty/neutron-contrail/scripts/create-vrouter.sh b/charms/trusty/neutron-contrail/scripts/create-vrouter.sh
deleted file mode 100755
index 686a7b7..0000000
--- a/charms/trusty/neutron-contrail/scripts/create-vrouter.sh
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/sh -e
-#
-# Script used to configure vRouter interface
-
-configVRouter()
-{
- cat juju-header
- echo "auto $1"
- if [ -e "$2" ]; then
- cat "$2"
- else
- echo "iface $1 inet manual"
- fi
- printf "\n%s\n" "auto vhost0"
- if [ -e "$3" ]; then
- cat "$3"
- else
- echo "iface vhost0 inet dhcp"
- fi
- cat <<-EOF
- pre-up ip link add address \$(cat /sys/class/net/$1/address) type vhost
- pre-up vif --add $1 --mac \$(cat /sys/class/net/$1/address) --vrf 0 --vhost-phys --type physical
- pre-up vif --add vhost0 --mac \$(cat /sys/class/net/$1/address) --vrf 0 --type vhost --xconnect $1
- post-down vif --list | awk '/^vif.*OS: vhost0/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete
- post-down vif --list | awk '/^vif.*OS: $1/ {split(\$1, arr, "\\/"); print arr[2];}' | xargs vif --delete
- post-down ip link delete vhost0
- EOF
-}
-
-ifacedown()
-{
- for iface; do
- # ifdown interface
- # if bridge, save list of interfaces
- # if bond, save list of slaves
- if [ ! -e /sys/class/net/$iface ]; then
- continue
- fi
- [ -d /sys/class/net/$iface/bridge ] && saveIfaces $iface
- [ -d /sys/class/net/$iface/bonding ] && saveSlaves $iface
- ifdown --force $iface
- done
-}
-
-ifaceup()
-{
- for iface; do
- # ifup interface
- # if bridge, restore list of interfaces
- # restore list of slaves if exists (bond)
- restoreSlaves $iface
- ifup $iface
- [ -d /sys/class/net/$iface/bridge ] && restoreIfaces $iface
- done
- return 0
-}
-
-restoreIfaces()
-{
- if [ -e $TMP/$1.ifaces ]; then
- cat $TMP/$1.ifaces | xargs -n 1 brctl addif $1 || true
- fi
-}
-
-restoreSlaves()
-{
- if [ -e $TMP/$1.slaves ]; then
- cat $TMP/$1.slaves | xargs ifup
- fi
-}
-
-saveIfaces()
-{
- if [ -z "$(find /sys/class/net/$1/brif -maxdepth 0 -empty)" ]; then
- find /sys/class/net/$1/brif | tail -n +2 | xargs -n 1 basename \
- > $TMP/$1.ifaces
- fi
-}
-
-saveSlaves()
-{
- if [ -s /sys/class/net/$1/bonding/slaves ]; then
- cat /sys/class/net/$1/bonding/slaves | tr " " "\n" \
- > $TMP/$1.slaves
- fi
-}
-
-TMP=$(mktemp -d /tmp/create-vrouter.XXX)
-
-if [ $# -ne 0 ]; then
- interface=$1
-else
- # use default gateway interface
- interface=$(route -n | awk '$1 == "0.0.0.0" { print $8 }')
-fi
-
-ifacedown $interface vhost0; sleep 5
-# add interfaces.d source line to /etc/network/interfaces
-if ! grep -q '^[[:blank:]]*source /etc/network/interfaces\.d/\*\.cfg[[:blank:]]*$' \
- /etc/network/interfaces; then
- printf "\n%s\n" "source /etc/network/interfaces.d/*.cfg" \
- >> /etc/network/interfaces
- # it's possible for conflicting network config to exist in
- # /etc/network/interfaces.d when we start sourcing it
- # so disable any config as a precautionary measure
- for cfg in /etc/network/interfaces.d/*.cfg; do
- [ -e "$cfg" ] || continue
- mv "$cfg" "$cfg.save"
- done
-fi
-mkdir -p /etc/network/interfaces.d
-for cfg in /etc/network/interfaces /etc/network/interfaces.d/*.cfg \
- /etc/network/*.config; do
- # for each network interfaces config, extract the config for
- # the chosen interface whilst commenting it out in the subsequent
- # replacement config
- [ -e "$cfg" ] || continue
- awk -v interface=$interface -v interface_cfg=$TMP/interface.cfg \
- -v vrouter_cfg=$TMP/vrouter.cfg -f vrouter-interfaces.awk "$cfg" \
- > $TMP/interfaces.cfg
- if ! diff $TMP/interfaces.cfg "$cfg" > /dev/null; then
- # create backup
- mv "$cfg" "$cfg.save"
- # substitute replacement config for original config
- cat juju-header $TMP/interfaces.cfg > "$cfg"
- fi
-done
-# use extracted interface config to create new vrouter config
-configVRouter $interface $TMP/interface.cfg $TMP/vrouter.cfg \
- > /etc/network/interfaces.d/vrouter.cfg
-ifaceup $interface vhost0
-
-rm -rf $TMP
diff --git a/charms/trusty/neutron-contrail/scripts/interfaces b/charms/trusty/neutron-contrail/scripts/interfaces
deleted file mode 100644
index 0356643..0000000
--- a/charms/trusty/neutron-contrail/scripts/interfaces
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file describes the network interfaces available on your system
-# and how to activate them. For more information see interfaces(5).
-
-# The loopback network interface
-auto lo
-iface lo inet loopback
-
diff --git a/charms/trusty/neutron-contrail/scripts/juju-header b/charms/trusty/neutron-contrail/scripts/juju-header
deleted file mode 100644
index fccac13..0000000
--- a/charms/trusty/neutron-contrail/scripts/juju-header
+++ /dev/null
@@ -1,5 +0,0 @@
-###############################################################################
-# [ WARNING ]
-# Configuration file maintained by Juju. Local changes may be overwritten.
-###############################################################################
-
diff --git a/charms/trusty/neutron-contrail/scripts/remove-juju-bridge.sh b/charms/trusty/neutron-contrail/scripts/remove-juju-bridge.sh
deleted file mode 100755
index d9a9ec1..0000000
--- a/charms/trusty/neutron-contrail/scripts/remove-juju-bridge.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh -e
-#
-# Script used to remove Juju LXC bridge on MAAS systems
-
-if [ ! -e /sys/class/net/juju-br0 ]; then
- exit 0
-fi
-
-interface=$(find /sys/class/net/juju-br0/brif | sed -n -e '2p' | xargs basename)
-
-ifdown --force $interface juju-br0; sleep 5
-cp interfaces /etc/network
-cat <<-EOF >> /etc/network/interfaces
- auto $interface
- iface $interface inet dhcp
- EOF
-ifup $interface
diff --git a/charms/trusty/neutron-contrail/scripts/vhost-phys.sh b/charms/trusty/neutron-contrail/scripts/vhost-phys.sh
deleted file mode 100755
index 6565d1c..0000000
--- a/charms/trusty/neutron-contrail/scripts/vhost-phys.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh -e
-#
-# Script used to determine physical interface of vhost0
-
-mac=$(cat /sys/class/net/vhost0/address)
-vif --list | awk -v mac=$mac 'BEGIN { RS="\n\n" }; $3 != "vhost0" && $0 ~ "HWaddr:" mac { print $3; exit 0 }'
diff --git a/charms/trusty/neutron-contrail/scripts/vrouter-interfaces.awk b/charms/trusty/neutron-contrail/scripts/vrouter-interfaces.awk
deleted file mode 100644
index d8e5851..0000000
--- a/charms/trusty/neutron-contrail/scripts/vrouter-interfaces.awk
+++ /dev/null
@@ -1,38 +0,0 @@
-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 }