Merge "Modify glance image-create commands to use openstackclient"

This commit is contained in:
Jenkins 2014-08-15 00:50:41 +00:00 committed by Gerrit Code Review
commit a3ecab6618
3 changed files with 68 additions and 68 deletions

View File

@ -85,7 +85,7 @@ function upload_image {
# OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading # OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
if [[ "$image_url" =~ 'openvz' ]]; then if [[ "$image_url" =~ 'openvz' ]]; then
image_name="${image_fname%.tar.gz}" image_name="${image_fname%.tar.gz}"
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name" --is-public=True --container-format ami --disk-format ami < "${image}" openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name" --public --container-format ami --disk-format ami < "${image}"
return return
fi fi
@ -196,7 +196,7 @@ function upload_image {
vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}" vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}" vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}"
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name" --is-public=True --container-format bare --disk-format vmdk --property vmware_disktype="$vmdk_disktype" --property vmware_adaptertype="$vmdk_adapter_type" --property hw_vif_model="$vmdk_net_adapter" < "${image}" openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name" --public --container-format bare --disk-format vmdk --property vmware_disktype="$vmdk_disktype" --property vmware_adaptertype="$vmdk_adapter_type" --property hw_vif_model="$vmdk_net_adapter" < "${image}"
return return
fi fi
@ -212,11 +212,11 @@ function upload_image {
# directly from volume. # directly from volume.
force_vm_mode="--property vm_mode=xen" force_vm_mode="--property vm_mode=xen"
fi fi
glance \ openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name "$image_name" --is-public=True \ "$image_name" --public \
--container-format=ovf --disk-format=vhd \ --container-format=ovf --disk-format=vhd \
$force_vm_mode < "${image}" $force_vm_mode < "${image}"
return return
@ -227,11 +227,11 @@ function upload_image {
# Setting metadata, so PV mode is used. # Setting metadata, so PV mode is used.
if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
image_name="${image_fname%.xen-raw.tgz}" image_name="${image_fname%.xen-raw.tgz}"
glance \ openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name "$image_name" --is-public=True \ "$image_name" --public \
--container-format=tgz --disk-format=raw \ --container-format=tgz --disk-format=raw \
--property vm_mode=xen < "${image}" --property vm_mode=xen < "${image}"
return return
@ -307,9 +307,9 @@ function upload_image {
if [ "$container_format" = "bare" ]; then if [ "$container_format" = "bare" ]; then
if [ "$unpack" = "zcat" ]; then if [ "$unpack" = "zcat" ]; then
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name" $img_property --is-public True --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}") openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}")
else else
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name" $img_property --is-public True --container-format=$container_format --disk-format $disk_format < "${image}" openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < "${image}"
fi fi
else else
# Use glance client to add the kernel the root filesystem. # Use glance client to add the kernel the root filesystem.
@ -317,12 +317,12 @@ function upload_image {
# kernel for use when uploading the root filesystem. # kernel for use when uploading the root filesystem.
local kernel_id="" ramdisk_id=""; local kernel_id="" ramdisk_id="";
if [ -n "$kernel" ]; then if [ -n "$kernel" ]; then
kernel_id=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name-kernel" $img_property --is-public True --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2) kernel_id=$(openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name-kernel" $img_property --public --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2)
fi fi
if [ -n "$ramdisk" ]; then if [ -n "$ramdisk" ]; then
ramdisk_id=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$image_name-ramdisk" $img_property --is-public True --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2) ramdisk_id=$(openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name-ramdisk" $img_property --public --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2)
fi fi
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "${image_name%.img}" $img_property --is-public True --container-format ami --disk-format ami ${kernel_id:+--property kernel_id=$kernel_id} ${ramdisk_id:+--property ramdisk_id=$ramdisk_id} < "${image}" openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "${image_name%.img}" $img_property --public --container-format ami --disk-format ami ${kernel_id:+--property kernel_id=$kernel_id} ${ramdisk_id:+--property ramdisk_id=$ramdisk_id} < "${image}"
fi fi
} }

View File

@ -229,19 +229,19 @@ function upload_baremetal_deploy {
fi fi
# load them into glance # load them into glance
BM_DEPLOY_KERNEL_ID=$(glance \ BM_DEPLOY_KERNEL_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $BM_DEPLOY_KERNEL \ $BM_DEPLOY_KERNEL \
--is-public True --disk-format=aki \ --public --disk-format=aki \
< $TOP_DIR/files/$BM_DEPLOY_KERNEL | grep ' id ' | get_field 2) < $TOP_DIR/files/$BM_DEPLOY_KERNEL | grep ' id ' | get_field 2)
BM_DEPLOY_RAMDISK_ID=$(glance \ BM_DEPLOY_RAMDISK_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $BM_DEPLOY_RAMDISK \ $BM_DEPLOY_RAMDISK \
--is-public True --disk-format=ari \ --public --disk-format=ari \
< $TOP_DIR/files/$BM_DEPLOY_RAMDISK | grep ' id ' | get_field 2) < $TOP_DIR/files/$BM_DEPLOY_RAMDISK | grep ' id ' | get_field 2)
} }
@ -284,19 +284,19 @@ function extract_and_upload_k_and_r_from_image {
OUT_RAMDISK=${out##*,} OUT_RAMDISK=${out##*,}
# load them into glance # load them into glance
KERNEL_ID=$(glance \ KERNEL_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $image_name-kernel \ $image_name-kernel \
--is-public True --disk-format=aki \ --public --disk-format=aki \
< $TOP_DIR/files/$OUT_KERNEL | grep ' id ' | get_field 2) < $TOP_DIR/files/$OUT_KERNEL | grep ' id ' | get_field 2)
RAMDISK_ID=$(glance \ RAMDISK_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $image_name-initrd \ $image_name-initrd \
--is-public True --disk-format=ari \ --public --disk-format=ari \
< $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2) < $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2)
} }
@ -362,18 +362,18 @@ function upload_baremetal_image {
if [ "$CONTAINER_FORMAT" = "bare" ]; then if [ "$CONTAINER_FORMAT" = "bare" ]; then
extract_and_upload_k_and_r_from_image $token $IMAGE extract_and_upload_k_and_r_from_image $token $IMAGE
elif [ "$CONTAINER_FORMAT" = "ami" ]; then elif [ "$CONTAINER_FORMAT" = "ami" ]; then
KERNEL_ID=$(glance \ KERNEL_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name "$IMAGE_NAME-kernel" --is-public True \ "$IMAGE_NAME-kernel" --public \
--container-format aki \ --container-format aki \
--disk-format aki < "$KERNEL" | grep ' id ' | get_field 2) --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
RAMDISK_ID=$(glance \ RAMDISK_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name "$IMAGE_NAME-ramdisk" --is-public True \ "$IMAGE_NAME-ramdisk" --public \
--container-format ari \ --container-format ari \
--disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2) --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
else else
@ -381,11 +381,11 @@ function upload_baremetal_image {
return return
fi fi
glance \ openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name "${IMAGE_NAME%.img}" --is-public True \ "${IMAGE_NAME%.img}" --public \
--container-format $CONTAINER_FORMAT \ --container-format $CONTAINER_FORMAT \
--disk-format $DISK_FORMAT \ --disk-format $DISK_FORMAT \
${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \ ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \

View File

@ -494,19 +494,19 @@ function upload_baremetal_ironic_deploy {
die_if_not_set $LINENO token "Keystone fail to get token" die_if_not_set $LINENO token "Keystone fail to get token"
# load them into glance # load them into glance
IRONIC_DEPLOY_KERNEL_ID=$(glance \ IRONIC_DEPLOY_KERNEL_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \ $(basename $IRONIC_DEPLOY_KERNEL_PATH) \
--is-public True --disk-format=aki \ --public --disk-format=aki \
< $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2) < $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2)
IRONIC_DEPLOY_RAMDISK_ID=$(glance \ IRONIC_DEPLOY_RAMDISK_ID=$(openstack \
--os-auth-token $token \ --os-token $token \
--os-image-url http://$GLANCE_HOSTPORT \ --os-url http://$GLANCE_HOSTPORT \
image-create \ image create \
--name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \ $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
--is-public True --disk-format=ari \ --public --disk-format=ari \
< $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2) < $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2)
} }