blob: 49d78af1f83745a12a3aa60be0269a5151831ba9 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Library HeatBridge
3Library Collections
DR695Hccff30b2017-02-17 18:44:24 -05004Library OperatingSystem
DR695Ha6ce9512019-07-19 14:25:43 -04005Library ONAPLibrary.ServiceMapping WITH NAME ServiceMapping
DR695Hd9794652019-07-19 18:20:40 -04006Library ONAPLibrary.Templating WITH NAME Templating
7Library ONAPLibrary.AAI WITH NAME AAI
8
DR695Hccff30b2017-02-17 18:44:24 -05009
10Resource openstack/keystone_interface.robot
11Resource openstack/heat_interface.robot
12Resource openstack/nova_interface.robot
jf986075010a42017-02-22 16:52:54 -050013Resource openstack/neutron_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -050014Resource aai/aai_interface.robot
Marco Platania992832a2019-02-08 15:25:19 -080015Resource aai/create_vnfc.robot
DR695Hccff30b2017-02-17 18:44:24 -050016
17*** Variables ***
DR695Hccff30b2017-02-17 18:44:24 -050018${MULTIPART_PATH} /bulkadd
19${NAMED_QUERY_PATH} /aai/search/named-query
DR695H3bb6cf42019-06-20 15:04:04 -040020${NAMED_QUERY_TEMPLATE} aai/named_query.jinja
DR695Hccff30b2017-02-17 18:44:24 -050021
jf986075010a42017-02-22 16:52:54 -050022${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 Platania992832a2019-02-08 15:25:19 -080027${VSERVER_NAME} \${vserver_name}
jf986075010a42017-02-22 16:52:54 -050028
jf986099c63292017-03-09 15:28:42 -050029#******************** Test Case Variables ****************
30${REVERSE_HEATBRIDGE}
31
DR695Hccff30b2017-02-17 18:44:24 -050032
33*** Keywords ***
34Execute Heatbridge
35 [Documentation] Run the Heatbridge against the stack to generate the bulkadd message
36 ... Execute the build add
jf986099c63292017-03-09 15:28:42 -050037 ... Validate the add results by running the named query
DR695H1ccabd02019-07-15 17:19:12 -040038 [Arguments] ${stack_name} ${service} ${ipv4_oam_address}
jf986099c63292017-03-09 15:28:42 -050039 Return From Keyword If '${service}' == 'vVG'
DR695Hccff30b2017-02-17 18:44:24 -050040 Run Openstack Auth Request auth
41 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name}
42 ${stack_id}= Get From Dictionary ${stack_info} id
43 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
44 ${vnf_id}= Get From Dictionary ${stack_info} vnf_id
Marco Plataniae0079272018-08-01 12:45:28 -040045 ${KeyIsPresent}= Run Keyword And Return Status Dictionary Should Contain Key ${stack_info} ${ipv4_oam_address}
46 ${ipv4_vnf_address}= Run Keyword If ${KeyIsPresent} Get From Dictionary ${stack_info} ${ipv4_oam_address}
Marco Platania4abf21f2018-10-29 17:22:52 -040047 Run Set VNF Params ${vnf_id} ${ipv4_vnf_address} ACTIVE Active
Marco Platania992832a2019-02-08 15:25:19 -080048 ### Create a vnfc for each vServer ###
49 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
50 ${resource_list}= Get From Dictionary ${stack_resources} resources
DR695H910097e2019-05-08 13:55:32 -040051 :FOR ${resource} IN @{resource_list}
Marco Platania992832a2019-02-08 15:25:19 -080052 \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Run Create VNFC auth ${resource['physical_resource_id']} ${service}
Marco Platania4abf21f2018-10-29 17:22:52 -040053 ${keystone_api_version}= Run Keyword If '${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION}'=='' Get KeystoneAPIVersion
Ah2f3b8462018-10-04 11:56:36 +053054 ... ELSE Set Variable ${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION}
Marco Platania4abf21f2018-10-29 17:22:52 -040055 ${url} ${path}= Get Keystone Url And Path ${keystone_api_version}
Jerry Flood596db382017-10-27 08:37:37 -040056 ${openstack_identity_url}= Catenate ${url}${path}
jf986099c63292017-03-09 15:28:42 -050057 ${region}= Get Openstack Region
58 ${user} ${pass}= Get Openstack Credentials
Ah2f3b8462018-10-04 11:56:36 +053059 Run Keyword If '${keystone_api_version}'=='v2.0' Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER}
60 ... 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}
DR695Hccff30b2017-02-17 18:44:24 -050061 ${request}= Bridge Data ${stack_id}
62 Log ${request}
DR695Hd9794652019-07-19 18:20:40 -040063 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
64 ${resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request} auth=${auth}
DR695H11c06932017-03-03 18:12:49 -050065 ${status_string}= Convert To String ${resp.status_code}
66 Should Match Regexp ${status_string} ^(201|200)$
jf986075010a42017-02-22 16:52:54 -050067 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
68 Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge}
DR695Hfcb0ee82019-05-22 17:21:38 -040069 Run Validation Query ${stack_info} ${service} ${vnf_id}
DR695Hccff30b2017-02-17 18:44:24 -050070
Marco Platania992832a2019-02-08 15:25:19 -080071Run Create VNFC
72 [Documentation] Create a VNFC for a vServer
73 [Arguments] ${alias} ${vserver_id} ${service}
74 ${resp}= Get Openstack Server By Id ${alias} ${vserver_id}
75 Return From Keyword If '${resp.status_code}' != '200'
76 ${info}= Set Variable ${resp.json()}
77 ${keys}= Create Dictionary
DR695Hf1621de2019-06-20 15:37:57 -040078 ${vnfc_name}= Catenate \ ${info['server']['name']}
Marco Platania992832a2019-02-08 15:25:19 -080079 ${vnfc_nc}= Set Variable ${service}
80 ${vnfc_func}= Set Variable ${service}
81 Create VNFC If Not Exists ${vnfc_name} ${vnfc_nc} ${vnfc_func}
jf986075010a42017-02-22 16:52:54 -050082
DR695Hccff30b2017-02-17 18:44:24 -050083Run Validation Query
jf986099c63292017-03-09 15:28:42 -050084 [Documentation] Run A&AI query to validate the bulk add
DR695Hfcb0ee82019-05-22 17:21:38 -040085 [Arguments] ${stack_info} ${service} ${vnf_id}
jf986099c63292017-03-09 15:28:42 -050086 Return from Keyword If '${service}' == ''
DR695Ha6ce9512019-07-19 14:25:43 -040087 ServiceMapping.Set Directory default ./demo/service_mapping
DR695Hfcb0ee82019-05-22 17:21:38 -040088 ${payload}= Run Get Generic VNF by VnfId ${vnf_id}
89 ${vnf_type}= Catenate ${payload.json()[vnf-type]}
DR695Ha6ce9512019-07-19 14:25:43 -040090 ${server_name_parameter}= ServiceMapping.Get Validate Name Mapping default ${service} ${vnf_type}
DR695Hccff30b2017-02-17 18:44:24 -050091 ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter}
jf986099c63292017-03-09 15:28:42 -050092 Run Vserver Query ${vserver_name}
DR695Hccff30b2017-02-17 18:44:24 -050093
94Run Vserver Query
jf986099c63292017-03-09 15:28:42 -050095 [Documentation] Run A&AI query to validate the bulk add
DR695Hccff30b2017-02-17 18:44:24 -050096 [Arguments] ${vserver_name}
97 ${dict}= Create Dictionary vserver_name=${vserver_name}
DR695Hd9794652019-07-19 18:20:40 -040098 Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
99 ${request}= Templating.Apply Template aai ${NAMED_QUERY_TEMPLATE} ${dict}
100 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
101 ${resp}= AAI.Run Post Request ${AAI_FRONTEND_ENDPOINT} ${NAMED_QUERY_PATH} ${request} auth=${auth}
jf986099c63292017-03-09 15:28:42 -0500102 Should Be Equal As Strings ${resp.status_code} 200
103
104
Marco Plataniabf2a3ee2018-07-25 15:10:09 -0400105Run Set VNF Params
106 [Documentation] Run A&A GET and PUT to set prov-status, orchestration status, and ipv4-oam-address
Marco Platania4abf21f2018-10-29 17:22:52 -0400107 [Arguments] ${vnf_id} ${ipv4_vnf_address} ${prov_status}=ACTIVE ${orch_status}=Active
Brian Freeman108048b2018-05-22 13:13:05 -0500108 ${payload}= Run Get Generic VNF by VnfId ${vnf_id}
DR695Hfcb0ee82019-05-22 17:21:38 -0400109 ${vnf_type}= Catenate ${payload.json()[vnf-type]}
Brian Freeman108048b2018-05-22 13:13:05 -0500110 #${payload_json}= evaluate json.loads('''${payload}''') json
DR695Hfcb0ee82019-05-22 17:21:38 -0400111 set to dictionary ${payload} vnf-type ${prov_status}
Marco Plataniaf44e6432018-05-31 11:09:14 -0400112 set to dictionary ${payload} orchestration-status ${orch_status}
Marco Plataniabf2a3ee2018-07-25 15:10:09 -0400113 set to dictionary ${payload} ipv4-oam-address ${ipv4_vnf_address}
Brian Freeman108048b2018-05-22 13:13:05 -0500114 ${payload_string}= evaluate json.dumps(${payload}) json
DR695Hd9794652019-07-19 18:20:40 -0400115 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
116 ${put_resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf/${vnf_id} ${payload_string} auth=${auth}
Brian Freeman108048b2018-05-22 13:13:05 -0500117 ${status_string}= Convert To String ${put_resp.status_code}
118 Should Match Regexp ${status_string} ^(200|201)$
DR695H8e7028b2019-07-10 10:13:58 -0400119 Log Set VNF ProvStatus: ${vnf_id} to ${prov_status}
Brian Freeman108048b2018-05-22 13:13:05 -0500120
121Run Get Generic VNF By VnfId
122 [Documentation] Get VNF GET Payload with resource ID
123 [Arguments] ${vnf_id}
DR695Hd9794652019-07-19 18:20:40 -0400124 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
125 ${resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf?vnf-id=${vnf_id} auth=${auth}
Brian Freeman108048b2018-05-22 13:13:05 -0500126 Should Be Equal As Strings ${resp.status_code} 200
127 [Return] ${resp.json()}
128
DR695Hccff30b2017-02-17 18:44:24 -0500129Execute Reverse Heatbridge
jf986075010a42017-02-22 16:52:54 -0500130 [Documentation] VID has already torn down the stack, reverse HB
131 Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0
DR695H910097e2019-05-08 13:55:32 -0400132 :FOR ${uri} IN @{REVERSE_HEATBRIDGE}
jf986075010a42017-02-22 16:52:54 -0500133 \ Run Keyword And Ignore Error Delete A&AI Entity ${uri}
DR695Hccff30b2017-02-17 18:44:24 -0500134
jf986099c63292017-03-09 15:28:42 -0500135Generate Reverse Heatbridge From Stack Name
jf986075010a42017-02-22 16:52:54 -0500136 [Arguments] ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -0500137 Run Openstack Auth Request auth
jf986075010a42017-02-22 16:52:54 -0500138 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name} timeout=10s
139 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
140 [Return] ${reverse_heatbridge}
jf986099c63292017-03-09 15:28:42 -0500141
142Generate Reverse Heatbridge From Stack Info
jf986075010a42017-02-22 16:52:54 -0500143 [Arguments] ${stack_info}
144 ${reverse_heatbridge}= Create List
145 ${stack_name}= Get From Dictionary ${stack_info} name
DR695Hccff30b2017-02-17 18:44:24 -0500146 ${stack_id}= Get From Dictionary ${stack_info} id
147 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
jf986099c63292017-03-09 15:28:42 -0500148 ${region}= Get Openstack Region
149 ${keys}= Create Dictionary region=${region} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id}
DR695Hccff30b2017-02-17 18:44:24 -0500150 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
151 ${resource_list}= Get From Dictionary ${stack_resources} resources
DR695H910097e2019-05-08 13:55:32 -0400152 :FOR ${resource} IN @{resource_list}
DR695Hccff30b2017-02-17 18:44:24 -0500153 \ Log ${resource}
jf986075010a42017-02-22 16:52:54 -0500154 \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys}
DR695H910097e2019-05-08 13:55:32 -0400155 :FOR ${resource} IN @{resource_list}
jf986075010a42017-02-22 16:52:54 -0500156 \ Log ${resource}
157 \ Run Keyword If '${resource['resource_type']}' == 'OS::Nova::Server' Generate Vserver Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys} ${resource_list}
158 [Return] ${reverse_heatbridge}
jf986099c63292017-03-09 15:28:42 -0500159
jf986075010a42017-02-22 16:52:54 -0500160Generate Vserver Uri
DR695Hccff30b2017-02-17 18:44:24 -0500161 [Documentation] Run teardown against the server to generate a message that removes it
jf986075010a42017-02-22 16:52:54 -0500162 [Arguments] ${alias} ${port_id} ${reverse_heatbridge} ${keys} ${resource_list}
163 ${resp}= Get Openstack Server By Id ${alias} ${port_id}
164 Return From Keyword If '${resp.status_code}' != '200'
jf986099c63292017-03-09 15:28:42 -0500165 ${info}= Set Variable ${resp.json()}
166 Set To Dictionary ${keys} vserver_id=${info['server']['id']}
167 Set To Dictionary ${keys} flavor=${info['server']['flavor']['id']}
168 Set To Dictionary ${keys} image_id=${info['server']['image']['id']}
DR695Hd9794652019-07-19 18:20:40 -0400169 ${uri}= Templating.Template String ${VSERVER_URI} ${keys}
jf986075010a42017-02-22 16:52:54 -0500170 Append To List ${reverse_heatbridge} ${uri}
DR695Hd9794652019-07-19 18:20:40 -0400171 ${uri}= Templating.Template String ${FLAVOR_URI} ${keys}
jf986075010a42017-02-22 16:52:54 -0500172 Append To List ${reverse_heatbridge} ${uri}
DR695Hd9794652019-07-19 18:20:40 -0400173 ${uri}= Templating.Template String ${IMAGE_URI} ${keys}
jf986075010a42017-02-22 16:52:54 -0500174 Append To List ${reverse_heatbridge} ${uri}
175
176Generate Linterface Uri
177 [Documentation] Run teardown against the server to generate a message that removes it
178 [Arguments] ${alias} ${server_id} ${reverse_heatbridge} ${keys}
179 ${resp}= Get Openstack Port By Id ${alias} ${server_id}
180 Return From Keyword If '${resp.status_code}' != '200'
jf986099c63292017-03-09 15:28:42 -0500181 ${info}= Set Variable ${resp.json()}
jf986075010a42017-02-22 16:52:54 -0500182 Set To Dictionary ${keys} vserver_id=${info['port']['device_id']}
183 Set To Dictionary ${keys} linterface_id=${info['port']['name']}
DR695Hd9794652019-07-19 18:20:40 -0400184 ${uri}= Templating.Template String ${L_INTERFACE_URI} ${keys}
jf986075010a42017-02-22 16:52:54 -0500185 Append To List ${reverse_heatbridge} ${uri}
jf986099c63292017-03-09 15:28:42 -0500186