Skip to content

Commit a3ecab6

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Modify glance image-create commands to use openstackclient"
2 parents 5dd1778 + 8d3ac2d commit a3ecab6

3 files changed

Lines changed: 68 additions & 68 deletions

File tree

functions

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function upload_image {
8585
# OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
8686
if [[ "$image_url" =~ 'openvz' ]]; then
8787
image_name="${image_fname%.tar.gz}"
88-
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}"
88+
openstack --os-token $token --os-url http://$GLANCE_HOSTPORT image create "$image_name" --public --container-format ami --disk-format ami < "${image}"
8989
return
9090
fi
9191

@@ -196,7 +196,7 @@ function upload_image {
196196
vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
197197
vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}"
198198

199-
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}"
199+
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}"
200200
return
201201
fi
202202

@@ -212,11 +212,11 @@ function upload_image {
212212
# directly from volume.
213213
force_vm_mode="--property vm_mode=xen"
214214
fi
215-
glance \
216-
--os-auth-token $token \
217-
--os-image-url http://$GLANCE_HOSTPORT \
218-
image-create \
219-
--name "$image_name" --is-public=True \
215+
openstack \
216+
--os-token $token \
217+
--os-url http://$GLANCE_HOSTPORT \
218+
image create \
219+
"$image_name" --public \
220220
--container-format=ovf --disk-format=vhd \
221221
$force_vm_mode < "${image}"
222222
return
@@ -227,11 +227,11 @@ function upload_image {
227227
# Setting metadata, so PV mode is used.
228228
if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
229229
image_name="${image_fname%.xen-raw.tgz}"
230-
glance \
231-
--os-auth-token $token \
232-
--os-image-url http://$GLANCE_HOSTPORT \
233-
image-create \
234-
--name "$image_name" --is-public=True \
230+
openstack \
231+
--os-token $token \
232+
--os-url http://$GLANCE_HOSTPORT \
233+
image create \
234+
"$image_name" --public \
235235
--container-format=tgz --disk-format=raw \
236236
--property vm_mode=xen < "${image}"
237237
return
@@ -307,22 +307,22 @@ function upload_image {
307307

308308
if [ "$container_format" = "bare" ]; then
309309
if [ "$unpack" = "zcat" ]; then
310-
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}")
310+
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}")
311311
else
312-
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}"
312+
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}"
313313
fi
314314
else
315315
# Use glance client to add the kernel the root filesystem.
316316
# We parse the results of the first upload to get the glance ID of the
317317
# kernel for use when uploading the root filesystem.
318318
local kernel_id="" ramdisk_id="";
319319
if [ -n "$kernel" ]; then
320-
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)
320+
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)
321321
fi
322322
if [ -n "$ramdisk" ]; then
323-
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)
323+
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)
324324
fi
325-
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}"
325+
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}"
326326
fi
327327
}
328328

lib/baremetal

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,19 @@ function upload_baremetal_deploy {
229229
fi
230230

231231
# load them into glance
232-
BM_DEPLOY_KERNEL_ID=$(glance \
233-
--os-auth-token $token \
234-
--os-image-url http://$GLANCE_HOSTPORT \
235-
image-create \
236-
--name $BM_DEPLOY_KERNEL \
237-
--is-public True --disk-format=aki \
232+
BM_DEPLOY_KERNEL_ID=$(openstack \
233+
--os-token $token \
234+
--os-url http://$GLANCE_HOSTPORT \
235+
image create \
236+
$BM_DEPLOY_KERNEL \
237+
--public --disk-format=aki \
238238
< $TOP_DIR/files/$BM_DEPLOY_KERNEL | grep ' id ' | get_field 2)
239-
BM_DEPLOY_RAMDISK_ID=$(glance \
240-
--os-auth-token $token \
241-
--os-image-url http://$GLANCE_HOSTPORT \
242-
image-create \
243-
--name $BM_DEPLOY_RAMDISK \
244-
--is-public True --disk-format=ari \
239+
BM_DEPLOY_RAMDISK_ID=$(openstack \
240+
--os-token $token \
241+
--os-url http://$GLANCE_HOSTPORT \
242+
image create \
243+
$BM_DEPLOY_RAMDISK \
244+
--public --disk-format=ari \
245245
< $TOP_DIR/files/$BM_DEPLOY_RAMDISK | grep ' id ' | get_field 2)
246246
}
247247

@@ -284,19 +284,19 @@ function extract_and_upload_k_and_r_from_image {
284284
OUT_RAMDISK=${out##*,}
285285

286286
# load them into glance
287-
KERNEL_ID=$(glance \
288-
--os-auth-token $token \
289-
--os-image-url http://$GLANCE_HOSTPORT \
290-
image-create \
291-
--name $image_name-kernel \
292-
--is-public True --disk-format=aki \
287+
KERNEL_ID=$(openstack \
288+
--os-token $token \
289+
--os-url http://$GLANCE_HOSTPORT \
290+
image create \
291+
$image_name-kernel \
292+
--public --disk-format=aki \
293293
< $TOP_DIR/files/$OUT_KERNEL | grep ' id ' | get_field 2)
294-
RAMDISK_ID=$(glance \
295-
--os-auth-token $token \
296-
--os-image-url http://$GLANCE_HOSTPORT \
297-
image-create \
298-
--name $image_name-initrd \
299-
--is-public True --disk-format=ari \
294+
RAMDISK_ID=$(openstack \
295+
--os-token $token \
296+
--os-url http://$GLANCE_HOSTPORT \
297+
image create \
298+
$image_name-initrd \
299+
--public --disk-format=ari \
300300
< $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2)
301301
}
302302

@@ -362,30 +362,30 @@ function upload_baremetal_image {
362362
if [ "$CONTAINER_FORMAT" = "bare" ]; then
363363
extract_and_upload_k_and_r_from_image $token $IMAGE
364364
elif [ "$CONTAINER_FORMAT" = "ami" ]; then
365-
KERNEL_ID=$(glance \
366-
--os-auth-token $token \
367-
--os-image-url http://$GLANCE_HOSTPORT \
368-
image-create \
369-
--name "$IMAGE_NAME-kernel" --is-public True \
365+
KERNEL_ID=$(openstack \
366+
--os-token $token \
367+
--os-url http://$GLANCE_HOSTPORT \
368+
image create \
369+
"$IMAGE_NAME-kernel" --public \
370370
--container-format aki \
371371
--disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
372-
RAMDISK_ID=$(glance \
373-
--os-auth-token $token \
374-
--os-image-url http://$GLANCE_HOSTPORT \
375-
image-create \
376-
--name "$IMAGE_NAME-ramdisk" --is-public True \
372+
RAMDISK_ID=$(openstack \
373+
--os-token $token \
374+
--os-url http://$GLANCE_HOSTPORT \
375+
image create \
376+
"$IMAGE_NAME-ramdisk" --public \
377377
--container-format ari \
378378
--disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
379379
else
380380
# TODO(deva): add support for other image types
381381
return
382382
fi
383383

384-
glance \
385-
--os-auth-token $token \
386-
--os-image-url http://$GLANCE_HOSTPORT \
387-
image-create \
388-
--name "${IMAGE_NAME%.img}" --is-public True \
384+
openstack \
385+
--os-token $token \
386+
--os-url http://$GLANCE_HOSTPORT \
387+
image create \
388+
"${IMAGE_NAME%.img}" --public \
389389
--container-format $CONTAINER_FORMAT \
390390
--disk-format $DISK_FORMAT \
391391
${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \

lib/ironic

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,19 @@ function upload_baremetal_ironic_deploy {
494494
die_if_not_set $LINENO token "Keystone fail to get token"
495495

496496
# load them into glance
497-
IRONIC_DEPLOY_KERNEL_ID=$(glance \
498-
--os-auth-token $token \
499-
--os-image-url http://$GLANCE_HOSTPORT \
500-
image-create \
501-
--name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \
502-
--is-public True --disk-format=aki \
497+
IRONIC_DEPLOY_KERNEL_ID=$(openstack \
498+
--os-token $token \
499+
--os-url http://$GLANCE_HOSTPORT \
500+
image create \
501+
$(basename $IRONIC_DEPLOY_KERNEL_PATH) \
502+
--public --disk-format=aki \
503503
< $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2)
504-
IRONIC_DEPLOY_RAMDISK_ID=$(glance \
505-
--os-auth-token $token \
506-
--os-image-url http://$GLANCE_HOSTPORT \
507-
image-create \
508-
--name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
509-
--is-public True --disk-format=ari \
504+
IRONIC_DEPLOY_RAMDISK_ID=$(openstack \
505+
--os-token $token \
506+
--os-url http://$GLANCE_HOSTPORT \
507+
image create \
508+
$(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
509+
--public --disk-format=ari \
510510
< $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2)
511511
}
512512

0 commit comments

Comments
 (0)