Browse code

Add glance client

* python-glanceclient overrides the old client shipped with glance in /usr/local/bin
* start adding exercises

Change-Id: I460ed5749bca69425f23d328c0537c2ef91f84a4

Dean Troyer authored on 2012/04/14 03:16:38
Showing 8 changed files
... ...
@@ -51,7 +51,7 @@ DEFAULT_FLOATING_POOL=${DEFAULT_FLOATING_POOL:-nova}
51 51
 # =================
52 52
 
53 53
 # Grab the id of the image to launch
54
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
54
+IMAGE=`glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1`
55 55
 die_if_not_set IMAGE "Failure getting image"
56 56
 
57 57
 # Instance and volume names
... ...
@@ -46,7 +46,9 @@ unset OS_AUTH_URL
46 46
 
47 47
 # Common authentication args
48 48
 TENANT_ARG="--os_tenant_name=$x_TENANT_NAME"
49
+TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME"
49 50
 ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL"
51
+ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
50 52
 
51 53
 # Set global return
52 54
 RETURN=0
... ...
@@ -94,7 +96,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
94 94
         STATUS_GLANCE="Skipped"
95 95
     else
96 96
         echo -e "\nTest Glance"
97
-        if glance $TENANT_ARG $ARGS index; then
97
+        if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then
98 98
             STATUS_GLANCE="Succeeded"
99 99
         else
100 100
             STATUS_GLANCE="Failed"
... ...
@@ -107,7 +107,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
107 107
         STATUS_GLANCE="Skipped"
108 108
     else
109 109
         echo -e "\nTest Glance"
110
-        if glance index; then
110
+        if glance image-list; then
111 111
             STATUS_GLANCE="Succeeded"
112 112
         else
113 113
             STATUS_GLANCE="Failed"
... ...
@@ -63,10 +63,10 @@ nova list
63 63
 nova image-list
64 64
 
65 65
 # But we recommend using glance directly
66
-glance -f index
66
+glance image-list
67 67
 
68 68
 # Grab the id of the image to launch
69
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
69
+IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
70 70
 
71 71
 # Security Groups
72 72
 # ---------------
... ...
@@ -53,10 +53,10 @@ nova list
53 53
 nova image-list
54 54
 
55 55
 # But we recommend using glance directly
56
-glance -f index
56
+glance image-list
57 57
 
58 58
 # Grab the id of the image to launch
59
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
59
+IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
60 60
 
61 61
 # determinine instance type
62 62
 # -------------------------
... ...
@@ -30,7 +30,7 @@ catalog.RegionOne.s3.internalURL = http://%SERVICE_HOST%:%S3_SERVICE_PORT%
30 30
 catalog.RegionOne.s3.name = S3 Service
31 31
 
32 32
 
33
-catalog.RegionOne.image.publicURL = http://%SERVICE_HOST%:9292/v1
34
-catalog.RegionOne.image.adminURL = http://%SERVICE_HOST%:9292/v1
35
-catalog.RegionOne.image.internalURL = http://%SERVICE_HOST%:9292/v1
33
+catalog.RegionOne.image.publicURL = http://%SERVICE_HOST%:9292
34
+catalog.RegionOne.image.adminURL = http://%SERVICE_HOST%:9292
35
+catalog.RegionOne.image.internalURL = http://%SERVICE_HOST%:9292
36 36
 catalog.RegionOne.image.name = Image Service
... ...
@@ -201,6 +201,7 @@ OFFLINE=`trueorfalse False $OFFLINE`
201 201
 NOVA_DIR=$DEST/nova
202 202
 HORIZON_DIR=$DEST/horizon
203 203
 GLANCE_DIR=$DEST/glance
204
+GLANCECLIENT_DIR=$DEST/python-glanceclient
204 205
 KEYSTONE_DIR=$DEST/keystone
205 206
 NOVACLIENT_DIR=$DEST/python-novaclient
206 207
 KEYSTONECLIENT_DIR=$DEST/python-keystoneclient
... ...
@@ -643,6 +644,7 @@ git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
643 643
 # python client library to nova that horizon (and others) use
644 644
 git_clone $KEYSTONECLIENT_REPO $KEYSTONECLIENT_DIR $KEYSTONECLIENT_BRANCH
645 645
 git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
646
+git_clone $GLANCECLIENT_REPO $GLANCECLIENT_DIR $GLANCECLIENT_BRANCH
646 647
 
647 648
 # glance, swift middleware and nova api needs keystone middleware
648 649
 if is_service_enabled key g-api n-api swift; then
... ...
@@ -715,6 +717,9 @@ if is_service_enabled melange; then
715 715
     cd $MELANGECLIENT_DIR; sudo python setup.py develop
716 716
 fi
717 717
 
718
+# Do this _after_ glance is installed to override the old binary
719
+cd $GLANCECLIENT_DIR; sudo python setup.py develop
720
+
718 721
 
719 722
 # Syslog
720 723
 # ------
... ...
@@ -1854,21 +1859,19 @@ if is_service_enabled g-reg; then
1854 1854
         esac
1855 1855
 
1856 1856
         if [ "$CONTAINER_FORMAT" = "bare" ]; then
1857
-            glance add --silent-upload -A $TOKEN name="$IMAGE_NAME" is_public=true container_format=$CONTAINER_FORMAT disk_format=$DISK_FORMAT < <(zcat --force "${IMAGE}")
1857
+            glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
1858 1858
         else
1859 1859
             # Use glance client to add the kernel the root filesystem.
1860 1860
             # We parse the results of the first upload to get the glance ID of the
1861 1861
             # kernel for use when uploading the root filesystem.
1862 1862
             KERNEL_ID=""; RAMDISK_ID="";
1863 1863
             if [ -n "$KERNEL" ]; then
1864
-                RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"`
1865
-                KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
1864
+                KERNEL_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" --public --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
1866 1865
             fi
1867 1866
             if [ -n "$RAMDISK" ]; then
1868
-                RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"`
1869
-                RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
1867
+                RAMDISK_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" --public --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
1870 1868
             fi
1871
-            glance add -A $TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat --force "${IMAGE}")
1869
+            glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" --public --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}"
1872 1870
         fi
1873 1871
     done
1874 1872
 fi
... ...
@@ -17,14 +17,14 @@ NOVA_BRANCH=master
17 17
 SWIFT_REPO=https://github.com/openstack/swift.git
18 18
 SWIFT_BRANCH=master
19 19
 
20
-# swift and keystone integration
21
-SWIFT_KEYSTONE_REPO=https://github.com/cloudbuilders/swift-keystone2.git
22
-SWIFT_KEYSTONE_BRANCH=master
23
-
24 20
 # image catalog service
25 21
 GLANCE_REPO=https://github.com/openstack/glance.git
26 22
 GLANCE_BRANCH=master
27 23
 
24
+# python glance client library
25
+GLANCECLIENT_REPO=https://github.com/openstack/python-glanceclient
26
+GLANCECLIENT_BRANCH=master
27
+
28 28
 # unified auth system (manages accounts/tokens)
29 29
 KEYSTONE_REPO=https://github.com/openstack/keystone.git
30 30
 KEYSTONE_BRANCH=master