]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat-keystone-setup workaround keystone output reordering
authorSteven Hardy <shardy@redhat.com>
Wed, 24 Oct 2012 12:41:34 +0000 (13:41 +0100)
committerSteven Hardy <shardy@redhat.com>
Thu, 25 Oct 2012 09:01:19 +0000 (10:01 +0100)
Folsom version of keystoneclient orders the columns for
keystone user-list differently, so we need to detect the
new format to extract the correct field

Fixes #273

Change-Id: I46f653dd3a8f7b5a68648fbd72671f95b386a547
Signed-off-by: Steven Hardy <shardy@redhat.com>
bin/heat-keystone-setup

index a908555626f97240c77a3b5f1925561304eda65a..74691bd0b883251ca91a3ef37ccb6657898ad1e0 100755 (executable)
@@ -44,10 +44,21 @@ get_id () {
     get_data 1 id 2 "$@"
 }
 
+get_column_num() {
+    local name=$1
+    shift
+    $@ | awk -F'|' "NR == 2 { for (i=2; i<NF; i++) if (\$i ~ \"^ *${name} *\$\") print (i - 1) }"
+}
+
 get_user() {
     local username=$1
 
-    local user_id=$(get_data 4 $username 1 keystone user-list)
+    # Outut format of keystone user-list changed between essex and
+    # folsom - the columns have been re-ordered (!?), so detect what
+    # column to pass to get_data via get_column_num
+    namecol=$(get_column_num name keystone user-list)
+
+    local user_id=$(get_data $namecol $username 1 keystone user-list)
 
     if [ -n "$user_id" ]; then
         echo "Found existing $username user" >&2