blob: 928efbddb50af10de1cb4c90bdae66c810f5f972 [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
5Library UUID
6Library OperatingSystem
7Resource ../global_properties.robot
8Resource ../json_templater.robot
9Resource openstack_common.robot
10
11*** Variables ***
12${OPENSTACK_KEYSTONE_API_VERSION} /v2.0
13${OPENSTACK_KEYSTONE_AUTH_PATH} /tokens
14${OPENSTACK_KEYSTONE_AUTH_BODY_FILE} robot/assets/templates/keystone_get_auth.template
15${OPENSTACK_KEYSTONE_TENANT_PATH} /tenants
16
17*** Keywords ***
18Run Openstack Auth Request
19 [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
20 [Arguments] ${alias} ${username}= ${password}=
21 ${username} ${password}= Set Openstack Credentials ${username} ${password}
22 ${session}= Create Session keystone ${GLOBAL_OPENSTACK_KEYSTONE_SERVER} verify=True
23 ${uuid}= Generate UUID
24 ${data_template}= OperatingSystem.Get File ${OPENSTACK_KEYSTONE_AUTH_BODY_FILE}
25 ${arguments}= Create Dictionary username=${username} password=${password}
26 ${data}= Fill JSON Template ${data_template} ${arguments}
27 ${data_path}= Catenate ${OPENSTACK_KEYSTONE_API_VERSION}${OPENSTACK_KEYSTONE_AUTH_PATH}
28 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
29 Log Sending authenticate post request ${data_path} with headers ${headers} and data ${data}
30 ${resp}= Post Request keystone ${data_path} data=${data} headers=${headers}
31 Save Openstack Auth ${alias} ${resp.text}
32 Log Received response from keystone ${resp.text}
33
34Get Openstack Tenants
35 [Documentation] Returns all the openstack tenant info
36 [Arguments] ${alias}
37 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_KEYSTONE_SERVICE_TYPE} region= url_ext=${OPENSTACK_KEYSTONE_TENANT_PATH} data_path=
38 [Return] ${resp.json()}
39
40Get Openstack Tenant
41 [Documentation] Returns the openstack tenant info for the specified tenantid
42 [Arguments] ${alias} ${tenant_id}
43 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_KEYSTONE_SERVICE_TYPE} region= url_ext=${OPENSTACK_KEYSTONE_TENANT_PATH} data_path=/${tenant_id}
44 [Return] ${resp.json()}
45
46Set Openstack Credentials
47 [Arguments] ${username} ${password}
48 Return From Keyword If '${username}' != '' ${username} ${password}
49 [Return] ${GLOBAL_VM_PROPERTIES['openstack_username']} ${GLOBAL_VM_PROPERTIES['openstack_password']}