Skip to content

Commit 3e9b562

Browse files
committed
Actually check if roles are set
In the helper functions to check if roles are set and if not add the role and return the id we weren't actually checking if the role was set. The reason for this was we grepped for name values while outputing only uuid values with OSC. Fix for this is straightforward, we just add the --role argument to OSC which will filter for us then we don't have to use a grep on the wrong value type. Change-Id: I2691b347d2a6273100deb4a1750ab353a8e49673
1 parent f4b4a79 commit 3e9b562

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

functions-common

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,21 +864,23 @@ function get_or_add_user_project_role {
864864

865865
# Gets user role id
866866
user_role_id=$(openstack role assignment list \
867+
--role $1 \
867868
--user $2 \
868869
--project $3 \
869870
$domain_args \
870-
| grep " $1 " | get_field 1)
871+
| grep '^|\s[a-f0-9]\+' | get_field 1)
871872
if [[ -z "$user_role_id" ]]; then
872873
# Adds role to user and get it
873874
openstack role add $1 \
874875
--user $2 \
875876
--project $3 \
876877
$domain_args
877878
user_role_id=$(openstack role assignment list \
879+
--role $1 \
878880
--user $2 \
879881
--project $3 \
880882
$domain_args \
881-
| grep " $1 " | get_field 1)
883+
| grep '^|\s[a-f0-9]\+' | get_field 1)
882884
fi
883885
echo $user_role_id
884886
}
@@ -889,18 +891,20 @@ function get_or_add_user_domain_role {
889891
local user_role_id
890892
# Gets user role id
891893
user_role_id=$(openstack role assignment list \
894+
--role $1 \
892895
--user $2 \
893896
--domain $3 \
894-
| grep " $1 " | get_field 1)
897+
| grep '^|\s[a-f0-9]\+' | get_field 1)
895898
if [[ -z "$user_role_id" ]]; then
896899
# Adds role to user and get it
897900
openstack role add $1 \
898901
--user $2 \
899902
--domain $3
900903
user_role_id=$(openstack role assignment list \
904+
--role $1 \
901905
--user $2 \
902906
--domain $3 \
903-
| grep " $1 " | get_field 1)
907+
| grep '^|\s[a-f0-9]\+' | get_field 1)
904908
fi
905909
echo $user_role_id
906910
}
@@ -911,6 +915,7 @@ function get_or_add_group_project_role {
911915
local group_role_id
912916
# Gets group role id
913917
group_role_id=$(openstack role assignment list \
918+
--role $1 \
914919
--group $2 \
915920
--project $3 \
916921
-f value)
@@ -920,6 +925,7 @@ function get_or_add_group_project_role {
920925
--group $2 \
921926
--project $3
922927
group_role_id=$(openstack role assignment list \
928+
--role $1 \
923929
--group $2 \
924930
--project $3 \
925931
-f value)

0 commit comments

Comments
 (0)