Fix image multi import

This commit is contained in:
John Hua 2015-09-18 10:36:59 +08:00
parent a388547a73
commit 7c993cb195
1 changed files with 15 additions and 14 deletions

View File

@ -3,7 +3,7 @@
LOG_FILE="/tmp/controller_post_deployment.log"
function clear_images {
for ID in $(glance image-list | awk 'NR>2{print $2}' | grep -v '^$');
for ID in $(glance image-list | awk 'NR>2{print $2}' | grep -v '^$');
do
glance image-delete $ID &>> $LOG_FILE
done
@ -19,25 +19,26 @@ function create_image {
local image_url
image_url="$3"
local image_file
image_file=$(mktemp)
if ! glance image-list --name "$image_name" --property vm_mode="$vm_mode" | grep -q "$image_name"; then
local image_file
image_file=$(mktemp)
wget -q -O "$image_file" "$image_url"
glance image-create \
--name "$image_name" \
--container-format ovf \
--disk-format vhd \
--property vm_mode="$vm_mode" \
--is-public True \
--file "$image_file" \
&>> $LOG_FILE
wget -q -O "$image_file" "$image_url"
glance image-create \
--name "$image_name" \
--container-format ovf \
--disk-format vhd \
--property vm_mode="$vm_mode" \
--is-public True \
--file "$image_file" \
&>> $LOG_FILE
rm "$image_file"
rm "$image_file"
fi
}
source /root/openrc admin
clear_images
create_image "TestVM" "xen" "http://ca.downloads.xensource.com/OpenStack/cirros-0.3.4-x86_64-disk.vhd.tgz"
create_image "F17-x86_64-cfntools" "hvm" "http://ca.downloads.xensource.com/OpenStack/F21-x86_64-cfntools.tgz"
glance image-list >> $LOG_FILE