blob: c0b9a9108c68dbdc3d377d5883dd4ed592e5c835 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Library HeatBridge
3Library Collections
4Library StringTemplater
5Library OperatingSystem
6Library UUID
7
8Resource openstack/keystone_interface.robot
9Resource openstack/heat_interface.robot
10Resource openstack/nova_interface.robot
jf986075010a42017-02-22 16:52:54 -050011Resource openstack/neutron_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -050012Resource aai/aai_interface.robot
Marco Platania992832a2019-02-08 15:25:19 -080013Resource aai/create_vnfc.robot
DR695Hccff30b2017-02-17 18:44:24 -050014
15*** Variables ***
DR695Hccff30b2017-02-17 18:44:24 -050016${MULTIPART_PATH} /bulkadd
17${NAMED_QUERY_PATH} /aai/search/named-query
jf986099c63292017-03-09 15:28:42 -050018${NAMED_QUERY_TEMPLATE} robot/assets/templates/aai/named_query.template
DR695Hccff30b2017-02-17 18:44:24 -050019
jf986075010a42017-02-22 16:52:54 -050020${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}
Marco Platania992832a2019-02-08 15:25:19 -080025${VSERVER_NAME} \${vserver_name}
jf986075010a42017-02-22 16:52:54 -050026
jf986099c63292017-03-09 15:28:42 -050027#******************** Test Case Variables ****************
28${REVERSE_HEATBRIDGE}
29
DR695Hccff30b2017-02-17 18:44:24 -050030
31*** Keywords ***
32Execute Heatbridge
33 [Documentation] Run the Heatbridge against the stack to generate the bulkadd message
34 ... Execute the build add
jf986099c63292017-03-09 15:28:42 -050035 ... Validate the add results by running the named query
Marco Plataniabf2a3ee2018-07-25 15:10:09 -040036 [Arguments] ${stack_name} ${service_instance_id} ${service} ${ipv4_oam_address}
jf986099c63292017-03-09 15:28:42 -050037 Return From Keyword If '${service}' == 'vVG'
DR695Hccff30b2017-02-17 18:44:24 -050038 Run Openstack Auth Request auth
39 ${stack_info}= Wait for Stack to Be Deployed auth ${stack_name}
40 ${stack_id}= Get From Dictionary ${stack_info} id
41 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
42 ${vnf_id}= Get From Dictionary ${stack_info} vnf_id
Marco Plataniae0079272018-08-01 12:45:28 -040043 ${KeyIsPresent}= Run Keyword And Return Status Dictionary Should Contain Key ${stack_info} ${ipv4_oam_address}
44 ${ipv4_vnf_address}= Run Keyword If ${KeyIsPresent} Get From Dictionary ${stack_info} ${ipv4_oam_address}
Marco Platania4abf21f2018-10-29 17:22:52 -040045 Run Set VNF Params ${vnf_id} ${ipv4_vnf_address} ACTIVE Active
Marco Platania992832a2019-02-08 15:25:19 -080046 ### Create a vnfc for each vServer ###
47 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
48 ${resource_list}= Get From Dictionary ${stack_resources} resources
49 :FOR ${resource} in @{resource_list}
50 \ 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 -040051 ${keystone_api_version}= Run Keyword If '${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION}'=='' Get KeystoneAPIVersion
Ah2f3b8462018-10-04 11:56:36 +053052 ... ELSE Set Variable ${GLOBAL_INJECTED_OPENSTACK_KEYSTONE_API_VERSION}
Marco Platania4abf21f2018-10-29 17:22:52 -040053 ${url} ${path}= Get Keystone Url And Path ${keystone_api_version}
Jerry Flood596db382017-10-27 08:37:37 -040054 ${openstack_identity_url}= Catenate ${url}${path}
jf986099c63292017-03-09 15:28:42 -050055 ${region}= Get Openstack Region
56 ${user} ${pass}= Get Openstack Credentials
Ah2f3b8462018-10-04 11:56:36 +053057 Run Keyword If '${keystone_api_version}'=='v2.0' Init Bridge ${openstack_identity_url} ${user} ${pass} ${tenant_id} ${region} ${GLOBAL_AAI_CLOUD_OWNER}
58 ... 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 -050059 ${request}= Bridge Data ${stack_id}
60 Log ${request}
Marco Platania4abf21f2018-10-29 17:22:52 -040061 ${resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}${MULTIPART_PATH} ${request}
DR695H11c06932017-03-03 18:12:49 -050062 ${status_string}= Convert To String ${resp.status_code}
63 Should Match Regexp ${status_string} ^(201|200)$
jf986075010a42017-02-22 16:52:54 -050064 ${reverse_heatbridge}= Generate Reverse Heatbridge From Stack Info ${stack_info}
65 Set Test Variable ${REVERSE_HEATBRIDGE} ${reverse_heatbridge}
DR695Hccff30b2017-02-17 18:44:24 -050066 Run Validation Query ${stack_info} ${service}
67
Marco Platania992832a2019-02-08 15:25:19 -080068Run Create VNFC
69 [Documentation] Create a VNFC for a vServer
70 [Arguments] ${alias} ${vserver_id} ${service}
71 ${resp}= Get Openstack Server By Id ${alias} ${vserver_id}
72 Return From Keyword If '${resp.status_code}' != '200'
73 ${info}= Set Variable ${resp.json()}
74 ${keys}= Create Dictionary
75 Set To Dictionary ${keys} vserver_name=${info['server']['name']}
76 ${vnfc_name}= Template String ${VSERVER_NAME} ${keys}
77 ${vnfc_nc}= Set Variable ${service}
78 ${vnfc_func}= Set Variable ${service}
79 Create VNFC If Not Exists ${vnfc_name} ${vnfc_nc} ${vnfc_func}
jf986075010a42017-02-22 16:52:54 -050080
DR695Hccff30b2017-02-17 18:44:24 -050081Run Validation Query
jf986099c63292017-03-09 15:28:42 -050082 [Documentation] Run A&AI query to validate the bulk add
DR695Hccff30b2017-02-17 18:44:24 -050083 [Arguments] ${stack_info} ${service}
jf986099c63292017-03-09 15:28:42 -050084 Return from Keyword If '${service}' == ''
DR695Hccff30b2017-02-17 18:44:24 -050085 ${server_name_parameter}= Get From Dictionary ${GLOBAL_VALIDATE_NAME_MAPPING} ${service}
86 ${vserver_name}= Get From Dictionary ${stack_info} ${server_name_parameter}
jf986099c63292017-03-09 15:28:42 -050087 Run Vserver Query ${vserver_name}
DR695Hccff30b2017-02-17 18:44:24 -050088
89Run Vserver Query
jf986099c63292017-03-09 15:28:42 -050090 [Documentation] Run A&AI query to validate the bulk add
DR695Hccff30b2017-02-17 18:44:24 -050091 [Arguments] ${vserver_name}
92 ${dict}= Create Dictionary vserver_name=${vserver_name}
93 ${request}= OperatingSystem.Get File ${NAMED_QUERY_TEMPLATE}
jf986099c63292017-03-09 15:28:42 -050094 ${request}= Template String ${request} ${dict}
DR695Hccff30b2017-02-17 18:44:24 -050095 ${resp}= Run A&AI Post Request ${NAMED_QUERY_PATH} ${request}
jf986099c63292017-03-09 15:28:42 -050096 Should Be Equal As Strings ${resp.status_code} 200
97
98
Marco Plataniabf2a3ee2018-07-25 15:10:09 -040099Run Set VNF Params
100 [Documentation] Run A&A GET and PUT to set prov-status, orchestration status, and ipv4-oam-address
Marco Platania4abf21f2018-10-29 17:22:52 -0400101 [Arguments] ${vnf_id} ${ipv4_vnf_address} ${prov_status}=ACTIVE ${orch_status}=Active
Brian Freeman108048b2018-05-22 13:13:05 -0500102 ${payload}= Run Get Generic VNF by VnfId ${vnf_id}
103
104 #${payload_json}= evaluate json.loads('''${payload}''') json
105 set to dictionary ${payload} prov-status ${prov_status}
Marco Plataniaf44e6432018-05-31 11:09:14 -0400106 set to dictionary ${payload} orchestration-status ${orch_status}
Marco Plataniabf2a3ee2018-07-25 15:10:09 -0400107 set to dictionary ${payload} ipv4-oam-address ${ipv4_vnf_address}
Brian Freeman108048b2018-05-22 13:13:05 -0500108 ${payload_string}= evaluate json.dumps(${payload}) json
109
110 ${put_resp}= Run A&AI Put Request ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf/${vnf_id} ${payload_string}
111 ${status_string}= Convert To String ${put_resp.status_code}
112 Should Match Regexp ${status_string} ^(200|201)$
113 Log To Console Set VNF ProvStatus: ${vnf_id} to ${prov_status}
114
115Run Get Generic VNF By VnfId
116 [Documentation] Get VNF GET Payload with resource ID
117 [Arguments] ${vnf_id}
Brian Freemana55adef2018-05-22 13:54:30 -0500118 ${resp}= Run A&AI Get Request ${VERSIONED_INDEX_PATH}/network/generic-vnfs/generic-vnf?vnf-id=${vnf_id}
Brian Freeman108048b2018-05-22 13:13:05 -0500119 Should Be Equal As Strings ${resp.status_code} 200
120 [Return] ${resp.json()}
121
DR695Hccff30b2017-02-17 18:44:24 -0500122Execute Reverse Heatbridge
jf986075010a42017-02-22 16:52:54 -0500123 [Documentation] VID has already torn down the stack, reverse HB
124 Return From Keyword If len(${REVERSE_HEATBRIDGE}) == 0
125 :for ${uri} in @{REVERSE_HEATBRIDGE}
126 \ Run Keyword And Ignore Error Delete A&AI Entity ${uri}
DR695Hccff30b2017-02-17 18:44:24 -0500127
jf986099c63292017-03-09 15:28:42 -0500128Generate Reverse Heatbridge From Stack Name
jf986075010a42017-02-22 16:52:54 -0500129 [Arguments] ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -0500130 Run Openstack Auth Request auth
jf986075010a42017-02-22 16:52:54 -0500131 ${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}
jf986099c63292017-03-09 15:28:42 -0500134
135Generate Reverse Heatbridge From Stack Info
jf986075010a42017-02-22 16:52:54 -0500136 [Arguments] ${stack_info}
137 ${reverse_heatbridge}= Create List
138 ${stack_name}= Get From Dictionary ${stack_info} name
DR695Hccff30b2017-02-17 18:44:24 -0500139 ${stack_id}= Get From Dictionary ${stack_info} id
140 ${tenant_id}= Get From Dictionary ${stack_info} OS::project_id
jf986099c63292017-03-09 15:28:42 -0500141 ${region}= Get Openstack Region
142 ${keys}= Create Dictionary region=${region} cloud=${GLOBAL_AAI_CLOUD_OWNER} tenant=${tenant_id}
DR695Hccff30b2017-02-17 18:44:24 -0500143 ${stack_resources}= Get Stack Resources auth ${stack_name} ${stack_id}
144 ${resource_list}= Get From Dictionary ${stack_resources} resources
DR695Hccff30b2017-02-17 18:44:24 -0500145 :FOR ${resource} in @{resource_list}
146 \ Log ${resource}
jf986075010a42017-02-22 16:52:54 -0500147 \ Run Keyword If '${resource['resource_type']}' == 'OS::Neutron::Port' Generate Linterface Uri auth ${resource['physical_resource_id']} ${reverse_heatbridge} ${keys}
148 :FOR ${resource} in @{resource_list}
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}
jf986099c63292017-03-09 15:28:42 -0500152
jf986075010a42017-02-22 16:52:54 -0500153Generate Vserver Uri
DR695Hccff30b2017-02-17 18:44:24 -0500154 [Documentation] Run teardown against the server to generate a message that removes it
jf986075010a42017-02-22 16:52:54 -0500155 [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'
jf986099c63292017-03-09 15:28:42 -0500158 ${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']}
jf986075010a42017-02-22 16:52:54 -0500162 ${uri}= Template String ${VSERVER_URI} ${keys}
163 Append To List ${reverse_heatbridge} ${uri}
164 ${uri}= Template String ${FLAVOR_URI} ${keys}
165 Append To List ${reverse_heatbridge} ${uri}
166 ${uri}= Template String ${IMAGE_URI} ${keys}
167 Append To List ${reverse_heatbridge} ${uri}
168
169Generate 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'
jf986099c63292017-03-09 15:28:42 -0500174 ${info}= Set Variable ${resp.json()}
jf986075010a42017-02-22 16:52:54 -0500175 Set To Dictionary ${keys} vserver_id=${info['port']['device_id']}
176 Set To Dictionary ${keys} linterface_id=${info['port']['name']}
177 ${uri}= Template String ${L_INTERFACE_URI} ${keys}
178 Append To List ${reverse_heatbridge} ${uri}
jf986099c63292017-03-09 15:28:42 -0500179