Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 145 lines (118 sloc) 3.894 kb
#!/bin/bash
if [ "$EUID" != "0" ]; then
echo "You must be root to run this script."
exit 1
fi
SCRIPT_NAME="rftest1"
LXCDIR=/var/lib/lxc
MONGODB_CONF=/etc/mongodb.conf
MONGODB_PORT=27017
CONTROLLER_PORT=6633
RF_HOME=..
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
export PYTHONPATH=$PYTHONPATH:$RF_HOME
cd $RF_HOME
wait_port_listen() {
port=$1
while ! `nc -z localhost $port` ; do
echo -n .
sleep 1
done
}
echo_bold() {
echo -e "\033[1m${1}\033[0m"
}
kill_process_tree() {
top=$1
pid=$2
children=`ps -o pid --no-headers --ppid ${pid}`
for child in $children
do
kill_process_tree 0 $child
done
if [ $top -eq 0 ]; then
kill -9 $pid &> /dev/null
fi
}
reset() {
init=$1;
if [ $init -eq 1 ]; then
echo_bold "-> Starting $SCRIPT_NAME";
else
echo_bold "-> Stopping child processes...";
kill_process_tree 1 $$
fi
sudo ovs-vsctl del-br dp0 &> /dev/null;
sudo ovs-vsctl del-br switch1 &> /dev/null;
sudo ovs-vsctl emer-reset &> /dev/null;
echo_bold "-> Stopping and resetting LXC VMs...";
lxc-shutdown -n rfvm1;
lxc-shutdown -n b1;
lxc-shutdown -n b2;
echo_bold "-> Deleting data from previous runs...";
mongo db --eval "
db.getCollection('rftable').drop();
db.getCollection('rfconfig').drop();
db.getCollection('rfstats').drop();
db.getCollection('rfclient<->rfserver').drop();
db.getCollection('rfserver<->rfproxy').drop();
"
rm -rf $LXCDIR/rfvm1/rootfs/var/run/network/ifstate;
rm -rf $LXCDIR/b1/rootfs/var/run/network/ifstate;
rm -rf $LXCDIR/b2/rootfs/var/run/network/ifstate;
rm -rf /var/lib/lxc/rfvm1/rootfs/opt/rfclient;
}
reset 1
trap "reset 0; exit 0" INT
echo_bold "-> Setting up the management bridge (lxcbr0)..."
ifconfig lxcbr0 192.169.1.1 up
echo_bold "-> Setting up MongoDB..."
sed -i "/bind_ip/c\bind_ip = 127.0.0.1,192.169.1.1" $MONGODB_CONF
service mongodb restart
wait_port_listen $MONGODB_PORT
echo_bold "-> Starting the rfvm1 virtual machine..."
# Create the rfclient dir
mkdir /var/lib/lxc/rfvm1/rootfs/opt/rfclient
# Copy the rfclient executable
cp build/rfclient /var/lib/lxc/rfvm1/rootfs/opt/rfclient/rfclient
# We sleep for a few seconds to wait for the interfaces to go up
echo "#!/bin/sh" > /var/lib/lxc/rfvm1/rootfs/root/run_rfclient.sh
echo "sleep 3" >> /var/lib/lxc/rfvm1/rootfs/root/run_rfclient.sh
echo "/opt/rfclient/rfclient > /var/log/rfclient.log" >> /var/lib/lxc/rfvm1/rootfs/root/run_rfclient.sh
chmod +x /var/lib/lxc/rfvm1/rootfs/root/run_rfclient.sh
lxc-start -n rfvm1 -d
echo_bold "-> Starting the controller and RFPRoxy..."
cd pox
./pox.py log.level --=INFO topology openflow.topology openflow.discovery rfproxy rfstats &
cd -
wait_port_listen $CONTROLLER_PORT
echo_bold "-> Starting RFServer..."
./rfserver/rfserver.py rftest/rftest1config.csv &
echo_bold "-> Starting the control plane network (dp0 VS)..."
ovs-vsctl add-br dp0
ovs-vsctl add-port dp0 rfvm1.1
ovs-vsctl add-port dp0 rfvm1.2
ovs-vsctl set Bridge dp0 other-config:datapath-id=7266767372667673
ovs-vsctl set-controller dp0 tcp:127.0.0.1:$CONTROLLER_PORT
ifconfig dp0 up
echo_bold "-> Starting the sample network..."
# Start the host VMs and give them a little time
lxc-start -n b1 -d
lxc-start -n b2 -d
sleep 2
ovs-vsctl add-br switch1
ovs-vsctl add-port switch1 b1.0
ovs-vsctl add-port switch1 b2.0
ovs-vsctl set Bridge switch1 other-config:datapath-id=0000000000000099
ovs-vsctl set-controller switch1 tcp:127.0.0.1:$CONTROLLER_PORT
ifconfig switch1 up
echo_bold "---"
echo_bold "This test is up and running."
echo_bold "Try pinging host b2 from host b1:"
echo_bold " $ sudo lxc-console -n b1"
echo_bold "Login and run:"
echo_bold " $ ping 172.31.2.2"
echo_bold "You can stop this test by pressing Ctrl+C."
echo_bold "---"
wait
exit 0
Jump to Line
Something went wrong with that request. Please try again.