blob: 1b7203597c7c8a559db6ee856553be8ac577dab6 [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
jf986099c63292017-03-09 15:28:42 -05005Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05006Library 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
jf986099c63292017-03-09 15:28:42 -050023 [Arguments] ${alias}
24 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_TYPES_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050025 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050026
DR695Hccff30b2017-02-17 18:44:24 -050027Get Openstack Volume
28 [Documentation] Returns the openstack volume information for the passed in volume id
29 [Arguments] ${alias} ${volume_id}
jf986099c63292017-03-09 15:28:42 -050030 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id}
DR695Hccff30b2017-02-17 18:44:24 -050031 [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}
jf986099c63292017-03-09 15:28:42 -050040 ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} data_path= data=${data}
DR695Hccff30b2017-02-17 18:44:24 -050041 Should Be Equal As Strings 200 ${resp.status_code}
42 [Return] ${resp.json()['volume']['id']}
jf986099c63292017-03-09 15:28:42 -050043
DR695Hccff30b2017-02-17 18:44:24 -050044Delete Openstack Volume
45 [Documentation] Runs an Openstack Request to delete a volume
46 [Arguments] ${alias} ${volume_id}
jf986099c63292017-03-09 15:28:42 -050047 ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id}
DR695Hccff30b2017-02-17 18:44:24 -050048 ${status_string}= Convert To String ${resp.status_code}
jf986099c63292017-03-09 15:28:42 -050049 Should Match Regexp ${status_string} ^(204|200|404)$
DR695Hccff30b2017-02-17 18:44:24 -050050 [Return] ${resp.text}