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 |
| 17 | ${NAMED_QUERY_TEMPLATE} robot/assets/templates/aai/named_query.template |
| 18 | ${REVERSE_HEATBRIDGE} |
| 19 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 20 | ${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 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 27 | |
| 28 | *** Keywords *** |
| 29 | Execute 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} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 44 | ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 45 | Should Be Equal As Strings ${resp.status_code} 200 |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 46 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
| 47 | Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 48 | Run Validation Query ${stack_info} ${service} |
| 49 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 50 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 51 | Run Validation Query |
| 52 | [Documentation] Run A&AI query to validate the bulk add |
| 53 | [Arguments] ${stack_info} ${service} |
| 54 | Return from Keyword If '${service}' == '' |
| 55 | ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service} |
| 56 | ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter} |
| 57 | Run Vserver Query ${vserver_name} |
| 58 | |
| 59 | Run Vserver Query |
| 60 | [Documentation] Run A&AI query to validate the bulk add |
| 61 | [Arguments] ${vserver_name} |
| 62 | ${dict}= Create Dictionary vserver_name=${vserver_name} |
| 63 | ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE} |
| 64 | ${request}= Template String ${request} ${dict} |
| 65 | ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request} |
| 66 | Should Be Equal As Strings ${resp.status_code} 200 |
| 67 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 68 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 69 | Execute Reverse Heatbridge |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 70 | [Documentation] VID has already torn down the stack, reverse HB |
| 71 | Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0 |
| 72 | :for ${uri} in @{REVERSE_HEATBRIDGE} |
| 73 | \ Run Keyword And Ignore Error Delete A&AI Entity ${uri} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 74 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 75 | Generate Reverse Heatbridge From Stack Name |
| 76 | [Arguments] ${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 77 | Run Openstack Auth Request auth |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 78 | ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s |
| 79 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
| 80 | [Return] ${reverse_heatbridge} |
| 81 | |
| 82 | Generate Reverse Heatbridge From Stack Info |
| 83 | [Arguments] ${stack_info} |
| 84 | ${reverse_heatbridge}= Create List |
| 85 | ${stack_name}= Get From Dictionary ${stack_info} name |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 86 | ${stack_id}= Get From Dictionary ${stack_info} id |
| 87 | ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 88 | ${keys}= Create Dictionary region=${GLOBAL_OPENSTACK_SERVICE_REGION} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 89 | ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id} |
| 90 | ${resource_list}= Get From Dictionary ${stack_resources} resources |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 91 | :FOR ${resource} in @{resource_list} |
| 92 | \ Log ${resource} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 93 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} |
| 94 | :FOR ${resource} in @{resource_list} |
| 95 | \ Log ${resource} |
| 96 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list} |
| 97 | [Return] ${reverse_heatbridge} |
| 98 | |
| 99 | Generate Vserver Uri |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 100 | [Documentation] Run teardown against the server to generate a message that removes it |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 101 | [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list} |
| 102 | ${resp}= Get Openstack Server By Id ${alias} ${port_id} |
| 103 | Return From Keyword If '${resp.status_code}' != '200' |
| 104 | ${info}= Set Variable ${resp.json()} |
| 105 | Set To Dictionary ${keys} vserver_id=${info['server']['id']} |
| 106 | Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']} |
| 107 | Set To Dictionary ${keys} image_id=${info['server']['image']['id']} |
| 108 | ${uri}= Template String ${VSERVER_URI} ${keys} |
| 109 | Append To List ${reverse_heatbridge} ${uri} |
| 110 | ${uri}= Template String ${FLAVOR_URI} ${keys} |
| 111 | Append To List ${reverse_heatbridge} ${uri} |
| 112 | ${uri}= Template String ${IMAGE_URI} ${keys} |
| 113 | Append To List ${reverse_heatbridge} ${uri} |
| 114 | |
| 115 | Generate Linterface Uri |
| 116 | [Documentation] Run teardown against the server to generate a message that removes it |
| 117 | [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys} |
| 118 | ${resp}= Get Openstack Port By Id ${alias} ${server_id} |
| 119 | Return From Keyword If '${resp.status_code}' != '200' |
| 120 | ${info}= Set Variable ${resp.json()} |
| 121 | Set To Dictionary ${keys} vserver_id=${info['port']['device_id']} |
| 122 | Set To Dictionary ${keys} linterface_id=${info['port']['name']} |
| 123 | ${uri}= Template String ${L_INTERFACE_URI} ${keys} |
| 124 | Append To List ${reverse_heatbridge} ${uri} |
| 125 | |