Browse code

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

Jenkins authored on 2014/08/15 09:50:41
Showing 3 changed files
... ...
@@ -85,7 +85,7 @@ function upload_image {
85 85
     # OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
86 86
     if [[ "$image_url" =~ 'openvz' ]]; then
87 87
         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}"
89 89
         return
90 90
     fi
91 91
 
... ...
@@ -196,7 +196,7 @@ function upload_image {
196 196
         vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
197 197
         vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}"
198 198
 
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}"
200 200
         return
201 201
     fi
202 202
 
... ...
@@ -212,11 +212,11 @@ function upload_image {
212 212
             # directly from volume.
213 213
             force_vm_mode="--property vm_mode=xen"
214 214
         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 \
220 220
             --container-format=ovf --disk-format=vhd \
221 221
             $force_vm_mode < "${image}"
222 222
         return
... ...
@@ -227,11 +227,11 @@ function upload_image {
227 227
     # Setting metadata, so PV mode is used.
228 228
     if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
229 229
         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 \
235 235
             --container-format=tgz --disk-format=raw \
236 236
             --property vm_mode=xen < "${image}"
237 237
         return
... ...
@@ -307,9 +307,9 @@ function upload_image {
307 307
 
308 308
     if [ "$container_format" = "bare" ]; then
309 309
         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}")
311 311
         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}"
313 313
         fi
314 314
     else
315 315
         # Use glance client to add the kernel the root filesystem.
... ...
@@ -317,12 +317,12 @@ function upload_image {
317 317
         # kernel for use when uploading the root filesystem.
318 318
         local kernel_id="" ramdisk_id="";
319 319
         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)
321 321
         fi
322 322
         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)
324 324
         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}"
326 326
     fi
327 327
 }
328 328
 
... ...
@@ -229,19 +229,19 @@ function upload_baremetal_deploy {
229 229
     fi
230 230
 
231 231
     # 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 \
238 238
         < $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 \
245 245
         < $TOP_DIR/files/$BM_DEPLOY_RAMDISK  | grep ' id ' | get_field 2)
246 246
 }
247 247
 
... ...
@@ -284,19 +284,19 @@ function extract_and_upload_k_and_r_from_image {
284 284
     OUT_RAMDISK=${out##*,}
285 285
 
286 286
     # 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 \
293 293
         < $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 \
300 300
         < $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2)
301 301
 }
302 302
 
... ...
@@ -362,18 +362,18 @@ function upload_baremetal_image {
362 362
     if [ "$CONTAINER_FORMAT" = "bare" ]; then
363 363
         extract_and_upload_k_and_r_from_image $token $IMAGE
364 364
     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 \
370 370
             --container-format aki \
371 371
             --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 \
377 377
             --container-format ari \
378 378
             --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
379 379
     else
... ...
@@ -381,11 +381,11 @@ function upload_baremetal_image {
381 381
         return
382 382
     fi
383 383
 
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 \
389 389
         --container-format $CONTAINER_FORMAT \
390 390
         --disk-format $DISK_FORMAT \
391 391
         ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \
... ...
@@ -494,19 +494,19 @@ function upload_baremetal_ironic_deploy {
494 494
     die_if_not_set $LINENO token "Keystone fail to get token"
495 495
 
496 496
     # 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 \
503 503
         < $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 \
510 510
         < $IRONIC_DEPLOY_RAMDISK_PATH  | grep ' id ' | get_field 2)
511 511
 }
512 512