DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields |
| 3 | Library OpenstackLibrary |
| 4 | Library RequestsLibrary |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 5 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 6 | Library OperatingSystem |
| 7 | Resource ../global_properties.robot |
| 8 | Resource ../json_templater.robot |
| 9 | Resource 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 *** |
| 21 | Get Openstack Volume Types |
| 22 | [Documentation] Returns the openstack volume types information |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 23 | [Arguments] ${alias} |
| 24 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_TYPES_PATH} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 25 | [Return] ${resp.json()} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 26 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 27 | Get Openstack Volume |
| 28 | [Documentation] Returns the openstack volume information for the passed in volume id |
| 29 | [Arguments] ${alias} ${volume_id} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 30 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 31 | [Return] ${resp.json()} |
| 32 | |
| 33 | Add 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} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 40 | ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} data_path= data=${data} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 41 | Should Be Equal As Strings 200 ${resp.status_code} |
| 42 | [Return] ${resp.json()['volume']['id']} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 43 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 44 | Delete Openstack Volume |
| 45 | [Documentation] Runs an Openstack Request to delete a volume |
| 46 | [Arguments] ${alias} ${volume_id} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 47 | ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} /${volume_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 48 | ${status_string}= Convert To String ${resp.status_code} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 49 | Should Match Regexp ${status_string} ^(204|200|404)$ |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 50 | [Return] ${resp.text} |