blob: 051a141ff7d36e2139b6ee6384f38a650d6c5b18 [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Matteo Scandolo9e557c62017-03-15 11:03:13 -070017#!/bin/bash
18
19function cleanup_network {
20 NETWORK=$1
21 SUBNETS=`neutron net-show $NETWORK | grep -i subnets | awk '{print $4}'`
22 if [[ $SUBNETS != "" ]]; then
23 PORTS=`neutron port-list | grep -i $SUBNETS | awk '{print $2}'`
24 for PORT in $PORTS; do
25 echo "Deleting port $PORT"
26 neutron port-delete $PORT
27 done
28 fi
29 neutron net-delete $NETWORK
30}
31
Zack Williamsa88041c2017-09-13 10:11:55 -070032source /opt/cord_profile/admin-openrc.sh
Matteo Scandolo9e557c62017-03-15 11:03:13 -070033
34echo "Deleting VMs"
35# Delete all VMs
36VMS=$( nova list --all-tenants|grep mysite|awk '{print $2}' )
37for VM in $VMS
38do
39 nova delete $VM
40done
41
42echo "Waiting 5 seconds..."
43sleep 5
44
45cleanup_network lan_network
46cleanup_network wan_network
47cleanup_network mysite_vcpe-private
48cleanup_network mysite_vsg-access
49cleanup_network management
50cleanup_network management_hosts
51
52echo "Deleting networks"
53# Delete all networks beginning with mysite_
54NETS=$( neutron net-list --all-tenants|grep mysite|awk '{print $2}' )
55for NET in $NETS
56do
57 neutron net-delete $NET
58done
59
60neutron net-delete lan_network || true
61neutron net-delete subscriber_network || true
62neutron net-delete public_network || true
63neutron net-delete hpc_client_network || true
64neutron net-delete ceilometer_network || true
65neutron net-delete management || true
66neutron net-delete management_hosts || true
67neutron net-delete mysite_vsg-access || true
68neutron net-delete public || true
69neutron net-delete exampleservice_network || true