]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat tools : glance-jeos-add-from-github avoid duplicates
authorSteven Hardy <shardy@redhat.com>
Mon, 20 Aug 2012 12:01:23 +0000 (13:01 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 20 Aug 2012 12:02:46 +0000 (13:02 +0100)
Avoid adding images to glance when they already exist

Change-Id: Ia914cc3015fcdcc0c12e3773985298fce6872751
Signed-off-by: Steven Hardy <shardy@redhat.com>
tools/glance-jeos-add-from-github.sh

index 113c0a32f02a8ea504997049e0f4baebf4f68f7d..3a22233570588c1a44739293c413cbd29342c09b 100755 (executable)
@@ -10,6 +10,11 @@ for i in ${IMAGES}
 do
     NAME=$(echo $i | sed "s/\.${DISK_FORMAT}//")
     echo "Downloading and registering $i with OpenStack glance as ${NAME}"
-    echo "Downloading from ${DOWNLOAD_URL}/$i"
-    glance add name=${NAME} is_public=true disk_format=${DISK_FORMAT} container_format=bare copy_from="${DOWNLOAD_URL}/$i"
+    if glance index | grep -q "\s${NAME}\s"
+    then
+        echo "WARNING : ${NAME} already exists, skipping"
+    else
+        echo "Downloading from ${DOWNLOAD_URL}/$i"
+        glance add name=${NAME} is_public=true disk_format=${DISK_FORMAT} container_format=bare copy_from="${DOWNLOAD_URL}/$i"
+    fi
 done