41667999e82e09523a0fd4a15751163810566cd3
[testsuite.git] / robot / resources / openstack / cinder_interface.robot
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           ONAPLibrary.Openstack
4 Library               RequestsLibrary
5 Library           ONAPLibrary.Utilities
6 Resource    ../global_properties.robot
7 Resource    ../json_templater.robot
8 Resource    openstack_common.robot
9
10
11 *** Variables ***
12 ${OPENSTACK_CINDER_API_VERSION}    /v1
13 ${OPENSTACK_CINDER_TYPES_PATH}    /types
14 ${OPENSTACK_CINDER_VOLUMES_PATH}    /volumes
15 ${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE}        robot/assets/templates/cinder_add_volume.template
16 ${OPENSTACK_CINDER_VOLUMES_TYPE}    SSD
17 ${OPENSTACK_CINDER_AVAILABILITY_ZONE}    nova
18
19 *** Keywords ***
20 Get Openstack Volume Types
21     [Documentation]    Returns the openstack volume types information
22     [Arguments]    ${alias}
23     ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE}   ${OPENSTACK_CINDER_TYPES_PATH}
24     [Return]    ${resp.json()}
25
26 Get Openstack Volume
27     [Documentation]    Returns the openstack volume information for the passed in volume id
28     [Arguments]    ${alias}    ${volume_id}
29     ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE}   ${OPENSTACK_CINDER_VOLUMES_PATH}            /${volume_id}
30     [Return]    ${resp.json()}
31
32 Add Openstack Volume
33     [Documentation]    Runs an Openstack Request to add a volume and returns that volume id of the created volume
34     [Arguments]    ${alias}    ${name}      ${size}
35     ${uuid}=    Generate UUID4
36     ${arguments}=    Create Dictionary    name=${name}     description=${GLOBAL_APPLICATION_ID}${uuid}  size=${size}    type=${OPENSTACK_CINDER_VOLUMES_TYPE}    availability_zone=${OPENSTACK_CINDER_AVAILABILITY_ZONE}
37     ${data}=    Fill JSON Template File   ${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE}    ${arguments}
38     ${resp}=    Internal Post Openstack    ${alias}    ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE}   ${OPENSTACK_CINDER_VOLUMES_PATH}    data_path=    data=${data}
39     Should Be Equal As Strings    200  ${resp.status_code}
40     [Return]    ${resp.json()['volume']['id']}
41
42 Delete Openstack Volume
43     [Documentation]    Runs an Openstack Request to delete a volume
44     [Arguments]    ${alias}    ${volume_id}
45     ${resp}=    Internal Delete Openstack    ${alias}    ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE}   ${OPENSTACK_CINDER_VOLUMES_PATH}       /${volume_id}
46     ${status_string}=    Convert To String    ${resp.status_code}
47     Should Match Regexp    ${status_string}    ^(204|200|404)$
48     [Return]    ${resp.text}