Fix: Update lf-activate-venv
[releng/builder.git] / jjb / packaging / openstack-k8s-cluster-delete.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2021 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # shellcheck disable=SC2153,SC2034
12 echo "---> Delete K8S cluster"
13
14 set -eux -o pipefail
15
16 # shellcheck disable=SC1090
17 . ~/lf-env.sh
18
19 lf-activate-venv --python python3 \
20     kubernetes \
21     python-heatclient \
22     python-openstackclient \
23     yq
24
25 os_cloud="${OS_CLOUD:-vex}"
26 cluster_name="${CLUSTER_NAME}"
27
28 cluster_delete_status="$(openstack --os-cloud "$OS_CLOUD" coe cluster delete "${CLUSTER_NAME}")"
29 if [[ -z "$cluster_delete_status" ]]; then
30     echo "ERROR: Failed to delete coe cluster ${cluster_name}"
31     exit 1
32 elif [[ "${cluster_delete_status}" =~ .*accepted.* ]]; then
33     echo "Cluster ${CLUSTER_NAME} delete in progress ..."
34     echo "${cluster_delete_status}"
35 fi