Jon Hall | 685359e | 2015-08-28 11:11:47 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | |
| 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 Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 22 | # ----------------------------------------------------------------------------- |
Jon Hall | 3a44010 | 2015-07-06 14:47:26 -0700 | [diff] [blame] | 23 | # This script will kill any TestON, ssh, and Mininet sessions that are running. |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 24 | # ----------------------------------------------------------------------------- |
| 25 | |
| 26 | # TODO: Add help to this file, and some more options? |
| 27 | # Maybe kill/uninstall ONOS? |
Yi Tseng | 6dace01 | 2021-09-07 14:09:50 -0700 | [diff] [blame] | 28 | sudo kill -9 `ps -ef | grep "./cli.py" | grep -v grep | awk '{print $2}'` &> /dev/null |
| 29 | sudo kill -9 `ps -ef | grep "bin/teston" | grep -v grep | awk '{print $2}'` &> /dev/null |
| 30 | sudo kill -9 `ps -ef | grep "/usr/bin/ssh" | grep -v grep | awk '{print $2}'` &> /dev/null |
| 31 | sudo kill -9 `ps ax | grep '[p]ython -m SimpleHTTPServer 8000' | awk '{print $1}'` &> /dev/null |
| 32 | sudo kill -9 `ps ax | grep 'kubectl' | awk '{print $2}'` &> /dev/null |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 33 | |
Jon Hall | 5eea081 | 2018-06-13 13:02:43 -0700 | [diff] [blame] | 34 | export user=${ONOS_USER:-$USER} |
You Wang | ed0df38 | 2018-04-16 13:25:02 -0700 | [diff] [blame] | 35 | if [[ -z "${OCN}" ]]; then |
| 36 | echo "Mininet cleanup skipped because OCN is not defined" |
| 37 | else |
Jon Hall | 5eea081 | 2018-06-13 13:02:43 -0700 | [diff] [blame] | 38 | ssh $user@$OCN """ |
You Wang | ed0df38 | 2018-04-16 13:25:02 -0700 | [diff] [blame] | 39 | sudo killall -9 dhclient dhcpd zebra bgpd vrrpd bird |
| 40 | sudo mn -c |
| 41 | sudo pkill -f mn.pid |
| 42 | """ |
| 43 | fi |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 44 | |
| 45 | # Restore persistent firewall rules |
| 46 | if [ "$1" = "-f" ]; then |
| 47 | |
| 48 | OCIS=( $(env | sed -ne 's:OC[0-9]\{1,\}=\(.*\):\1 :g p' | sort -k1) ) |
| 49 | if [ -z "$OCIS" ]; then |
| 50 | printf "no ONOS nodes set in your cell, Don't know where to look" >&2 && exit 0 |
| 51 | fi |
| 52 | |
| 53 | # TODO: Make the file configurable |
| 54 | for i in ${OCIS[@]}; do |
| 55 | echo "Restoring iptables rules on ${i}" |
| 56 | ssh sdn@$i "sudo iptables -F" |
| 57 | ssh sdn@$i "sudo iptables-restore < /etc/iptables/rules.v4" |
Jon Hall | 701fea1 | 2018-10-08 11:09:22 -0700 | [diff] [blame] | 58 | echo "Restoring ip6tables rules on ${i}" |
| 59 | ssh sdn@$i "sudo ip6tables -F" |
| 60 | ssh sdn@$i "sudo ip6tables-restore < /etc/iptables/rules.v6" |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 61 | done |
Jon Hall | dac3eae | 2020-06-05 12:04:06 -0700 | [diff] [blame] | 62 | elif [ "$1" = "-d" ]; then |
| 63 | docker stop $(docker ps -aq) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 64 | fi |