aboutsummaryrefslogtreecommitdiffstats
path: root/robot/resources/openstack/heat_interface.robot
blob: 0362d3eba36b8975ef1675fecd4d5096a4abad4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
*** Settings ***
Documentation     The interface for interacting with Openstack Heat API.
Library           ONAPLibrary.Openstack
Library         RequestsLibrary
Library           OperatingSystem
Library           Collections
Library           ONAPLibrary.Templating
Resource    ../global_properties.robot
Resource    openstack_common.robot

*** Variables ***
${OPENSTACK_HEAT_API_VERSION}    /v1
${OPENSTACK_HEAT_STACK_PATH}    /stacks
${OPENSTACK_HEAT_ADD_STACK_TEMPLATE}    openstack/heat_add_stack.jinja


*** Keywords ***
Get Openstack Stacks
    [Documentation]    Returns the openstack stacks info
    [Arguments]    ${alias}
    ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}
    [Return]    ${resp.json()}

Get Openstack Stack
    [Documentation]    Returns the openstack stacks info for the given stack name
    [Arguments]    ${alias}    ${stack_name}
    ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    /${stack_name}
    [Return]    ${resp.json()}

Create Openstack Stack
    [Documentation]    Takes an openstack heat yaml and returns the created stack
    [Arguments]    ${alias}    ${request}
    ${resp}=    Internal Post Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    data_path=    data=${request}
    [Return]    ${resp.json()}

Make Add Stack Request
    [Documentation]    Makes a JSON Add Stack Request from  YAML template and env files
    [Arguments]    ${name}    ${template}    ${env}
    ${templatedata}=    Template Yaml To Json    ${template}
    ${envdata}=    Env Yaml To Json    ${env}
    ${dict}=  Create Dictionary     template=${templatedata}    parameters=${envdata}    stack_name=${name}
    Create Environment    heat    ${GLOBAL_TEMPLATE_FOLDER}
    ${request}=    Apply Template    heat    ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE}    ${dict}
    Log    ${request}
    [Return]    ${request}

Delete Openstack Stack
    [Documentation]    Deletes and Openstack Stack for the passed name and id
    [Arguments]    ${alias}    ${stack_name}    ${stack_id}
    ${data_path}=    Catenate    /${stack_name}/${stack_id}
    ${resp}=    Internal Delete Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    data_path=${data_path}
    Should Be Equal As Strings    204  ${resp.status_code}
    [Return]    ${resp}

Get Stack Details
    [Documentation]    Gets all of the information necessary for tearing down an existing Openstack Stack
    [Arguments]    ${alias}    ${stack_name}
    ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    /${stack_name}
    ${result}=    Stack Info Parse    ${resp.json()}
    [Return]     ${result}

Get Stack Template
    [Documentation]    Gets all of the template information of an existing Openstack Stack
    [Arguments]    ${alias}    ${stack_name}    ${stack_id}
    ${data_path}=    Catenate    /${stack_name}/${stack_id}/template
    ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    ${data_path}
    ${template}=  Catenate    ${resp.json()}
    [Return]    ${template}

Get Stack Resources
    [Documentation]    Gets all of the resources of an existing Openstack Stack
    [Arguments]    ${alias}    ${stack_name}    ${stack_id}
    ${data_path}=    Catenate    /${stack_name}/${stack_id}/resources
    ${resp}=    Internal Get Openstack    ${alias}    ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE}    ${OPENSTACK_HEAT_STACK_PATH}    ${data_path}
    [Return]    ${resp.json()}

Wait for Stack to Be Deployed
    [Arguments]    ${alias}   ${stack_name}    ${timeout}=${GLOBAL_OPENSTACK_STACK_DEPLOYMENT_TIMEOUT}
    ${stack_info}=    Wait Until Keyword Succeeds    ${timeout}    30 sec    Get Deployed Stack    ${alias}    ${stack_name}
    ${status}=   Get From Dictionary    ${stack_info}    stack_status
    Should Be Equal    ${status}    CREATE_COMPLETE
    [Return]    ${stack_info}

Get Deployed Stack
    [Arguments]    ${alias}    ${stack_name}
    ${stack_info}=    Get Stack Details    ${alias}    ${stack_name}
    ${status}=   Get From Dictionary    ${stack_info}    stack_status
    Should Not Be Equal    ${status}    CREATE_IN_PROGRESS
    [Return]    ${stack_info}