1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
14 ${success_return_code} 0
19 [Arguments] ${role_name}
21 Should Not Be Empty ${role_name}
22 ${rc} ${stdout}= Run and Return RC and Output osm role-create ${role_name}
24 Should Be Equal As Integers ${rc} ${success_return_code}
29 [Documentation] Updates a role in OSM.
30 ... The extra parameters (like '--add') are given to this function in name=value format. These parameters will be appended to the 'osm role-update' command with the next syntax: --param_name=param_value
31 ... Example of execution:
32 ... Update Role \${role_name} add='vims: true'
34 [Arguments] ${role_name} @{optional_parameters}
36 ${osm_update_command}= Set Variable osm role-update ${role_name}
37 FOR ${param} IN @{optional_parameters}
38 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters
39 ${osm_update_command}= Catenate ${osm_update_command} --${param_name}=${param_value}
41 ${rc} ${stdout}= Run and Return RC and Output ${osm_update_command}
43 Should Be Equal As Integers ${rc} ${success_return_code}
47 [Arguments] ${role_name}
49 Should Not Be Empty ${role_name}
50 ${rc} ${stdout}= Run And Return RC And Output osm role-list | awk 'NR>3 {print $2}' | grep "${role_name}"
52 Should Be Equal As Integers ${rc} ${success_return_code}
55 Check If User Has Role
56 [Arguments] ${user_name} ${role_name} ${project_name}
58 Should Not Be Empty ${user_name}
59 Should Not Be Empty ${role_name}
60 Should Not Be Empty ${project_name}
61 ${rc} ${stdout}= Run And Return RC And Output osm user-show ${user_name} | grep -B1 "role_name" | grep -B1 "${role_name}" | grep "project_name" | grep "${project_name}"
63 Should Be Equal As Integers ${rc} ${success_return_code}
67 [Arguments] ${role_name}
69 ${rc} ${stdout}= Run and Return RC and Output osm role-delete ${role_name}
71 Should Be Equal As Integers ${rc} ${success_return_code}