blob: 6c48e12086ef0bd04aaa05f486b7aae4ae9aff7a [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with Openstack Keystone API. It handles low level stuff like managing the authtoken and Openstack required fields
3Library OpenstackLibrary
4Library RequestsLibrary
jf986099c63292017-03-09 15:28:42 -05005Library UUID
6Library Collections
DR695Hccff30b2017-02-17 18:44:24 -05007Library OperatingSystem
8Resource ../global_properties.robot
9Resource ../json_templater.robot
10Resource openstack_common.robot
11
12*** Variables ***
13${OPENSTACK_KEYSTONE_API_VERSION} /v2.0
14${OPENSTACK_KEYSTONE_AUTH_PATH} /tokens
15${OPENSTACK_KEYSTONE_AUTH_BODY_FILE} robot/assets/templates/keystone_get_auth.template
16${OPENSTACK_KEYSTONE_TENANT_PATH} /tenants
17
18*** Keywords ***
19Run Openstack Auth Request
20 [Documentation] Runs an Openstack Auth Request and returns the token and service catalog. you need to include the token in future request's x-auth-token headers. Service catalog describes what can be called
21 [Arguments] ${alias} ${username}= ${password}=
22 ${username} ${password}= Set Openstack Credentials ${username} ${password}
23 ${session}= Create Session keystone ${GLOBAL_OPENSTACK_KEYSTONE_SERVER} verify=True
24 ${uuid}= Generate UUID
25 ${data_template}= OperatingSystem.Get File ${OPENSTACK_KEYSTONE_AUTH_BODY_FILE}
26 ${arguments}= Create Dictionary username=${username} password=${password}
27 ${data}= Fill JSON Template ${data_template} ${arguments}
28 ${data_path}= Catenate ${OPENSTACK_KEYSTONE_API_VERSION}${OPENSTACK_KEYSTONE_AUTH_PATH}
29 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
30 Log Sending authenticate post request ${data_path} with headers ${headers} and data ${data}
31 ${resp}= Post Request keystone ${data_path} data=${data} headers=${headers}
jf986099c63292017-03-09 15:28:42 -050032 Save Openstack Auth ${alias} ${resp.text}
DR695Hccff30b2017-02-17 18:44:24 -050033 Log Received response from keystone ${resp.text}
jf986099c63292017-03-09 15:28:42 -050034
DR695Hccff30b2017-02-17 18:44:24 -050035Get Openstack Tenants
36 [Documentation] Returns all the openstack tenant info
37 [Arguments] ${alias}
jf986099c63292017-03-09 15:28:42 -050038 ${resp}= Internal Get Openstack With Region ${alias} ${GLOBAL_OPENSTACK_KEYSTONE_SERVICE_TYPE} region= url_ext=${OPENSTACK_KEYSTONE_TENANT_PATH} data_path=
DR695Hccff30b2017-02-17 18:44:24 -050039 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050040
DR695Hccff30b2017-02-17 18:44:24 -050041Get Openstack Tenant
42 [Documentation] Returns the openstack tenant info for the specified tenantid
43 [Arguments] ${alias} ${tenant_id}
jf986099c63292017-03-09 15:28:42 -050044 ${resp}= Internal Get Openstack With Region ${alias} ${GLOBAL_OPENSTACK_KEYSTONE_SERVICE_TYPE} region= url_ext=${OPENSTACK_KEYSTONE_TENANT_PATH} data_path=/${tenant_id}
DR695Hccff30b2017-02-17 18:44:24 -050045 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050046
DR695Hccff30b2017-02-17 18:44:24 -050047Set Openstack Credentials
48 [Arguments] ${username} ${password}
jf986099c63292017-03-09 15:28:42 -050049 Return From Keyword If '${username}' != '' ${username} ${password}
50 ${user} ${pass}= Get Openstack Credentials
51 [Return] ${user} ${pass}
52
53Get Openstack Credentials
54 Dictionary Should Contain Key ${GLOBAL_VM_PROPERTIES} openstack_username
DR695Hccff30b2017-02-17 18:44:24 -050055 [Return] ${GLOBAL_VM_PROPERTIES['openstack_username']} ${GLOBAL_VM_PROPERTIES['openstack_password']}