Merge "Add cli options to cleanup-images"
This commit is contained in:
commit
450b8df39f
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Removing Kolla images
|
- name: Removing Kolla images
|
||||||
command: /tmp/kolla-cleanup/tools/cleanup-images
|
command: /tmp/kolla-cleanup/tools/cleanup-images --all
|
||||||
when:
|
when:
|
||||||
- destroy_include_images | bool
|
- destroy_include_images | bool
|
||||||
|
@ -79,7 +79,7 @@ triggered on the Docker host when the neutron-agents containers are launched.
|
|||||||
This can be useful when you want to do a new clean deployment, particularly one
|
This can be useful when you want to do a new clean deployment, particularly one
|
||||||
changing the network topology.
|
changing the network topology.
|
||||||
|
|
||||||
``tools/cleanup-images`` is used to remove all Docker images built by Kolla
|
``tools/cleanup-images --all`` is used to remove all Docker images built by Kolla
|
||||||
from the local Docker cache.
|
from the local Docker cache.
|
||||||
|
|
||||||
``kolla-ansible -i INVENTORY deploy`` is used to deploy and start all Kolla
|
``kolla-ansible -i INVENTORY deploy`` is used to deploy and start all Kolla
|
||||||
|
@ -6,11 +6,73 @@ cd "$(dirname "$REAL_PATH")/.."
|
|||||||
|
|
||||||
. tools/validate-docker-execute.sh
|
. tools/validate-docker-execute.sh
|
||||||
|
|
||||||
KOLLA_IMAGES=$(docker images -a --filter "label=kolla_version" --format "{{.ID}}")
|
function process_cmd {
|
||||||
|
|
||||||
if [[ -z "$KOLLA_IMAGES" ]]; then
|
if [[ -z "$KOLLA_IMAGES" ]]; then
|
||||||
echo "No images to cleanup, exit now."
|
echo "No images to cleanup, exit now."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker rmi -f $@ $KOLLA_IMAGES
|
$CMD
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Command failed $CMD"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $0 COMMAND [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--all, -a Remove all kolla images
|
||||||
|
--dangling Remove orphaned images
|
||||||
|
--help, -h Show this usage information
|
||||||
|
--image, -i <image> Delete selected images
|
||||||
|
--image-version <image_version> Set Kolla image version
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
SHORT_OPTS="ahi:"
|
||||||
|
LONG_OPTS="all,dangling,help,image:,image-version:"
|
||||||
|
ARGS=$(getopt -o "${SHORT_OPTS}" -l "${LONG_OPTS}" --name "$0" -- "$@") || { usage >&2; exit 2; }
|
||||||
|
|
||||||
|
eval set -- "$ARGS"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
|
||||||
|
(--all|-a)
|
||||||
|
KOLLA_IMAGES="$(docker images -a --filter "label=kolla_version" --format "{{.ID}}")"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--dangling)
|
||||||
|
KOLLA_IMAGES="$(docker images -a --filter dangling=true --format "{{.ID}}")"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--image|-i)
|
||||||
|
KOLLA_IMAGES="$(docker images -a --filter "label=kolla_version" --format "{{.Repository}}\t{{.ID}}" | grep -E "$2" | awk '{print $2}')"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--image-version)
|
||||||
|
KOLLA_IMAGES="$(docker images -a --filter "label=kolla_version=${2}" --format "{{.ID}}")"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--help|-h)
|
||||||
|
usage
|
||||||
|
shift
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
CMD="docker rmi -f $@ $KOLLA_IMAGES"
|
||||||
|
process_cmd
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Cleanup-images support advanced features such as remove all kolla
|
||||||
|
images, remove dangling images, delete user selected images and
|
||||||
|
remove images from specific kolla_version.
|
Loading…
Reference in New Issue
Block a user