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 |
| 11 | Resource aai/aai_interface.robot |
| 12 | |
| 13 | *** Variables *** |
| 14 | ${VERSIONED_INDEX_PATH} /aai/v8 |
| 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 | |
| 20 | |
| 21 | *** Keywords *** |
| 22 | Execute Heatbridge |
| 23 | [Documentation] Run the Heatbridge against the stack to generate the bulkadd message |
| 24 | ... Execute the build add |
| 25 | ... Validate the add results by running the named query |
| 26 | [Arguments] ${stack_name} ${service_instance_id} ${service} |
| 27 | Return From Keyword If '${service}' == 'vVG' |
| 28 | Run Openstack Auth Request auth |
| 29 | ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} |
| 30 | ${stack_id}= Get From Dictionary ${stack_info} id |
| 31 | ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id |
| 32 | ${vnf_id}= Get From Dictionary ${stack_info} vnf_id |
| 33 | ${openstack_identity_url}= Catenate ${GLOBAL_OPENSTACK_KEYSTONE_SERVER}/v2.0 |
| 34 | 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} |
| 35 | ${request}= Bridge Data ${stack_id} |
| 36 | Log ${request} |
| 37 | ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request} |
| 38 | Should Be Equal As Strings ${resp.status_code} 200 |
| 39 | Generate Reverse Heatbridge ${request} |
| 40 | Run Validation Query ${stack_info} ${service} |
| 41 | |
| 42 | Run Validation Query |
| 43 | [Documentation] Run A&AI query to validate the bulk add |
| 44 | [Arguments] ${stack_info} ${service} |
| 45 | Return from Keyword If '${service}' == '' |
| 46 | ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service} |
| 47 | ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter} |
| 48 | Run Vserver Query ${vserver_name} |
| 49 | |
| 50 | Run Vserver Query |
| 51 | [Documentation] Run A&AI query to validate the bulk add |
| 52 | [Arguments] ${vserver_name} |
| 53 | ${dict}= Create Dictionary vserver_name=${vserver_name} |
| 54 | ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE} |
| 55 | ${request}= Template String ${request} ${dict} |
| 56 | ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request} |
| 57 | Should Be Equal As Strings ${resp.status_code} 200 |
| 58 | |
| 59 | Generate Reverse Heatbridge |
| 60 | [Documentation] Turn all of the HB puts into deletes... |
| 61 | [Arguments] ${heatbridge_string} |
| 62 | ${heatbridge}= To Json ${heatbridge_string} |
| 63 | ${list}= Get From Dictionary ${heatbridge} transactions |
| 64 | ${transactions}= Create List |
| 65 | ${dupeDict} Create Dictionary |
| 66 | :for ${t} in @{list} |
| 67 | \ ${entry}= Get Deletes From Heatbridge ${t} ${dupeDict} |
| 68 | \ Run Keyword If len(${entry}) > 0 Append To List ${transactions} ${entry} |
| 69 | ${reverse}= Create Dictionary transactions=${transactions} |
| 70 | Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse} |
| 71 | [Return] ${REVERSE_HEATBRIDGE} |
| 72 | |
| 73 | Get Deletes From Heatbridge |
| 74 | [Documentation] Turn all of the HB puts into deletes... Should be one 'put' with one |
| 75 | ... Not sure why this is structured this way, dictionary with operation as the key |
| 76 | ... So only one occurrance of an each operation, but with list of urls/bodies |
| 77 | ... So multiple gets, puts, etc. but in which order??? |
| 78 | [Arguments] ${putDict} ${dupeDict} |
| 79 | ${deleteDict}= Create Dictionary |
| 80 | ${keys}= Get Dictionary Keys ${putDict} |
| 81 | # We do not expect anyhting other than 'put' |
| 82 | :for ${key} in @{keys} |
| 83 | \ Should be Equal ${key} put |
| 84 | \ ${list}= Get From Dictionary ${putDict} put |
| 85 | \ ${deleteList}= Get List Of Deletes ${list} ${dupeDict} |
| 86 | \ Run Keyword If len(${deleteList}) > 0 Set To Dictionary ${deleteDict} delete=${deleteList} |
| 87 | [Return] ${deleteDict} |
| 88 | |
| 89 | Get List Of Deletes |
| 90 | [Documentation] Turn the list of puts into a list of deletes... |
| 91 | ... There is only on hash per 'put' but it looks like there can be more... |
| 92 | [Arguments] ${putList} ${dupeDict} |
| 93 | ${deleteList}= Create List |
| 94 | :for ${put} in @{putList} |
| 95 | \ ${uri}= Get From Dictionary ${put} uri |
| 96 | \ Continue For Loop If '${uri}' in ${dupeDict} |
| 97 | \ ${delete}= Create Dictionary uri=${uri} |
| 98 | \ Append To List ${deleteList} ${delete} |
| 99 | \ Set To Dictionary ${dupeDict} ${uri}=${uri} |
| 100 | [Return] ${deleteList} |
| 101 | |
| 102 | Execute Bulk Transaction |
| 103 | [Arguments] ${transaction} |
| 104 | :for ${put} in ${transaction} |
| 105 | \ Execute Put List ${put} |
| 106 | |
| 107 | Execute Put List |
| 108 | [Arguments] ${put} |
| 109 | Log ${put} |
| 110 | ${list}= Get From Dictionary ${put} put |
| 111 | :for ${request} in @{list} |
| 112 | \ Execute Single Put ${request} |
| 113 | |
| 114 | Execute Single Put |
| 115 | [Arguments] ${request} |
| 116 | ${data}= Get From Dictionary ${request} body |
| 117 | ${path}= Get From Dictionary ${request} uri |
| 118 | ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${path} ${data} |
| 119 | Should Be Equal As Strings ${resp.status_code} 201 |
| 120 | |
| 121 | |
| 122 | Execute Reverse Heatbridge |
| 123 | [Documentation] VID has already torn down the stack, reverse HB |
| 124 | [Arguments] ${reverse_heatbridge} |
| 125 | ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${reverse_heatbridge} |
| 126 | Should Be Equal As Strings ${resp.status_code} 200 |
| 127 | |
| 128 | |
| 129 | Execute Heatbridge Teardown |
| 130 | [Documentation] Run teardown against the stack to generate a bulkadd message that removes it |
| 131 | [Arguments] ${stack_name} |
| 132 | Run Openstack Auth Request auth |
| 133 | ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} |
| 134 | ${stack_id}= Get From Dictionary ${stack_info} id |
| 135 | ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id |
| 136 | ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id} |
| 137 | ${resource_list}= Get From Dictionary ${stack_resources} resources |
| 138 | Get Length ${resource_list} |
| 139 | Log ${resource_list} |
| 140 | :FOR ${resource} in @{resource_list} |
| 141 | \ Log ${resource} |
| 142 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Execute Server Teardown auth ${resource['physical_resource_id']} |
| 143 | |
| 144 | Execute Server Teardown |
| 145 | [Documentation] Run teardown against the server to generate a message that removes it |
| 146 | [Arguments] ${alias} ${server_id} |
| 147 | ${server}= Get Openstack Server By Id ${alias} ${server_id} |
| 148 | Log ${server} |