Feat: Add Job template to deploy ODL on K8S Magnum
[releng/builder.git] / jjb / packaging / openstack-k8s-cluster-delete.sh
diff --git a/jjb/packaging/openstack-k8s-cluster-delete.sh b/jjb/packaging/openstack-k8s-cluster-delete.sh
new file mode 100644 (file)
index 0000000..7550ded
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# shellcheck disable=SC2153,SC2034
+echo "---> Delete K8S cluster"
+
+set -eux -o pipefail
+# shellcheck disable=SC1090
+source ~/lf-env.sh
+
+os_cloud="${OS_CLOUD:-vex}"
+cluster_name="${CLUSTER_NAME}"
+
+cluster_delete_status="$(openstack --os-cloud "$OS_CLOUD" coe cluster delete "${CLUSTER_NAME}")"
+if [[ -z "$cluster_delete_status" ]]; then
+    echo "ERROR: Failed to delete coe cluster ${cluster_name}"
+    exit 1
+elif [[ "${cluster_delete_status}" =~ .*accepted.* ]]; then
+    echo "Cluster ${CLUSTER_NAME} delete in progress ..."
+    echo "${cluster_delete_status}"
+fi