--- /dev/null
+*** Comments ***
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+*** Settings ***
+Documentation Library providing keywords for CRUD operations over roles with OSM client.
+Library OperatingSystem
+
+
+*** Variables ***
+${SUCCESS_RETURN_CODE} 0
+
+
+*** Keywords ***
+Create Role
+ [Documentation] Create a role in OSM with the name passed as argument, and return the role id.
+ [Arguments] ${role_name}
+ Should Not Be Empty ${role_name}
+ ${rc} ${stdout}= Run And Return Rc And Output osm role-create ${role_name}
+ Log ${stdout}
+ Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
+ RETURN ${stdout}
+
+Update Role
+ [Documentation] Update a role in OSM.
+ ... 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
+ ... Example of execution:
+ ... Update Role \${role_name} add='vims: true'
+ [Arguments] ${role_name} @{optional_parameters}
+ ${osm_update_command}= Set Variable osm role-update ${role_name}
+ FOR ${param} IN @{optional_parameters}
+ ${match} ${param_name} ${param_value}= Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters
+ Log ${match},${param_name},${param_value}
+ ${osm_update_command}= Catenate ${osm_update_command} --${param_name}=${param_value}
+ END
+ ${rc} ${stdout}= Run And Return Rc And Output ${osm_update_command}
+ Log ${stdout}
+ Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
+
+Check If Role Exists
+ [Documentation] Check if a role exists in OSM.
+ [Arguments] ${role_name}
+ Should Not Be Empty ${role_name}
+ ${rc} ${stdout}= Run And Return RC And Output osm role-list | awk 'NR>3 {print $2}' | grep "${role_name}"
+ Log ${stdout}
+ Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
+
+Check If User Has Role
+ [Documentation] Check if a user has a role in a specific project in OSM.
+ [Arguments] ${user_name} ${role_name} ${project_name}
+ Should Not Be Empty ${user_name}
+ Should Not Be Empty ${role_name}
+ Should Not Be Empty ${project_name}
+ ${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}"
+ Log ${stdout}
+ Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
+
+Delete Role
+ [Documentation] Delete from OSM the role passed as argument.
+ [Arguments] ${role_name}
+ ${rc} ${stdout}= Run And Return Rc And Output osm role-delete ${role_name}
+ Log ${stdout}
+ Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}