DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library HeatBridge |
| 3 | Library Collections |
| 4 | Library StringTemplater |
| 5 | Library OperatingSystem |
| 6 | Library UUID |
| 7 | |
| 8 | Resource openstack/keystone_interface.robot |
| 9 | Resource openstack/heat_interface.robot |
| 10 | Resource openstack/nova_interface.robot |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 11 | Resource openstack/neutron_interface.robot |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 12 | Resource aai/aai_interface.robot |
| 13 | |
| 14 | *** Variables *** |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 15 | ${MULTIPART_PATH} /bulkadd |
| 16 | ${NAMED_QUERY_PATH} /aai/search/named-query |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 17 | ${NAMED_QUERY_TEMPLATE} robot/assets/templates/aai/named_query.template |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 18 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 19 | ${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 | |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 25 | #******************** Test Case Variables **************** |
| 26 | ${REVERSE_HEATBRIDGE} |
| 27 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 28 | |
| 29 | *** Keywords *** |
| 30 | Execute Heatbridge |
| 31 | [Documentation] Run the Heatbridge against the stack to generate the bulkadd message |
| 32 | ... Execute the build add |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 33 | ... Validate the add results by running the named query |
| 34 | [Arguments] ${stack_name} ${service_instance_id} ${service} |
| 35 | Return From Keyword If '${service}' == 'vVG' |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 36 | 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 |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame^] | 41 | Run Set VNF ProvStatus ${vnf_id} PROV |
Jerry Flood | 596db38 | 2017-10-27 08:37:37 -0400 | [diff] [blame] | 42 | ${url} ${path}= Get Keystone Url And Path |
| 43 | ${openstack_identity_url}= Catenate ${url}${path} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 44 | ${region}= Get Openstack Region |
| 45 | ${user} ${pass}= Get Openstack Credentials |
| 46 | Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 47 | ${request}= Bridge Data ${stack_id} |
| 48 | Log ${request} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame^] | 49 | ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request} |
DR695H | 11c0693 | 2017-03-03 18:12:49 -0500 | [diff] [blame] | 50 | ${status_string}= Convert To String ${resp.status_code} |
| 51 | Should Match Regexp ${status_string} ^(201|200)$ |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 52 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
| 53 | Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 54 | Run Validation Query ${stack_info} ${service} |
| 55 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 56 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 57 | Run Validation Query |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 58 | [Documentation] Run A&AI query to validate the bulk add |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 59 | [Arguments] ${stack_info} ${service} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 60 | Return from Keyword If '${service}' == '' |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 61 | ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service} |
| 62 | ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 63 | Run Vserver Query ${vserver_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 64 | |
| 65 | Run Vserver Query |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 66 | [Documentation] Run A&AI query to validate the bulk add |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 67 | [Arguments] ${vserver_name} |
| 68 | ${dict}= Create Dictionary vserver_name=${vserver_name} |
| 69 | ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 70 | ${request}= Template String ${request} ${dict} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 71 | ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 72 | Should Be Equal As Strings ${resp.status_code} 200 |
| 73 | |
| 74 | |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame^] | 75 | Run Set VNF ProvStatus |
| 76 | [Documentation] Run A&A GET and PUT to set prov-status |
| 77 | [Arguments] ${vnf_id} ${prov_status}=PROV |
| 78 | ${payload}= Run Get Generic VNF by VnfId ${vnf_id} |
| 79 | |
| 80 | #${payload_json}= evaluate json.loads('''${payload}''') json |
| 81 | set to dictionary ${payload} prov-status ${prov_status} |
| 82 | ${payload_string}= evaluate json.dumps(${payload}) json |
| 83 | |
| 84 | ${put_resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf/${vnf_id} ${payload_string} |
| 85 | ${status_string}= Convert To String ${put_resp.status_code} |
| 86 | Should Match Regexp ${status_string} ^(200|201)$ |
| 87 | Log To Console Set VNF ProvStatus: ${vnf_id} to ${prov_status} |
| 88 | |
| 89 | Run Get Generic VNF By VnfId |
| 90 | [Documentation] Get VNF GET Payload with resource ID |
| 91 | [Arguments] ${vnf_id} |
| 92 | ${resp}= Run A&AI Get Request ${AAI_INDEX PATH}/network/generic-vnfs/generic-vnf?vnf-id=${vnf_id} |
| 93 | Should Be Equal As Strings ${resp.status_code} 200 |
| 94 | [Return] ${resp.json()} |
| 95 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 96 | Execute Reverse Heatbridge |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 97 | [Documentation] VID has already torn down the stack, reverse HB |
| 98 | Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0 |
| 99 | :for ${uri} in @{REVERSE_HEATBRIDGE} |
| 100 | \ Run Keyword And Ignore Error Delete A&AI Entity ${uri} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 101 | |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 102 | Generate Reverse Heatbridge From Stack Name |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 103 | [Arguments] ${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 104 | Run Openstack Auth Request auth |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 105 | ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s |
| 106 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
| 107 | [Return] ${reverse_heatbridge} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 108 | |
| 109 | Generate Reverse Heatbridge From Stack Info |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 110 | [Arguments] ${stack_info} |
| 111 | ${reverse_heatbridge}= Create List |
| 112 | ${stack_name}= Get From Dictionary ${stack_info} name |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 113 | ${stack_id}= Get From Dictionary ${stack_info} id |
| 114 | ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 115 | ${region}= Get Openstack Region |
| 116 | ${keys}= Create Dictionary region=${region} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 117 | ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id} |
| 118 | ${resource_list}= Get From Dictionary ${stack_resources} resources |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 119 | :FOR ${resource} in @{resource_list} |
| 120 | \ Log ${resource} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 121 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} |
| 122 | :FOR ${resource} in @{resource_list} |
| 123 | \ Log ${resource} |
| 124 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list} |
| 125 | [Return] ${reverse_heatbridge} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 126 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 127 | Generate Vserver Uri |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 128 | [Documentation] Run teardown against the server to generate a message that removes it |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 129 | [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list} |
| 130 | ${resp}= Get Openstack Server By Id ${alias} ${port_id} |
| 131 | Return From Keyword If '${resp.status_code}' != '200' |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 132 | ${info}= Set Variable ${resp.json()} |
| 133 | Set To Dictionary ${keys} vserver_id=${info['server']['id']} |
| 134 | Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']} |
| 135 | Set To Dictionary ${keys} image_id=${info['server']['image']['id']} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 136 | ${uri}= Template String ${VSERVER_URI} ${keys} |
| 137 | Append To List ${reverse_heatbridge} ${uri} |
| 138 | ${uri}= Template String ${FLAVOR_URI} ${keys} |
| 139 | Append To List ${reverse_heatbridge} ${uri} |
| 140 | ${uri}= Template String ${IMAGE_URI} ${keys} |
| 141 | Append To List ${reverse_heatbridge} ${uri} |
| 142 | |
| 143 | Generate Linterface Uri |
| 144 | [Documentation] Run teardown against the server to generate a message that removes it |
| 145 | [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys} |
| 146 | ${resp}= Get Openstack Port By Id ${alias} ${server_id} |
| 147 | Return From Keyword If '${resp.status_code}' != '200' |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 148 | ${info}= Set Variable ${resp.json()} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 149 | Set To Dictionary ${keys} vserver_id=${info['port']['device_id']} |
| 150 | Set To Dictionary ${keys} linterface_id=${info['port']['name']} |
| 151 | ${uri}= Template String ${L_INTERFACE_URI} ${keys} |
| 152 | Append To List ${reverse_heatbridge} ${uri} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 153 | |