Thomas Vachuska

Adding tools for next version of warden.

Change-Id: I35b0ac57b54b0bf7b8c6b6a40e02f050b3fcc7f1
#!/bin/bash
# Creates a cell definition from the given name and LXC info
name="$1"
apps="${2:-drivers,openflow,proxyarp,mobility,pathpainter}"
echo "export ONOS_CELL=borrow"
echo "export ONOS_NIC=\"10.128.11.*\""
sudo lxc-ls -F "name,ipv4" --fancy | grep $name | \
sed "s/^$name/OC/" | tr "[:lower:]" "[:upper:]" | \
sed -r 's/[ ]+/\=/;s/^/export /'
echo "export OCT=\"\$OC1\""
echo "export ONOS_USE_SSH=true"
echo "export ONOS_APPS=${apps}"
#!/bin/bash
# Creates a new node from the base image.
base="$1"
ip="$2"
name="$3"
key="$4"
sudo lxc-clone -o $base -n $name
sudo chmod 777 /var/lib/lxc
sudo chmod 777 /var/lib/lxc/$name
sudo chmod 666 /var/lib/lxc/$name/config
sudo cat >>/var/lib/lxc/$name/config <<EOF
lxc.network.ipv4 = ${ip}/16
lxc.network.ipv4.gateway = 10.128.0.1
EOF
sudo chmod 644 /var/lib/lxc/$name/config
sudo chmod 750 /var/lib/lxc/$name
sudo chmod 700 /var/lib/lxc
sudo lxc-start -d -n $name
sudo lxc-attach -n $name -- ping -c1 8.8.8.8
sudo lxc-attach -n $name -- bash -c "echo $key >> /home/sdn/.ssh/authorized_keys"
sudo lxc-ls --fancy
#!/bin/bash
# Creates a new cell.
name="$1"
ipx="$2"
key="$3"
cd $(dirname $0)
./clone-node base-mininet ${ipx/x/0} $name-mn "$key"
for n in {1..3}; do
./clone-node base-onos ${ipx/x/$n} $name-$n "$key"
done
#!/bin/bash
# Destroys an LXC cell with the specified name.
name=$1
cd $(dirname $0)
./destroy-node $name-mn
for n in {1..3}; do
./destroy-node $name-$n
done
#!/bin/bash
# Destroys an LXC node with the specified name.
name=$1
[ "$name" = "onos-base" ] && echo "Don't do that!" && exit 1
[ "$name" = "mininet-base" ] && echo "Don't do that!" && exit 1
sudo lxc-stop -n $name
sudo lxc-destroy -n $name