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>
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