Merge "Modify glance image-create
commands to use openstackclient"
This commit is contained in:
commit
a3ecab6618
34
functions
34
functions
@ -85,7 +85,7 @@ function upload_image {
|
||||
# OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
|
||||
if [[ "$image_url" =~ 'openvz' ]]; then
|
||||
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
|
||||
fi
|
||||
|
||||
@ -196,7 +196,7 @@ function upload_image {
|
||||
vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
|
||||
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
|
||||
fi
|
||||
|
||||
@ -212,11 +212,11 @@ function upload_image {
|
||||
# directly from volume.
|
||||
force_vm_mode="--property vm_mode=xen"
|
||||
fi
|
||||
glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name "$image_name" --is-public=True \
|
||||
openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
"$image_name" --public \
|
||||
--container-format=ovf --disk-format=vhd \
|
||||
$force_vm_mode < "${image}"
|
||||
return
|
||||
@ -227,11 +227,11 @@ function upload_image {
|
||||
# Setting metadata, so PV mode is used.
|
||||
if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
|
||||
image_name="${image_fname%.xen-raw.tgz}"
|
||||
glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name "$image_name" --is-public=True \
|
||||
openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
"$image_name" --public \
|
||||
--container-format=tgz --disk-format=raw \
|
||||
--property vm_mode=xen < "${image}"
|
||||
return
|
||||
@ -307,9 +307,9 @@ function upload_image {
|
||||
|
||||
if [ "$container_format" = "bare" ]; 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
|
||||
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
|
||||
else
|
||||
# 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.
|
||||
local kernel_id="" ramdisk_id="";
|
||||
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
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -229,19 +229,19 @@ function upload_baremetal_deploy {
|
||||
fi
|
||||
|
||||
# load them into glance
|
||||
BM_DEPLOY_KERNEL_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $BM_DEPLOY_KERNEL \
|
||||
--is-public True --disk-format=aki \
|
||||
BM_DEPLOY_KERNEL_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$BM_DEPLOY_KERNEL \
|
||||
--public --disk-format=aki \
|
||||
< $TOP_DIR/files/$BM_DEPLOY_KERNEL | grep ' id ' | get_field 2)
|
||||
BM_DEPLOY_RAMDISK_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $BM_DEPLOY_RAMDISK \
|
||||
--is-public True --disk-format=ari \
|
||||
BM_DEPLOY_RAMDISK_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$BM_DEPLOY_RAMDISK \
|
||||
--public --disk-format=ari \
|
||||
< $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##*,}
|
||||
|
||||
# load them into glance
|
||||
KERNEL_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $image_name-kernel \
|
||||
--is-public True --disk-format=aki \
|
||||
KERNEL_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$image_name-kernel \
|
||||
--public --disk-format=aki \
|
||||
< $TOP_DIR/files/$OUT_KERNEL | grep ' id ' | get_field 2)
|
||||
RAMDISK_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $image_name-initrd \
|
||||
--is-public True --disk-format=ari \
|
||||
RAMDISK_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$image_name-initrd \
|
||||
--public --disk-format=ari \
|
||||
< $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2)
|
||||
}
|
||||
|
||||
@ -362,18 +362,18 @@ function upload_baremetal_image {
|
||||
if [ "$CONTAINER_FORMAT" = "bare" ]; then
|
||||
extract_and_upload_k_and_r_from_image $token $IMAGE
|
||||
elif [ "$CONTAINER_FORMAT" = "ami" ]; then
|
||||
KERNEL_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name "$IMAGE_NAME-kernel" --is-public True \
|
||||
KERNEL_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
"$IMAGE_NAME-kernel" --public \
|
||||
--container-format aki \
|
||||
--disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
|
||||
RAMDISK_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name "$IMAGE_NAME-ramdisk" --is-public True \
|
||||
RAMDISK_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
"$IMAGE_NAME-ramdisk" --public \
|
||||
--container-format ari \
|
||||
--disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
|
||||
else
|
||||
@ -381,11 +381,11 @@ function upload_baremetal_image {
|
||||
return
|
||||
fi
|
||||
|
||||
glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name "${IMAGE_NAME%.img}" --is-public True \
|
||||
openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
"${IMAGE_NAME%.img}" --public \
|
||||
--container-format $CONTAINER_FORMAT \
|
||||
--disk-format $DISK_FORMAT \
|
||||
${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \
|
||||
|
24
lib/ironic
24
lib/ironic
@ -494,19 +494,19 @@ function upload_baremetal_ironic_deploy {
|
||||
die_if_not_set $LINENO token "Keystone fail to get token"
|
||||
|
||||
# load them into glance
|
||||
IRONIC_DEPLOY_KERNEL_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \
|
||||
--is-public True --disk-format=aki \
|
||||
IRONIC_DEPLOY_KERNEL_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$(basename $IRONIC_DEPLOY_KERNEL_PATH) \
|
||||
--public --disk-format=aki \
|
||||
< $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2)
|
||||
IRONIC_DEPLOY_RAMDISK_ID=$(glance \
|
||||
--os-auth-token $token \
|
||||
--os-image-url http://$GLANCE_HOSTPORT \
|
||||
image-create \
|
||||
--name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
|
||||
--is-public True --disk-format=ari \
|
||||
IRONIC_DEPLOY_RAMDISK_ID=$(openstack \
|
||||
--os-token $token \
|
||||
--os-url http://$GLANCE_HOSTPORT \
|
||||
image create \
|
||||
$(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
|
||||
--public --disk-format=ari \
|
||||
< $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user