Browse code

Use normal API not token/endpoint for image uploads

There is no reason to use keystone token bootstrapping for image
uploads. Glance is a service, and images can be uploaded to it normally
without special shenanigans.

Depends-On: If7b81c4a6746c8a1eb0302c96e045fb0f457d67b
Change-Id: I7092fb10cbe243e091789134263fab081af0c7f4

Monty Taylor authored on 2015/09/20 00:35:22
Showing 2 changed files
... ...
@@ -71,7 +71,7 @@ function upload_image {
71 71
     # OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
72 72
     if [[ "$image_url" =~ 'openvz' ]]; then
73 73
         image_name="${image_fname%.tar.gz}"
74
-        openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image create "$image_name" --public --container-format ami --disk-format ami < "${image}"
74
+        openstack --os-cloud=devstack-admin image create "$image_name" --public --container-format ami --disk-format ami < "${image}"
75 75
         return
76 76
     fi
77 77
 
... ...
@@ -182,7 +182,7 @@ function upload_image {
182 182
         vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
183 183
         vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}"
184 184
 
185
-        openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$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}"
185
+        openstack --os-cloud=devstack-admin 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}"
186 186
         return
187 187
     fi
188 188
 
... ...
@@ -199,8 +199,7 @@ function upload_image {
199 199
             force_vm_mode="--property vm_mode=xen"
200 200
         fi
201 201
         openstack \
202
-            --os-token $token \
203
-            --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT \
202
+            --os-cloud=devstack-admin \
204 203
             image create \
205 204
             "$image_name" --public \
206 205
             --container-format=ovf --disk-format=vhd \
... ...
@@ -214,8 +213,7 @@ function upload_image {
214 214
     if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
215 215
         image_name="${image_fname%.xen-raw.tgz}"
216 216
         openstack \
217
-            --os-token $token \
218
-            --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT \
217
+            --os-cloud=devstack-admin \
219 218
             image create \
220 219
             "$image_name" --public \
221 220
             --container-format=tgz --disk-format=raw \
... ...
@@ -231,8 +229,7 @@ function upload_image {
231 231
         fi
232 232
 
233 233
         openstack \
234
-            --os-token $token \
235
-            --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT \
234
+            --os-cloud=devstack-admin \
236 235
             image create \
237 236
             "$image_name" --public \
238 237
             --container-format=bare --disk-format=ploop \
... ...
@@ -314,9 +311,9 @@ function upload_image {
314 314
 
315 315
     if [ "$container_format" = "bare" ]; then
316 316
         if [ "$unpack" = "zcat" ]; then
317
-            openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}")
317
+            openstack --os-cloud=devstack-admin image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}")
318 318
         else
319
-            openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < "${image}"
319
+            openstack --os-cloud=devstack-admin image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < "${image}"
320 320
         fi
321 321
     else
322 322
         # Use glance client to add the kernel the root filesystem.
... ...
@@ -324,12 +321,12 @@ function upload_image {
324 324
         # kernel for use when uploading the root filesystem.
325 325
         local kernel_id="" ramdisk_id="";
326 326
         if [ -n "$kernel" ]; then
327
-            kernel_id=$(openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image create "$image_name-kernel" $img_property --public --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2)
327
+            kernel_id=$(openstack --os-cloud=devstack-admin image create "$image_name-kernel" $img_property --public --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2)
328 328
         fi
329 329
         if [ -n "$ramdisk" ]; then
330
-            ramdisk_id=$(openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image create "$image_name-ramdisk" $img_property --public --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2)
330
+            ramdisk_id=$(openstack --os-cloud=devstack-admin image create "$image_name-ramdisk" $img_property --public --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2)
331 331
         fi
332
-        openstack --os-token $token --os-url $GLANCE_SERVICE_PROTOCOL://$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}"
332
+        openstack --os-cloud=devstack-admin 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}"
333 333
     fi
334 334
 }
335 335
 
... ...
@@ -1216,8 +1216,6 @@ fi
1216 1216
 # See https://help.ubuntu.com/community/CloudInit for more on ``cloud-init``
1217 1217
 
1218 1218
 if is_service_enabled g-reg; then
1219
-    TOKEN=$(openstack token issue -c id -f value)
1220
-    die_if_not_set $LINENO TOKEN "Keystone fail to get token"
1221 1219
 
1222 1220
     echo_summary "Uploading images"
1223 1221