DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library HeatBridge |
| 3 | Library Collections |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 4 | Library OperatingSystem |
DR695H | a6ce951 | 2019-07-19 14:25:43 -0400 | [diff] [blame] | 5 | Library ONAPLibrary.ServiceMapping WITH NAME ServiceMapping |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 6 | Library ONAPLibrary.Templating WITH NAME Templating |
| 7 | Library ONAPLibrary.AAI WITH NAME AAI |
| 8 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 9 | |
| 10 | Resource openstack/keystone_interface.robot |
| 11 | Resource openstack/heat_interface.robot |
| 12 | Resource openstack/nova_interface.robot |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 13 | Resource openstack/neutron_interface.robot |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 14 | Resource aai/aai_interface.robot |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 15 | Resource aai/create_vnfc.robot |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | |
| 17 | *** Variables *** |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 18 | ${MULTIPART_PATH} /bulkadd |
| 19 | ${NAMED_QUERY_PATH} /aai/search/named-query |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 20 | ${NAMED_QUERY_TEMPLATE} aai/named_query.jinja |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 21 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 22 | ${BASE_URI} /cloud-infrastructure/cloud-regions/cloud-region/\${cloud}/\${region} |
| 23 | ${IMAGE_URI} ${BASE_URI}/images/image/\${image_id} |
| 24 | ${FLAVOR_URI} ${BASE_URI}/flavors/flavor/\${flavor} |
| 25 | ${VSERVER_URI} ${BASE_URI}/tenants/tenant/\${tenant}/vservers/vserver/\${vserver_id} |
| 26 | ${L_INTERFACE_URI} ${VSERVER_URI}/l-interfaces/l-interface/\${linterface_id} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 27 | ${VSERVER_NAME} \${vserver_name} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 28 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 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 |
DR695H | 1ccabd0 | 2019-07-15 17:19:12 -0400 | [diff] [blame] | 34 | [Arguments] ${stack_name} ${service} ${ipv4_oam_address} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 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 |
Marco Platania | e007927 | 2018-08-01 12:45:28 -0400 | [diff] [blame] | 41 | ${KeyIsPresent}= Run Keyword And Return Status Dictionary Should Contain Key ${stack_info} ${ipv4_oam_address} |
| 42 | ${ipv4_vnf_address}= Run Keyword If ${KeyIsPresent} Get From Dictionary ${stack_info} ${ipv4_oam_address} |
Marco Platania | 4abf21f | 2018-10-29 17:22:52 -0400 | [diff] [blame] | 43 | Run Set VNF Params ${vnf_id} ${ipv4_vnf_address} ACTIVE Active |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 44 | ### Create a vnfc for each vServer ### |
| 45 | ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id} |
| 46 | ${resource_list}= Get From Dictionary ${stack_resources} resources |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 47 | :FOR ${resource} IN @{resource_list} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 48 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Run Create VNFC auth ${resource['physical_resource_id']} ${service} |
Marco Platania | 4abf21f | 2018-10-29 17:22:52 -0400 | [diff] [blame] | 49 | ${keystone_api_version}= Run Keyword If '${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION}'=='' Get KeystoneAPIVersion |
Ah | 2f3b846 | 2018-10-04 11:56:36 +0530 | [diff] [blame] | 50 | ... ELSE Set Variable ${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION} |
Marco Platania | 4abf21f | 2018-10-29 17:22:52 -0400 | [diff] [blame] | 51 | ${url} ${path}= Get Keystone Url And Path ${keystone_api_version} |
Jerry Flood | 596db38 | 2017-10-27 08:37:37 -0400 | [diff] [blame] | 52 | ${openstack_identity_url}= Catenate ${url}${path} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 53 | ${region}= Get Openstack Region |
| 54 | ${user} ${pass}= Get Openstack Credentials |
Ah | 2f3b846 | 2018-10-04 11:56:36 +0530 | [diff] [blame] | 55 | Run Keyword If '${keystone_api_version}'=='v2.0' Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER} |
| 56 | ... ELSE Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER} ${GLOBAL_INJECTED_OPENSTACK_DOMAIN_ID} ${GLOBAL_INJECTED_OPENSTACK_PROJECT_NAME} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 57 | ${request}= Bridge Data ${stack_id} |
| 58 | Log ${request} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 59 | ${resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request} auth=${GLOBAL_AAI_AUTHENTICATION} |
DR695H | 11c0693 | 2017-03-03 18:12:49 -0500 | [diff] [blame] | 60 | ${status_string}= Convert To String ${resp.status_code} |
| 61 | Should Match Regexp ${status_string} ^(201|200)$ |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 62 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
DR695H | fcb0ee8 | 2019-05-22 17:21:38 -0400 | [diff] [blame] | 63 | Run Validation Query ${stack_info} ${service} ${vnf_id} |
DR695H | c1103fb | 2019-07-22 12:37:45 -0400 | [diff] [blame] | 64 | [Return] ${reverse_heatbridge} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 65 | |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 66 | Run Create VNFC |
| 67 | [Documentation] Create a VNFC for a vServer |
| 68 | [Arguments] ${alias} ${vserver_id} ${service} |
| 69 | ${resp}= Get Openstack Server By Id ${alias} ${vserver_id} |
| 70 | Return From Keyword If '${resp.status_code}' != '200' |
| 71 | ${info}= Set Variable ${resp.json()} |
| 72 | ${keys}= Create Dictionary |
DR695H | f1621de | 2019-06-20 15:37:57 -0400 | [diff] [blame] | 73 | ${vnfc_name}= Catenate \ ${info['server']['name']} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 74 | ${vnfc_nc}= Set Variable ${service} |
| 75 | ${vnfc_func}= Set Variable ${service} |
| 76 | Create VNFC If Not Exists ${vnfc_name} ${vnfc_nc} ${vnfc_func} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 77 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 78 | Run Validation Query |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 79 | [Documentation] Run A&AI query to validate the bulk add |
DR695H | fcb0ee8 | 2019-05-22 17:21:38 -0400 | [diff] [blame] | 80 | [Arguments] ${stack_info} ${service} ${vnf_id} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 81 | Return from Keyword If '${service}' == '' |
DR695H | 102f320 | 2019-05-24 15:05:03 -0400 | [diff] [blame] | 82 | ServiceMapping.Set Directory default ${GLOBAL_SERVICE_MAPPING_DIRECTORY} |
DR695H | fcb0ee8 | 2019-05-22 17:21:38 -0400 | [diff] [blame] | 83 | ${payload}= Run Get Generic VNF by VnfId ${vnf_id} |
| 84 | ${vnf_type}= Catenate ${payload.json()[vnf-type]} |
DR695H | a6ce951 | 2019-07-19 14:25:43 -0400 | [diff] [blame] | 85 | ${server_name_parameter}= ServiceMapping.Get Validate Name Mapping default ${service} ${vnf_type} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 86 | ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 87 | Run Vserver Query ${vserver_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 88 | |
| 89 | Run Vserver Query |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 90 | [Documentation] Run A&AI query to validate the bulk add |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 91 | [Arguments] ${vserver_name} |
| 92 | ${dict}= Create Dictionary vserver_name=${vserver_name} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 93 | Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER} |
| 94 | ${request}= Templating.Apply Template aai ${NAMED_QUERY_TEMPLATE} ${dict} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 95 | ${resp}= AAI.Run Post Request ${AAI_FRONTEND_ENDPOINT} ${NAMED_QUERY_PATH} ${request} auth=${GLOBAL_AAI_AUTHENTICATION} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 96 | Should Be Equal As Strings ${resp.status_code} 200 |
| 97 | |
| 98 | |
Marco Platania | bf2a3ee | 2018-07-25 15:10:09 -0400 | [diff] [blame] | 99 | Run Set VNF Params |
| 100 | [Documentation] Run A&A GET and PUT to set prov-status, orchestration status, and ipv4-oam-address |
Marco Platania | 4abf21f | 2018-10-29 17:22:52 -0400 | [diff] [blame] | 101 | [Arguments] ${vnf_id} ${ipv4_vnf_address} ${prov_status}=ACTIVE ${orch_status}=Active |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 102 | ${payload}= Run Get Generic VNF by VnfId ${vnf_id} |
DR695H | fcb0ee8 | 2019-05-22 17:21:38 -0400 | [diff] [blame] | 103 | ${vnf_type}= Catenate ${payload.json()[vnf-type]} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 104 | #${payload_json}= evaluate json.loads('''${payload}''') json |
DR695H | fcb0ee8 | 2019-05-22 17:21:38 -0400 | [diff] [blame] | 105 | set to dictionary ${payload} vnf-type ${prov_status} |
Marco Platania | f44e643 | 2018-05-31 11:09:14 -0400 | [diff] [blame] | 106 | set to dictionary ${payload} orchestration-status ${orch_status} |
Marco Platania | bf2a3ee | 2018-07-25 15:10:09 -0400 | [diff] [blame] | 107 | set to dictionary ${payload} ipv4-oam-address ${ipv4_vnf_address} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 108 | ${payload_string}= evaluate json.dumps(${payload}) json |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 109 | ${put_resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf/${vnf_id} ${payload_string} auth=${GLOBAL_AAI_AUTHENTICATION} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 110 | ${status_string}= Convert To String ${put_resp.status_code} |
| 111 | Should Match Regexp ${status_string} ^(200|201)$ |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 112 | Log Set VNF ProvStatus: ${vnf_id} to ${prov_status} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 113 | |
| 114 | Run Get Generic VNF By VnfId |
| 115 | [Documentation] Get VNF GET Payload with resource ID |
| 116 | [Arguments] ${vnf_id} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 117 | ${resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf?vnf-id=${vnf_id} auth=${GLOBAL_AAI_AUTHENTICATION} |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 118 | Should Be Equal As Strings ${resp.status_code} 200 |
| 119 | [Return] ${resp.json()} |
| 120 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 121 | Execute Reverse Heatbridge |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 122 | [Documentation] VID has already torn down the stack, reverse HB |
DR695H | c1103fb | 2019-07-22 12:37:45 -0400 | [diff] [blame] | 123 | [Arguments] ${uris_to_delete} |
| 124 | Return From Keyword If len(${uris_to_delete}) == 0 |
| 125 | :FOR ${uri} IN @{uris_to_delete} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 126 | \ Run Keyword And Ignore Error Delete A&AI Entity ${uri} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 127 | |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 128 | Generate Reverse Heatbridge From Stack Name |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 129 | [Arguments] ${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 130 | Run Openstack Auth Request auth |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 131 | ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s |
| 132 | ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info} |
| 133 | [Return] ${reverse_heatbridge} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 134 | |
| 135 | Generate Reverse Heatbridge From Stack Info |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 136 | [Arguments] ${stack_info} |
| 137 | ${reverse_heatbridge}= Create List |
| 138 | ${stack_name}= Get From Dictionary ${stack_info} name |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 139 | ${stack_id}= Get From Dictionary ${stack_info} id |
| 140 | ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 141 | ${region}= Get Openstack Region |
| 142 | ${keys}= Create Dictionary region=${region} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 143 | ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id} |
| 144 | ${resource_list}= Get From Dictionary ${stack_resources} resources |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 145 | :FOR ${resource} IN @{resource_list} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 146 | \ Log ${resource} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 147 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 148 | :FOR ${resource} IN @{resource_list} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 149 | \ Log ${resource} |
| 150 | \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list} |
| 151 | [Return] ${reverse_heatbridge} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 152 | |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 153 | Generate Vserver Uri |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 154 | [Documentation] Run teardown against the server to generate a message that removes it |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 155 | [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list} |
| 156 | ${resp}= Get Openstack Server By Id ${alias} ${port_id} |
| 157 | Return From Keyword If '${resp.status_code}' != '200' |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 158 | ${info}= Set Variable ${resp.json()} |
| 159 | Set To Dictionary ${keys} vserver_id=${info['server']['id']} |
| 160 | Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']} |
| 161 | Set To Dictionary ${keys} image_id=${info['server']['image']['id']} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 162 | ${uri}= Templating.Template String ${VSERVER_URI} ${keys} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 163 | Append To List ${reverse_heatbridge} ${uri} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 164 | ${uri}= Templating.Template String ${FLAVOR_URI} ${keys} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 165 | Append To List ${reverse_heatbridge} ${uri} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 166 | ${uri}= Templating.Template String ${IMAGE_URI} ${keys} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 167 | Append To List ${reverse_heatbridge} ${uri} |
| 168 | |
| 169 | Generate Linterface Uri |
| 170 | [Documentation] Run teardown against the server to generate a message that removes it |
| 171 | [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys} |
| 172 | ${resp}= Get Openstack Port By Id ${alias} ${server_id} |
| 173 | Return From Keyword If '${resp.status_code}' != '200' |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 174 | ${info}= Set Variable ${resp.json()} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 175 | Set To Dictionary ${keys} vserver_id=${info['port']['device_id']} |
| 176 | Set To Dictionary ${keys} linterface_id=${info['port']['name']} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 177 | ${uri}= Templating.Template String ${L_INTERFACE_URI} ${keys} |
jf9860 | 75010a4 | 2017-02-22 16:52:54 -0500 | [diff] [blame] | 178 | Append To List ${reverse_heatbridge} ${uri} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 179 | |