forked from openshift-metal3/dev-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ocp_cleanup.sh
executable file
·56 lines (48 loc) · 1.87 KB
/
ocp_cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -x
source logging.sh
source common.sh
source ocp_install_env.sh
sudo systemctl stop fix_certs.timer
if [ -d ${OCP_DIR} ]; then
${OCP_DIR}/openshift-install --dir ${OCP_DIR} --log-level=debug destroy bootstrap
${OCP_DIR}/openshift-install --dir ${OCP_DIR} --log-level=debug destroy cluster
rm -rf ${OCP_DIR}
fi
sudo rm -rf /etc/NetworkManager/dnsmasq.d/openshift-${CLUSTER_NAME}.conf
# Cleanup ssh keys for baremetal network
if [ -f $HOME/.ssh/known_hosts ]; then
EXT_SUB_V4=$(echo "${EXTERNAL_SUBNET_V4}" | cut -d"/" -f1 | sed "s/0$//")
if [ -n "${EXT_SUB_V4}" ]; then
sed -i "/^${EXT_SUB_V4}/d" $HOME/.ssh/known_hosts
fi
EXT_SUB_V6=$(echo "${EXTERNAL_SUBNET_V6}" | cut -d"/" -f1 | sed "s/0$//")
if [ -n "${EXT_SUB_V6}" ]; then
sed -i "/^${EXT_SUB_V6}/d" $HOME/.ssh/known_hosts
fi
PRO_SUB=$(echo "${PROVISIONING_NETWORK}" | cut -d"/" -f1 | sed "s/0$//")
if [ -n "${PRO_SUB}" ]; then
sed -i "/^${PRO_SUB}/d" $HOME/.ssh/known_hosts
fi
sed -i "/^api.${CLUSTER_DOMAIN}/d" $HOME/.ssh/known_hosts
fi
if test -f assets/templates/98_master-chronyd-redhat.yaml ; then
rm -f assets/templates/98_master-chronyd-redhat.yaml
fi
if test -f assets/templates/98_worker-chronyd-redhat.yaml ; then
rm -f assets/templates/98_worker-chronyd-redhat.yaml
fi
# If the installer fails before terraform completes the destroy bootstrap
# cleanup doesn't clean up the VM/volumes created..
for vm in $(sudo virsh list --all --name | grep "^${CLUSTER_NAME}.*bootstrap"); do
sudo virsh destroy $vm
sudo virsh undefine $vm --remove-all-storage
done
# The .ign volume isn't deleted via --remove-all-storage
VOLS="$(sudo virsh vol-list --pool default | awk '{print $1}' | grep "^${CLUSTER_NAME}.*bootstrap")"
for v in $VOLS; do
sudo virsh vol-delete $v --pool default
done
if [ -d assets/generated ]; then
rm -rf assets/generated
fi