79eee278254748754a9736327eeb7b0dacd0c1ea
[releng/global-jjb.git] / shell / openstack-cleanup-old-images.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017, 2018 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 # Removes openstack images older than X days in the cloud
12 echo "---> Cleanup old images"
13
14 # shellcheck disable=SC1090
15 source ~/lf-env.sh
16
17 # TODO: "openstacksdk<0.99" AttributeError: 'Image' object has no
18 # attribute 'protected'
19 lf-activate-venv --python python3 "lftools[openstack]" \
20     kubernetes \
21     niet \
22     "openstacksdk<0.99" \
23     python-heatclient \
24     python-openstackclient \
25     python-magnumclient \
26     yq
27
28 os_cloud="${OS_CLOUD:-vex}"
29 os_image_cleanup_age="${OS_IMAGE_CLEANUP_AGE:-30}"
30
31 set -eux -o pipefail
32
33 lftools openstack --os-cloud "${os_cloud}" image cleanup --days="${os_image_cleanup_age}"