blob: fa4b26a0ee7c36b353b7e532af8ad656e7a3ac1e [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Library HeatBridge
3Library Collections
4Library StringTemplater
5Library OperatingSystem
6Library UUID
7
8Resource openstack/keystone_interface.robot
9Resource openstack/heat_interface.robot
10Resource openstack/nova_interface.robot
jf986075010a42017-02-22 16:52:54 -050011Resource openstack/neutron_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -050012Resource aai/aai_interface.robot
13
14*** Variables ***
DR695Hccff30b2017-02-17 18:44:24 -050015${MULTIPART_PATH} /bulkadd
16${NAMED_QUERY_PATH} /aai/search/named-query
17${NAMED_QUERY_TEMPLATE} robot/assets/templates/aai/named_query.template
18${REVERSE_HEATBRIDGE}
19
jf986075010a42017-02-22 16:52:54 -050020${BASE_URI} /cloud-infrastructure/cloud-regions/cloud-region/\${cloud}/\${region}
21${IMAGE_URI} ${BASE_URI}/images/image/\${image_id}
22${FLAVOR_URI} ${BASE_URI}/flavors/flavor/\${flavor}
23${VSERVER_URI} ${BASE_URI}/tenants/tenant/\${tenant}/vservers/vserver/\${vserver_id}
24${L_INTERFACE_URI} ${VSERVER_URI}/l-interfaces/l-interface/\${linterface_id}
25
26
DR695Hccff30b2017-02-17 18:44:24 -050027
28*** Keywords ***
29Execute Heatbridge
30 [Documentation] Run the Heatbridge against the stack to generate the bulkadd message
31 ... Execute the build add
32 ... Validate the add results by running the named query
33 [Arguments] ${stack_name} ${service_instance_id} ${service}
34 Return From Keyword If '${service}' == 'vVG'
35 Run Openstack Auth Request auth
36 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name}
37 ${stack_id}= Get From Dictionary ${stack_info} id
38 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
39 ${vnf_id}= Get From Dictionary ${stack_info} vnf_id
40 ${openstack_identity_url}= Catenate ${GLOBAL_OPENSTACK_KEYSTONE_SERVER}/v2.0
41 Init Bridge ${openstack_identity_url} ${GLOBAL_VM_PROPERTIES['openstack_username']} ${GLOBAL_VM_PROPERTIES['openstack_password']} ${tenant_id} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${GLOBAL_AAI_CLOUD_OWNER}
42 ${request}= Bridge Data ${stack_id}
43 Log ${request}
DR695H5bf0e2d2017-03-03 17:02:45 -050044 ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request}
DR695H11c06932017-03-03 18:12:49 -050045 ${status_string}= Convert To String ${resp.status_code}
46 Should Match Regexp ${status_string} ^(201|200)$
jf986075010a42017-02-22 16:52:54 -050047 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
48 Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge}
DR695Hccff30b2017-02-17 18:44:24 -050049 Run Validation Query ${stack_info} ${service}
50
jf986075010a42017-02-22 16:52:54 -050051
DR695Hccff30b2017-02-17 18:44:24 -050052Run Validation Query
53 [Documentation] Run A&AI query to validate the bulk add
54 [Arguments] ${stack_info} ${service}
55 Return from Keyword If '${service}' == ''
56 ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service}
57 ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter}
58 Run Vserver Query ${vserver_name}
59
60Run Vserver Query
61 [Documentation] Run A&AI query to validate the bulk add
62 [Arguments] ${vserver_name}
63 ${dict}= Create Dictionary vserver_name=${vserver_name}
64 ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE}
65 ${request}= Template String ${request} ${dict}
66 ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request}
67 Should Be Equal As Strings ${resp.status_code} 200
68
DR695Hccff30b2017-02-17 18:44:24 -050069
DR695Hccff30b2017-02-17 18:44:24 -050070Execute Reverse Heatbridge
jf986075010a42017-02-22 16:52:54 -050071 [Documentation] VID has already torn down the stack, reverse HB
72 Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0
73 :for ${uri} in @{REVERSE_HEATBRIDGE}
74 \ Run Keyword And Ignore Error Delete A&AI Entity ${uri}
DR695Hccff30b2017-02-17 18:44:24 -050075
jf986075010a42017-02-22 16:52:54 -050076Generate Reverse Heatbridge From Stack Name
77 [Arguments] ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050078 Run Openstack Auth Request auth
jf986075010a42017-02-22 16:52:54 -050079 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s
80 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
81 [Return] ${reverse_heatbridge}
82
83Generate Reverse Heatbridge From Stack Info
84 [Arguments] ${stack_info}
85 ${reverse_heatbridge}= Create List
86 ${stack_name}= Get From Dictionary ${stack_info} name
DR695Hccff30b2017-02-17 18:44:24 -050087 ${stack_id}= Get From Dictionary ${stack_info} id
88 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
jf986075010a42017-02-22 16:52:54 -050089 ${keys}= Create Dictionary region=${GLOBAL_OPENSTACK_SERVICE_REGION} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id}
DR695Hccff30b2017-02-17 18:44:24 -050090 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
91 ${resource_list}= Get From Dictionary ${stack_resources} resources
DR695Hccff30b2017-02-17 18:44:24 -050092 :FOR ${resource} in @{resource_list}
93 \ Log ${resource}
jf986075010a42017-02-22 16:52:54 -050094 \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys}
95 :FOR ${resource} in @{resource_list}
96 \ Log ${resource}
97 \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list}
98 [Return] ${reverse_heatbridge}
99
100Generate Vserver Uri
DR695Hccff30b2017-02-17 18:44:24 -0500101 [Documentation] Run teardown against the server to generate a message that removes it
jf986075010a42017-02-22 16:52:54 -0500102 [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list}
103 ${resp}= Get Openstack Server By Id ${alias} ${port_id}
104 Return From Keyword If '${resp.status_code}' != '200'
105 ${info}= Set Variable ${resp.json()}
106 Set To Dictionary ${keys} vserver_id=${info['server']['id']}
107 Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']}
108 Set To Dictionary ${keys} image_id=${info['server']['image']['id']}
109 ${uri}= Template String ${VSERVER_URI} ${keys}
110 Append To List ${reverse_heatbridge} ${uri}
111 ${uri}= Template String ${FLAVOR_URI} ${keys}
112 Append To List ${reverse_heatbridge} ${uri}
113 ${uri}= Template String ${IMAGE_URI} ${keys}
114 Append To List ${reverse_heatbridge} ${uri}
115
116Generate Linterface Uri
117 [Documentation] Run teardown against the server to generate a message that removes it
118 [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys}
119 ${resp}= Get Openstack Port By Id ${alias} ${server_id}
120 Return From Keyword If '${resp.status_code}' != '200'
121 ${info}= Set Variable ${resp.json()}
122 Set To Dictionary ${keys} vserver_id=${info['port']['device_id']}
123 Set To Dictionary ${keys} linterface_id=${info['port']['name']}
124 ${uri}= Template String ${L_INTERFACE_URI} ${keys}
125 Append To List ${reverse_heatbridge} ${uri}
126