blob: 6cee999fe0efb2517b058e4a52a234564105826f [file] [log] [blame]
beierlm107d16a2020-05-15 21:47:43 -04001#! /bin/bash
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15function remove_iptables() {
16 stack=$1
17 if [ -z "$OSM_VCA_HOST" ]; then
18 OSM_VCA_HOST=`sg lxd -c "juju show-controller controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
19 [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
20 fi
21
22 if [ -z "$DEFAULT_IP" ]; then
23 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
24 [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
25 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
26 [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
27 fi
28
29 if sudo iptables -t nat -C PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST; then
30 sudo iptables -t nat -D PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST
31 sudo netfilter-persistent save
32 fi
33}
34
35remove_iptables
36juju destroy-model osm-on-k8s --destroy-storage
37juju destroy-model test --destroy-storage
38sudo snap unalias osm
39sudo snap remove osmclient