blob: ee1a253b3ba5059db21b9f688174ee3dea3e2d1f [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with Openstack. 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
12*** Variables ***
13${OPENSTACK_CINDER_API_VERSION} /v1
14${OPENSTACK_CINDER_TYPES_PATH} /types
15${OPENSTACK_CINDER_VOLUMES_PATH} /volumes
16${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE} robot/assets/templates/cinder_add_volume.template
17${OPENSTACK_CINDER_VOLUMES_TYPE} SSD
18${OPENSTACK_CINDER_AVAILABILITY_ZONE} nova
19
20*** Keywords ***
21Get Openstack Volume Types
22 [Documentation] Returns the openstack volume types information
23 [Arguments] ${alias}
24 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_CINDER_TYPES_PATH}
25 [Return] ${resp.json()}
26
27Get Openstack Volume
28 [Documentation] Returns the openstack volume information for the passed in volume id
29 [Arguments] ${alias} ${volume_id}
30 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id}
31 [Return] ${resp.json()}
32
33Add Openstack Volume
34 [Documentation] Runs an Openstack Request to add a volume and returns that volume id of the created volume
35 [Arguments] ${alias} ${name} ${size}
36 ${data_template}= OperatingSystem.Get File ${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE}
37 ${uuid}= Generate UUID
38 ${arguments}= Create Dictionary name=${name} description=${GLOBAL_APPLICATION_ID}${uuid} size=${size} type=${OPENSTACK_CINDER_VOLUMES_TYPE} availability_zone=${OPENSTACK_CINDER_AVAILABILITY_ZONE}
39 ${data}= Fill JSON Template ${data_template} ${arguments}
40 ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_CINDER_VOLUMES_PATH} data_path= data=${data}
41 Should Be Equal As Strings 200 ${resp.status_code}
42 [Return] ${resp.json()['volume']['id']}
43
44Delete Openstack Volume
45 [Documentation] Runs an Openstack Request to delete a volume
46 [Arguments] ${alias} ${volume_id}
47 ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id}
48 ${status_string}= Convert To String ${resp.status_code}
49 Should Match Regexp ${status_string} ^(204|200|404)$
50 [Return] ${resp.text}