blob: 23b288aecdf2a541d3b1ff0681bb7c7432f626c2 [file] [log] [blame]
Jon Hall685359e2015-08-28 11:11:47 -07001#!/bin/bash
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002
3# Copyright 2015 Open Networking Foundation (ONF)
4#
5# Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6# the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7# or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
8#
9# TestON is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 2 of the License, or
12# (at your option) any later version.
13#
14# TestON is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with TestON. If not, see <http://www.gnu.org/licenses/>.
21
Jon Hall6e709752016-02-01 13:38:46 -080022# -----------------------------------------------------------------------------
Jon Hall3a440102015-07-06 14:47:26 -070023# This script will kill any TestON, ssh, and Mininet sessions that are running.
Jon Hall6e709752016-02-01 13:38:46 -080024# -----------------------------------------------------------------------------
25
26# TODO: Add help to this file, and some more options?
27# Maybe kill/uninstall ONOS?
Jon Hall3a440102015-07-06 14:47:26 -070028sudo kill -9 `ps -ef | grep "./cli.py" | grep -v grep | awk '{print $2}'`
Jon Hallf632d202015-07-30 15:45:11 -070029sudo kill -9 `ps -ef | grep "bin/teston" | grep -v grep | awk '{print $2}'`
Jon Hall3a440102015-07-06 14:47:26 -070030sudo kill -9 `ps -ef | grep "ssh -X" | grep -v grep | awk '{print $2}'`
Jon Hallbe6b5232018-04-12 10:52:52 -070031sudo kill -9 `ps ax | grep '[p]ython -m SimpleHTTPServer 8000' | awk '{print $1}'`
Jon Hall6e709752016-02-01 13:38:46 -080032
Jon Hall5eea0812018-06-13 13:02:43 -070033export user=${ONOS_USER:-$USER}
You Wanged0df382018-04-16 13:25:02 -070034if [[ -z "${OCN}" ]]; then
35 echo "Mininet cleanup skipped because OCN is not defined"
36else
Jon Hall5eea0812018-06-13 13:02:43 -070037 ssh $user@$OCN """
You Wanged0df382018-04-16 13:25:02 -070038 sudo killall -9 dhclient dhcpd zebra bgpd vrrpd bird
39 sudo mn -c
40 sudo pkill -f mn.pid
41 """
42fi
Jon Hall6e709752016-02-01 13:38:46 -080043
44# Restore persistent firewall rules
45if [ "$1" = "-f" ]; then
46
47 OCIS=( $(env | sed -ne 's:OC[0-9]\{1,\}=\(.*\):\1 :g p' | sort -k1) )
48 if [ -z "$OCIS" ]; then
49 printf "no ONOS nodes set in your cell, Don't know where to look" >&2 && exit 0
50 fi
51
52 # TODO: Make the file configurable
53 for i in ${OCIS[@]}; do
54 echo "Restoring iptables rules on ${i}"
55 ssh sdn@$i "sudo iptables -F"
56 ssh sdn@$i "sudo iptables-restore < /etc/iptables/rules.v4"
Jon Hall701fea12018-10-08 11:09:22 -070057 echo "Restoring ip6tables rules on ${i}"
58 ssh sdn@$i "sudo ip6tables -F"
59 ssh sdn@$i "sudo ip6tables-restore < /etc/iptables/rules.v6"
Jon Hall6e709752016-02-01 13:38:46 -080060 done
61fi