Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / openstack-stack-delete.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 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 echo "---> openstack-stack-delete.sh"
12
13 set -eufo pipefail
14
15 # shellcheck disable=SC1090
16 source ~/lf-env.sh
17
18 lf-activate-venv --python python3 "lftools[openstack]" \
19     kubernetes \
20     python-heatclient \
21     python-openstackclient
22
23 echo "INFO: Retrieving stack cost for: $OS_STACK_NAME"
24 if ! lftools openstack --os-cloud "$OS_CLOUD" stack cost "$OS_STACK_NAME" > stack-cost; then
25     echo "WARNING: Unable to get stack costs, continuing anyway"
26     echo "total: 0" > stack-cost
27 else
28     echo "DEBUG: Successfully retrieved stack cost: $(cat stack-cost)"
29 fi
30
31 # Delete the stack even if the stack-cost script fails
32 lftools openstack --os-cloud "$OS_CLOUD" stack delete "$OS_STACK_NAME" \
33     | echo "INFO: $(cat)"