blob: 3ddeff1163991d870eeb043fec228d93e7020039 [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
jf986099c63292017-03-09 15:28:42 -050017${NAMED_QUERY_TEMPLATE} robot/assets/templates/aai/named_query.template
DR695Hccff30b2017-02-17 18:44:24 -050018
jf986075010a42017-02-22 16:52:54 -050019${BASE_URI} /cloud-infrastructure/cloud-regions/cloud-region/\${cloud}/\${region}
20${IMAGE_URI} ${BASE_URI}/images/image/\${image_id}
21${FLAVOR_URI} ${BASE_URI}/flavors/flavor/\${flavor}
22${VSERVER_URI} ${BASE_URI}/tenants/tenant/\${tenant}/vservers/vserver/\${vserver_id}
23${L_INTERFACE_URI} ${VSERVER_URI}/l-interfaces/l-interface/\${linterface_id}
24
jf986099c63292017-03-09 15:28:42 -050025#******************** Test Case Variables ****************
26${REVERSE_HEATBRIDGE}
27
DR695Hccff30b2017-02-17 18:44:24 -050028
29*** Keywords ***
30Execute Heatbridge
31 [Documentation] Run the Heatbridge against the stack to generate the bulkadd message
32 ... Execute the build add
jf986099c63292017-03-09 15:28:42 -050033 ... Validate the add results by running the named query
34 [Arguments] ${stack_name} ${service_instance_id} ${service}
35 Return From Keyword If '${service}' == 'vVG'
DR695Hccff30b2017-02-17 18:44:24 -050036 Run Openstack Auth Request auth
37 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name}
38 ${stack_id}= Get From Dictionary ${stack_info} id
39 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
40 ${vnf_id}= Get From Dictionary ${stack_info} vnf_id
jf986099c63292017-03-09 15:28:42 -050041 ${openstack_identity_url}= Catenate ${GLOBAL_OPENSTACK_KEYSTONE_SERVER}/v2.0
42 ${region}= Get Openstack Region
43 ${user} ${pass}= Get Openstack Credentials
44 Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER}
DR695Hccff30b2017-02-17 18:44:24 -050045 ${request}= Bridge Data ${stack_id}
46 Log ${request}
DR695H5bf0e2d2017-03-03 17:02:45 -050047 ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request}
DR695H11c06932017-03-03 18:12:49 -050048 ${status_string}= Convert To String ${resp.status_code}
49 Should Match Regexp ${status_string} ^(201|200)$
jf986075010a42017-02-22 16:52:54 -050050 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
51 Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge}
DR695Hccff30b2017-02-17 18:44:24 -050052 Run Validation Query ${stack_info} ${service}
53
jf986075010a42017-02-22 16:52:54 -050054
DR695Hccff30b2017-02-17 18:44:24 -050055Run Validation Query
jf986099c63292017-03-09 15:28:42 -050056 [Documentation] Run A&AI query to validate the bulk add
DR695Hccff30b2017-02-17 18:44:24 -050057 [Arguments] ${stack_info} ${service}
jf986099c63292017-03-09 15:28:42 -050058 Return from Keyword If '${service}' == ''
DR695Hccff30b2017-02-17 18:44:24 -050059 ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service}
60 ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter}
jf986099c63292017-03-09 15:28:42 -050061 Run Vserver Query ${vserver_name}
DR695Hccff30b2017-02-17 18:44:24 -050062
63Run Vserver Query
jf986099c63292017-03-09 15:28:42 -050064 [Documentation] Run A&AI query to validate the bulk add
DR695Hccff30b2017-02-17 18:44:24 -050065 [Arguments] ${vserver_name}
66 ${dict}= Create Dictionary vserver_name=${vserver_name}
67 ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE}
jf986099c63292017-03-09 15:28:42 -050068 ${request}= Template String ${request} ${dict}
DR695Hccff30b2017-02-17 18:44:24 -050069 ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request}
jf986099c63292017-03-09 15:28:42 -050070 Should Be Equal As Strings ${resp.status_code} 200
71
72
DR695Hccff30b2017-02-17 18:44:24 -050073Execute Reverse Heatbridge
jf986075010a42017-02-22 16:52:54 -050074 [Documentation] VID has already torn down the stack, reverse HB
75 Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0
76 :for ${uri} in @{REVERSE_HEATBRIDGE}
77 \ Run Keyword And Ignore Error Delete A&AI Entity ${uri}
DR695Hccff30b2017-02-17 18:44:24 -050078
jf986099c63292017-03-09 15:28:42 -050079Generate Reverse Heatbridge From Stack Name
jf986075010a42017-02-22 16:52:54 -050080 [Arguments] ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050081 Run Openstack Auth Request auth
jf986075010a42017-02-22 16:52:54 -050082 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s
83 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
84 [Return] ${reverse_heatbridge}
jf986099c63292017-03-09 15:28:42 -050085
86Generate Reverse Heatbridge From Stack Info
jf986075010a42017-02-22 16:52:54 -050087 [Arguments] ${stack_info}
88 ${reverse_heatbridge}= Create List
89 ${stack_name}= Get From Dictionary ${stack_info} name
DR695Hccff30b2017-02-17 18:44:24 -050090 ${stack_id}= Get From Dictionary ${stack_info} id
91 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
jf986099c63292017-03-09 15:28:42 -050092 ${region}= Get Openstack Region
93 ${keys}= Create Dictionary region=${region} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id}
DR695Hccff30b2017-02-17 18:44:24 -050094 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
95 ${resource_list}= Get From Dictionary ${stack_resources} resources
DR695Hccff30b2017-02-17 18:44:24 -050096 :FOR ${resource} in @{resource_list}
97 \ Log ${resource}
jf986075010a42017-02-22 16:52:54 -050098 \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys}
99 :FOR ${resource} in @{resource_list}
100 \ Log ${resource}
101 \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list}
102 [Return] ${reverse_heatbridge}
jf986099c63292017-03-09 15:28:42 -0500103
jf986075010a42017-02-22 16:52:54 -0500104Generate Vserver Uri
DR695Hccff30b2017-02-17 18:44:24 -0500105 [Documentation] Run teardown against the server to generate a message that removes it
jf986075010a42017-02-22 16:52:54 -0500106 [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list}
107 ${resp}= Get Openstack Server By Id ${alias} ${port_id}
108 Return From Keyword If '${resp.status_code}' != '200'
jf986099c63292017-03-09 15:28:42 -0500109 ${info}= Set Variable ${resp.json()}
110 Set To Dictionary ${keys} vserver_id=${info['server']['id']}
111 Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']}
112 Set To Dictionary ${keys} image_id=${info['server']['image']['id']}
jf986075010a42017-02-22 16:52:54 -0500113 ${uri}= Template String ${VSERVER_URI} ${keys}
114 Append To List ${reverse_heatbridge} ${uri}
115 ${uri}= Template String ${FLAVOR_URI} ${keys}
116 Append To List ${reverse_heatbridge} ${uri}
117 ${uri}= Template String ${IMAGE_URI} ${keys}
118 Append To List ${reverse_heatbridge} ${uri}
119
120Generate Linterface Uri
121 [Documentation] Run teardown against the server to generate a message that removes it
122 [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys}
123 ${resp}= Get Openstack Port By Id ${alias} ${server_id}
124 Return From Keyword If '${resp.status_code}' != '200'
jf986099c63292017-03-09 15:28:42 -0500125 ${info}= Set Variable ${resp.json()}
jf986075010a42017-02-22 16:52:54 -0500126 Set To Dictionary ${keys} vserver_id=${info['port']['device_id']}
127 Set To Dictionary ${keys} linterface_id=${info['port']['name']}
128 ${uri}= Template String ${L_INTERFACE_URI} ${keys}
129 Append To List ${reverse_heatbridge} ${uri}
jf986099c63292017-03-09 15:28:42 -0500130