replace aai, closeloop, sdc with jinja
[testsuite.git] / robot / resources / asdc_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with ASDC. It handles low level stuff like managing the http request library and DCAE required fields
3 Library           RequestsLibrary
4 Library           ONAPLibrary.Utilities
5 Library           ONAPLibrary.JSON
6 Library           OperatingSystem
7 Library           Collections
8 Library           SeleniumLibrary
9 Library           String
10 Library           StringTemplater
11 Library           ArchiveLibrary
12 Library           ONAPLibrary.Openstack
13 Library           DateTime
14 Library           ONAPLibrary.ServiceMapping
15 Library           ONAPLibrary.Templating
16 Resource          global_properties.robot
17 Resource          browser_setup.robot
18
19 *** Variables ***
20 ${ASDC_DESIGNER_USER_ID}    cs0008
21 ${ASDC_TESTER_USER_ID}    jm0007
22 ${ASDC_GOVERNOR_USER_ID}    gv0001
23 ${ASDC_OPS_USER_ID}    op0001
24 ${ASDC_HEALTH_CHECK_PATH}    /sdc1/rest/healthCheck
25 ${ASDC_VENDOR_LICENSE_MODEL_PATH}    /onboarding-api/v1.0/vendor-license-models
26 ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}    /onboarding-api/v1.0/vendor-software-products
27 ${ASDC_VENDOR_KEY_GROUP_PATH}    /license-key-groups
28 ${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}    /entitlement-pools
29 ${ASDC_VENDOR_FEATURE_GROUP_PATH}    /feature-groups
30 ${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}    /license-agreements
31 ${ASDC_VENDOR_ACTIONS_PATH}    /actions
32 ${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}    /orchestration-template-candidate
33 ${ASDC_FE_CATALOG_RESOURCES_PATH}    /sdc1/feProxy/rest/v1/catalog/resources
34 ${ASDC_FE_CATALOG_SERVICES_PATH}    /sdc1/feProxy/rest/v1/catalog/services
35 ${ASDC_CATALOG_RESOURCES_PATH}    /sdc2/rest/v1/catalog/resources
36 ${ASDC_CATALOG_SERVICES_PATH}    /sdc2/rest/v1/catalog/services
37 ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}    /sdc2/rest/v1/inactiveComponents/resource
38 ${ASDC_CATALOG_RESOURCES_QUERY_PATH}    /sdc2/rest/v1/catalog/resources/resourceName
39 ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}    /sdc2/rest/v1/inactiveComponents/service
40 ${ASDC_CATALOG_LIFECYCLE_PATH}    /lifecycleState
41 ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}    /resourceInstance
42 ${ASDC_CATALOG_SERVICE_RESOURCE_ARTIFACT_PATH}    /artifacts
43 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}    /distribution-state
44 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    /distribution
45 ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    /approve
46 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    /distribution/PROD/activate
47 ${ASDC_LICENSE_MODEL_TEMPLATE}    asdc/license_model.jinja
48 ${ASDC_KEY_GROUP_TEMPLATE}    asdc/key_group.jinja
49 ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    asdc/entitlement_pool.jinja
50 ${ASDC_FEATURE_GROUP_TEMPLATE}    asdc/feature_group.jinja
51 ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    asdc/license_agreement.jinja
52 ${ASDC_ACTION_TEMPLATE}    asdc/action.jinja
53 ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    asdc/software_product.jinja
54 ${ASDC_ARTIFACT_UPLOAD_TEMPLATE}    asdc/artifact_upload.jinja
55 ${ASDC_CATALOG_RESOURCE_TEMPLATE}    asdc/catalog_resource.jinja
56 ${ASDC_USER_REMARKS_TEMPLATE}    asdc/user_remarks.jinja
57 ${ASDC_CATALOG_SERVICE_TEMPLATE}    asdc/catalog_service.jinja
58 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    asdc/resource_instance.jinja
59 ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    asdc/catalog_vnf_properties.jinja
60 ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    asdc/catalog_vnf_inputs.jinja
61 ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    asdc/catalog_net_input_properties.jinja
62 ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    asdc/catalog_resource_alloted_resource.jinja
63 ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    asdc/catalog_allotted_properties.jinja
64 ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    asdc/catalog_allotted_inputs.jinja
65 ${SDC_CATALOG_DEPLOYMENT_ARTIFACT_PATH}     robot/assets/asdc/blueprints/
66 ${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_FE_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
67 ${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
68 ${ASDC_BE_ONBOARD_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_ONBOARD_IP_ADDR}:${GLOBAL_ASDC_BE_ONBOARD_PORT}
69
70 *** Keywords ***
71 Distribute Model From ASDC
72     [Documentation]    Goes end to end creating all the ASDC objects based ONAP model and distributing it to the systems. It then returns the service name, VF name and VF module name
73     [Arguments]    ${model_zip_path}   ${catalog_service_name}=    ${cds}=    ${service}=
74     # For Testing use random service names
75     #${random}=    Get Current Date
76     #${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}_${random}
77     ${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
78     ${catalog_resource_ids}=    Create List
79     ${catalog_resources}=   Create Dictionary
80     #####  TODO: Support for Multiple resources of one type in a service  ######
81     #   The zip list is the resources - no mechanism to indicate more than 1 of the items in the zip list
82     #   Get Service Vnf Mapping  has the logical mapping but it is not the same key as model_zip_path
83     #   ${vnflist}=   Get Service Vnf Mapping    alias    ${service}
84     #   Save the resource_id in a dictionary keyed by the resource name in the zipfile name (vFWDT_vFWSNK.zip or vFWDT_vPKG.zip)
85     #   Create the resources but do not immediately add resource
86     #   Add Resource to Service in a separate FOR loop
87     ${resource_types}=   Create Dictionary
88
89     :FOR    ${zip}     IN     @{model_zip_path}
90     \    ${loop_catalog_resource_id}=    Setup ASDC Catalog Resource    ${zip}    ${cds}
91     #     zip can be vFW.zip or vFWDT_VFWSNK.zip
92     \    ${resource_type_match}=    Get Regexp Matches    ${zip}   ${service}_(.*)\.zip    1
93     #  Need to be able to distribute preload for vFWCL vFWSNK and vFWDT vFWSNK to prepend service to vnf_type
94     \    ${resource_type_string}=   Set Variable If   len(${resource_type_match})==0    ${service}    ${service}${resource_type_match[0]}
95     \    Set To Dictionary    ${resource_types}    ${resource_type_string}    ${loop_catalog_resource_id}   
96     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
97
98     Set Directory    default    ./demo/service_mapping
99     ${vnflist}=    Get Service Vnf Mapping    default    ${service}
100
101     # Spread the icons on the pallette starting on the left
102     ${xoffset}=    Set Variable    ${0}
103
104     :FOR  ${vnf}   IN   @{vnflist}
105     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource      ${resource_types['${vnf}']}
106     \    Set To Dictionary    ${catalog_resources}   ${resource_types['${vnf}']}=${loop_catalog_resource_resp}
107     \    ${catalog_resource_unique_name}=   Add ASDC Resource Instance    ${catalog_service_id}    ${resource_types['${vnf}']}    ${loop_catalog_resource_resp['name']}    ${xoffset}
108     \    ${xoffset}=   Set Variable   ${xoffset+100}
109     #
110     # do this here because the loop_catalog_resource_resp is different format after adding networks
111     ${vf_module}=   Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
112     #
113     #  do network
114     ${networklist}=    Get Service Neutron Mapping    default    ${service}
115     ${generic_neutron_net_uuid}=   Get Generic NeutronNet UUID
116     :FOR   ${network}   IN   @{networklist}
117     \    ${loop_catalog_resource_id}=   Set Variable    ${generic_neutron_net_uuid}
118     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
119     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
120     \    ${loop_catalog_resource_id}=   Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${network}    ${xoffset}      ${0}    VL
121     \    ${nf_role}=   Convert To Lowercase   ${network}
122     \    Setup SDC Catalog Resource GenericNeutronNet Properties      ${catalog_service_id}    ${nf_role}   ${loop_catalog_resource_id}
123     \    ${xoffset}=   Set Variable   ${xoffset+100}
124     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
125     ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
126     #
127     # do deployment artifacts
128     #
129     ${deploymentlist}=    Get Service Deployment Artifact Mapping    default    ${service}
130     :FOR  ${deployment}  IN   @{deploymentlist}
131     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
132     \    Setup SDC Catalog Resource Deployment Artifact Properties      ${catalog_service_id}   ${loop_catalog_resource_resp}  ${catalog_resource_unique_name}  ${deployment}
133     Checkin ASDC Catalog Service    ${catalog_service_id}
134     Request Certify ASDC Catalog Service    ${catalog_service_id}
135     Start Certify ASDC Catalog Service    ${catalog_service_id}
136     # on certify it gets a new id
137     ${catalog_service_id}=    Certify ASDC Catalog Service    ${catalog_service_id}
138     Approve ASDC Catalog Service    ${catalog_service_id}
139         :FOR   ${DIST_INDEX}    IN RANGE   1
140         \   Log     Distribution Attempt ${DIST_INDEX}
141         \   Distribute ASDC Catalog Service    ${catalog_service_id}
142         \   ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
143         \   ${status}   ${_} =   Run Keyword And Ignore Error   Loop Over Check Catalog Service Distributed       ${catalog_service_resp['uuid']}
144         \   Exit For Loop If   '${status}'=='PASS'
145         Should Be Equal As Strings  ${status}  PASS
146     [Return]    ${catalog_service_resp['name']}    ${loop_catalog_resource_resp['name']}    ${vf_module}   ${catalog_resource_ids}    ${catalog_service_id}   ${catalog_resources}
147
148 Distribute vCPEResCust Model From ASDC
149     [Documentation]    Goes end to end creating all the ASDC objects for the vCPE ResCust Service model and distributing it to the systems. It then returns the service name, VF name and VF module name
150     [Arguments]    ${model_zip_path}   ${catalog_service_name}=    ${cds}=    ${service}=
151     # For testing use random service name
152     #${random}=    Get Current Date
153     ${uuid}=    Generate UUID4
154     ${random}=     Evaluate    str("${uuid}")[:4]
155     ${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}_${random}
156     #   catalog_service_name already
157     #${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
158     Log To Console    ${\n}ServiceName: ${catalog_service_name}_${random}
159     #${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
160     ${catalog_resource_ids}=    Create List
161     ${catalog_resources}=   Create Dictionary
162     :FOR    ${zip}     IN     @{model_zip_path}
163     \    ${loop_catalog_resource_id}=    Setup ASDC Catalog Resource    ${zip}    ${cds}
164     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
165     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
166     \    Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${loop_catalog_resource_resp['name']}
167     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
168     #
169     # do this here because the loop_catalog_resource_resp is different format after adding networks
170     ${vf_module}=   Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
171     #
172     #  do allottedresource
173     ${allottedresource_list}=   Create List    TunnelXConn     BRG
174     #  Example data
175     #${tunnelxconn_dict}=   Create Dictionary      invariantUUID=8ac029e7-77aa-40d4-b28a-d17c02d5fd82    UUID=2ddc1b37-d7da-4aab-b645-ed7db34a5d03    node_type=org.openecomp.service.Demovcpevgmux
176     #${brg_dict}=   Create Dictionary      invariantUUID=ff0337b9-dbe2-4d88-bb74-18bf027ae586   UUID=1b6974f1-4aed-47f4-b962-816aa1261927    node_type=org.openecomp.service.Demovcpevbrgemu
177     # Create /tmp/vcpe_allotted_resource_data.json with demo vgmux and brgemu CSARs
178     Create Allotted Resource Data File
179     ${vcpe_ar_data_file}    OperatingSystem.Get File    /tmp/vcpe_allotted_resource_data.json
180     ${tunnelxconn_invariant_uuid}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['invariantUUID']}
181     ${tunnelxconn_uuid}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['UUID']}
182     ${tunnelxconn_node_type}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['node_type']}
183     ${brg_invariant_uuid}=    Catenate    ${vcpe_ar_data_file.json()['brg']['invariantUUID']}
184     ${brg_uuid}=    Catenate    ${vcpe_ar_data_file.json()['brg']['UUID']}
185     ${brg_node_type}=    Catenate    ${vcpe_ar_data_file.json()['brg']['node_type']}
186     ${tunnelxconn_dict}=   Create Dictionary      invariantUUID=${tunnelxconn_invariant_uuid}  UUID=${tunnelxconn_uuid}  node_type=${tunnelxconn_node_type}
187     ${brg_dict}=   Create Dictionary      invariantUUID=${brg_invariant_uuid}   UUID=${brg_uuid}  node_type=${brg_node_type}
188     ${xoffset}=    Set Variable    ${100}
189     ${allottedresource_uuid}=   Get AllottedResource UUID
190     ${random}=    Get Current Date
191     :FOR   ${allottedresource}   IN   @{allottedresource_list}
192     \    ${loop_catalog_resource_id}=   Set Variable    ${allottedresource_uuid}
193     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
194     \    ${loop_catalog_resource_id}=    Add ASDC Allotted Resource Catalog Resource     00000    ${allottedresource}_${random}    ONAP     ${loop_catalog_resource_id}   ${allottedresource}
195     \    ${loop_catalog_resource_id2}=   Add ASDC Resource Instance To Resource     ${loop_catalog_resource_id}    ${allottedresource_uuid}    ${allottedresource}    ${xoffset}      ${0}
196     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
197     #
198     #   Set the properties to relate to the brg and gmux
199     #
200     \    Run Keyword If   '${allottedresource}'=='TunnelXConn'    Setup SDC Catalog Resource AllottedResource Properties      ${catalog_service_id}    ${allottedresource}   ${loop_catalog_resource_id}   ${tunnelxconn_dict['invariantUUID']}   ${tunnelxconn_dict['UUID']}   ${tunnelxconn_dict['node_type']}
201     \    Run Keyword If   '${allottedresource}'=='BRG'   Setup SDC Catalog Resource AllottedResource Properties      ${catalog_service_id}    ${allottedresource}   ${loop_catalog_resource_id}   ${brg_dict['invariantUUID']}   ${brg_dict['UUID']}   ${brg_dict['node_type']}
202     #
203     #    Set the nf_role nf_type
204     #
205     \    Run Keyword If   '${allottedresource}'=='TunnelXConn'    Setup SDC Catalog Resource AllottedResource Inputs  ${catalog_service_id}    ${allottedresource}   ${loop_catalog_resource_id}
206     \    Run Keyword If   '${allottedresource}'=='BRG'    Setup SDC Catalog Resource AllottedResource Inputs  ${catalog_service_id}    ${allottedresource}   ${loop_catalog_resource_id}
207     \    ${loop_catalog_resource_id}=   Certify ASDC Catalog Resource    ${loop_catalog_resource_id}  ${ASDC_DESIGNER_USER_ID}
208     \    Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${loop_catalog_resource_resp['name']}
209     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
210     ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
211     Checkin ASDC Catalog Service    ${catalog_service_id}
212     Request Certify ASDC Catalog Service    ${catalog_service_id}
213     Start Certify ASDC Catalog Service    ${catalog_service_id}
214     # on certify it gets a new id
215     ${catalog_service_id}=    Certify ASDC Catalog Service    ${catalog_service_id}
216     Approve ASDC Catalog Service    ${catalog_service_id}
217         :FOR   ${DIST_INDEX}    IN RANGE   1
218         \   Log     Distribution Attempt ${DIST_INDEX}
219         \   Distribute ASDC Catalog Service    ${catalog_service_id}
220         \   ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
221         \   ${status}   ${_} =   Run Keyword And Ignore Error   Loop Over Check Catalog Service Distributed       ${catalog_service_resp['uuid']}
222         \   Exit For Loop If   '${status}'=='PASS'
223         Should Be Equal As Strings  ${status}  PASS
224     [Return]    ${catalog_service_resp['name']}    ${loop_catalog_resource_resp['name']}    ${vf_module}   ${catalog_resource_ids}    ${catalog_service_id}   ${catalog_resources}
225
226
227 Create Allotted Resource Data File
228    [Documentation]    Create Allotted Resource json data file
229    ${allotted_resource}=    Create Dictionary
230    ${allotted_csar_map}=    Create Dictionary
231    Set To Dictionary    ${allotted_csar_map}    tunnelxconn=service-Demovcpevgmux-csar.csar
232    Set To Dictionary    ${allotted_csar_map}    brg=service-Demovcpevbrgemu-csar.csar
233    ${keys}=    Get Dictionary Keys    ${allotted_csar_map}
234    :FOR   ${key}   IN   @{keys}
235    \    ${csar}=    Get From Dictionary    ${allotted_csar_map}    ${key}
236    \    ${dir}    ${ext}=    Split String From Right    ${csar}    -    1
237    \    Extract Zip File    /tmp/csar/${csar}    /tmp/csar/${dir}
238    \    ${template}=    Catenate    /tmp/csar/${dir}/Definitions/${dir}-template.yml
239    \    ${json_str}=    Template Yaml To Json    ${template}
240    \    ${json_obj}=    To Json   ${json_str}
241    \    ${attrs}=    Create Dictionary
242    \    Set To Dictionary    ${attrs}    invariantUUID=${json_obj['metadata']['invariantUUID']}
243    \    Set To Dictionary    ${attrs}    UUID=${json_obj['metadata']['UUID']}
244    \    Set To Dictionary    ${attrs}    node_type=${json_obj['topology_template']['substitution_mappings']['node_type']}
245    \    Set To Dictionary    ${allotted_resource}    ${key}=${attrs}
246    ${result_str}=   Evaluate    json.dumps(${allotted_resource}, indent=2)    json
247    Log To Console    ${result_str}
248    Create File    /tmp/vcpe_allotted_resource_data.json    ${result_str}
249
250 Download CSAR
251    [Documentation]   Download CSAR
252    [Arguments]    ${catalog_service_id}    ${save_directory}=/tmp/csar
253    # get meta data
254    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/filteredDataByParams?include=toscaArtifacts    ${ASDC_DESIGNER_USER_ID}    ${ASDC_BE_ENDPOINT}
255    ${csar_resource_id}=    Set Variable   ${resp.json()['toscaArtifacts']['assettoscacsar']['uniqueId']}
256    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/artifacts/${csar_resource_id}
257    ${csar_file_name}=   Set Variable    ${resp.json()['artifactName']}
258    ${base64Obj}=   Set Variable    ${resp.json()['base64Contents']}
259    ${binObj}=   Evaluate   base64.b64decode("${base64Obj}")   modules=base64
260    Create Binary File  ${save_directory}/${csar_file_name}  ${binObj}
261    Log To Console      ${\n}Downloaded:${csar_file_name}
262
263
264 Get Generic NeutronNet UUID
265    [Documentation]   Look up the UUID of the Generic NeutronNetwork Resource
266    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_QUERY_PATH}/Generic%20NeutronNet/resourceVersion/1.0   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ENDPOINT}
267    [Return]    ${resp.json()['allVersions']['1.0']}
268
269 Get AllottedResource UUID
270    [Documentation]   Look up the UUID of the Allotted Resource
271    # if this fails then the AllottedResource template got deleted from SDC by mistake
272    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_QUERY_PATH}/AllottedResource/resourceVersion/1.0   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ENDPOINT}
273    [Return]    ${resp.json()['allVersions']['1.0']}
274
275 Loop Over Check Catalog Service Distributed
276     [Arguments]    ${catalog_service_id}
277     # SO watchdog timeout is 300 seconds need buffer
278     ${dist_status}=   Set Variable    CONTINUE
279     :FOR  ${CHECK_INDEX}  IN RANGE   20
280     \   ${status}   ${_} =   Run Keyword And Ignore Error     Check Catalog Service Distributed    ${catalog_service_id}    ${dist_status}
281     \   Sleep     20s
282     \   Return From Keyword If   '${status}'=='PASS'
283     # need a way to exit the loop early on DISTRIBUTION_COMPLETE_ERROR  ${dist_status} doesnt work
284     #\   Exit For Loop If   '${dist_status}'=='EXIT'
285     Should Be Equal As Strings  ${status}   PASS
286
287 Setup ASDC Catalog Resource
288     [Documentation]    Creates all the steps a VF needs for an ASDC Catalog Resource and returns the id
289     [Arguments]    ${model_zip_path}    ${cds}=
290     ${license_model_id}   ${license_model_version_id}=    Add ASDC License Model
291
292
293     ${license_temp_date}=   Get Current Date
294     ${license_start_date}=   Get Current Date     result_format=%m/%d/%Y
295     ${license_end_date}=     Add Time To Date   ${license_temp_date}    365 days    result_format=%m/%d/%Y
296     ${key_group_id}=    Add ASDC License Group    ${license_model_id}   ${license_model_version_id}  ${license_start_date}  ${license_end_date}
297     ${pool_id}=    Add ASDC Entitlement Pool    ${license_model_id}   ${license_model_version_id}  ${license_start_date}  ${license_end_date}
298
299     ${feature_group_id}=    Add ASDC Feature Group    ${license_model_id}    ${key_group_id}    ${pool_id}  ${license_model_version_id}
300     ${license_agreement_id}=    Add ASDC License Agreement    ${license_model_id}    ${feature_group_id}   ${license_model_version_id}
301     Submit ASDC License Model    ${license_model_id}   ${license_model_version_id}
302     ${license_model_resp}=    Get ASDC License Model    ${license_model_id}   ${license_model_version_id}
303     ${matches}=   Get Regexp Matches  ${model_zip_path}  temp/(.*)\.zip  1
304     ${software_product_name_prefix}=    Set Variable   ${matches[0]}
305     ${software_product_id}   ${software_product_version_id}=    Add ASDC Software Product    ${license_agreement_id}    ${feature_group_id}    ${license_model_resp['vendorName']}    ${license_model_id}    ${license_model_version_id}    ${software_product_name_prefix}
306     Upload ASDC Heat Package    ${software_product_id}    ${model_zip_path}   ${software_product_version_id}
307     Validate ASDC Software Product    ${software_product_id}  ${software_product_version_id}
308     Submit ASDC Software Product    ${software_product_id}  ${software_product_version_id}
309     Package ASDC Software Product    ${software_product_id}   ${software_product_version_id}
310     ${software_product_resp}=    Get ASDC Software Product    ${software_product_id}    ${software_product_version_id}
311     ${catalog_resource_id}=    Add ASDC Catalog Resource     ${license_agreement_id}    ${software_product_resp['name']}    ${license_model_resp['vendorName']}    ${software_product_id}
312     # Check if need to set up CDS properties
313     Run Keyword If    '${cds}' == 'vfwng'    Setup ASDC Catalog Resource CDS Properties    ${catalog_resource_id}
314
315     ${catalog_resource_id}=   Certify ASDC Catalog Resource    ${catalog_resource_id}  ${ASDC_DESIGNER_USER_ID}
316     [Return]    ${catalog_resource_id}
317
318
319 Setup SDC Catalog Resource Deployment Artifact Properties
320     [Documentation]    Set up Deployment Artiface properties
321     [Arguments]    ${catalog_service_id}    ${catalog_parent_service_id}   ${catalog_resource_unique_id}  ${blueprint_file}
322     ${resp}=    Get ASDC Catalog Resource Component Instances Properties  ${catalog_service_id}
323     ${blueprint_data}    OperatingSystem.Get File    ${SDC_CATALOG_DEPLOYMENT_ARTIFACT_PATH}${blueprint_file}
324     ${payloadData}=   Evaluate   base64.b64encode('''${blueprint_data}'''.encode('utf-8'))   modules=base64
325     ${dict}=    Create Dictionary  artifactLabel=blueprint  artifactName=${blueprint_file}   artifactType=DCAE_INVENTORY_BLUEPRINT  artifactGroupType=DEPLOYMENT  description=${blueprint_file}   payloadData=${payloadData}
326     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
327     ${data}=   Apply Template    sdc   ${ASDC_ARTIFACT_UPLOAD_TEMPLATE}    ${dict}
328     # POST artifactUpload to resource
329     ${artifact_upload_path}=    Catenate  ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/resourceInstance/${catalog_resource_unique_id}${ASDC_CATALOG_SERVICE_RESOURCE_ARTIFACT_PATH}
330     ${resp}=    Run ASDC MD5 Post Request    ${artifact_upload_path}    ${data}   ${ASDC_DESIGNER_USER_ID}
331     Should Be Equal As Strings  ${resp.status_code}     200
332     [Return]    ${resp}
333
334
335 Setup SDC Catalog Resource GenericNeutronNet Properties
336     [Documentation]    Set up GenericNeutronNet properties and inputs
337     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_parent_service_id}
338     ${resp}=    Get ASDC Catalog Resource Component Instances Properties  ${catalog_service_id}
339     ${componentInstances}  Set Variable   @{resp['componentInstancesProperties']}
340     # componentInstances can have 1 or more than 1 entry
341     ${passed}=    Run Keyword And Return Status   Evaluate    type(${componentInstances})
342     ${type}=      Run Keyword If     ${passed}    Evaluate    type(${componentInstances})
343     ${componentInstancesList}=    Run Keyword If   "${type}"!="<type 'list'>"    Create List  ${componentInstances}
344     ...    ELSE   Set Variable    ${componentInstances}
345     :FOR   ${item}  IN   @{componentInstancesList}
346     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${item}     ${nf_role}
347     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
348     \    ${componentInstance1}=   Set Variable    ${item}
349     :FOR    ${comp}    IN    @{resp['componentInstancesProperties']["${componentInstance1}"]}
350     \    ${name}    Set Variable   ${comp['name']}
351     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    network_role
352     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
353     \    ${description}    Set Variable    ${comp['description']}
354     \    ${description}=    Replace String    ${description}    ${\n}   \
355     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
356     \    ${parentUniqueId}    Set Variable    ${comp['parentUniqueId']}
357     \    ${ownerId}    Set Variable    ${comp['ownerId']}
358     \    ${dict}=    Create Dictionary    parentUniqueId=${parentUniqueId}   ownerId=${ownerId}  uniqueId=${uniqueId}    description=${description}
359     \    Run Keyword If   '${name}'=='network_role'   Set To Dictionary    ${dict}    name=${name}    value=${nf_role}
360     \    Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
361     \    ${data}=   Apply Template    sdc   ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    ${dict}
362     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_parent_service_id}    ${catalog_service_id}    ${data}
363
364
365 Setup SDC Catalog Resource AllottedResource Properties
366     [Documentation]    Set up Allotted Resource properties and inputs
367     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}   ${invariantUUID}   ${UUID}     ${node_type}
368     # Set component instances properties
369     ${nf_role_lc}=   Convert To Lowercase   ${nf_role}
370     ${resp}=    Get ASDC Catalog Resource Component Instances Properties For Resource     ${catalog_resource_id}
371     ${componentInstances}  Set Variable   @{resp['componentInstancesProperties']}
372     # componentInstances can have 1 or more than 1 entry
373     ${passed}=    Run Keyword And Return Status   Evaluate    type(${componentInstances})
374     ${type}=      Run Keyword If     ${passed}    Evaluate    type(${componentInstances})
375     ${componentInstancesList}=    Run Keyword If   "${type}"!="<type 'list'>"    Create List  ${componentInstances}
376     ...    ELSE   Set Variable    ${componentInstances}
377     :FOR   ${item}  IN   @{componentInstancesList}
378     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${item}     ${nf_role_lc}
379     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
380     \    ${componentInstance1}=   Set Variable    ${item}
381     ${dict}=    Create Dictionary
382     :FOR    ${comp}    IN    @{resp['componentInstancesProperties']["${componentInstance1}"]}
383     \    ${name}    Set Variable   ${comp['name']}
384     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain Any     ${name}    network_role  providing_service_invariant_uuid  providing_service_uuid  providing_service_name   uniqueId
385     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
386     \    ${parentUniqueId}    Set Variable    ${comp['parentUniqueId']}
387     \    ${ownerId}    Set Variable    ${comp['ownerId']}
388     \    Set To Dictionary     ${dict}    parentUniqueId=${parentUniqueId}   ownerId=${ownerId}
389     \    Run Keyword If   '${name}'=='providing_service_invariant_uuid'   Set To Dictionary    ${dict}    providing_service_invariant_uuid=${invariantUUID}
390     \    Run Keyword If   '${name}'=='providing_service_uuid'   Set To Dictionary    ${dict}    providing_service_uuid=${UUID}
391     \    Run Keyword If   '${name}'=='providing_service_name'   Set To Dictionary    ${dict}    providing_service_name=${node_type}
392     #    Sets it for each loop but should be one
393     \    ${uniqueId}    Set Variable     ${comp['uniqueId']}
394     \    ${uniqueId}   Fetch From Left   ${uniqueId}   .
395     \    Set To Dictionary    ${dict}    uniqueId=${uniqueId}
396     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
397     ${data}=   Apply Template    sdc   ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    ${dict}
398     ${response}=    Set ASDC Catalog Resource Component Instance Properties For Resource    ${catalog_resource_id}    ${componentInstance1}    ${data}
399     Log To Console    resp=${response}
400
401
402 Setup SDC Catalog Resource AllottedResource Inputs
403     [Documentation]    Set up Allotted Resource inputs
404     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}
405     # Set vnf inputs
406     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
407     ${dict}=    Create Dictionary
408     :FOR    ${comp}    IN    @{resp['inputs']}
409     \    ${name}    Set Variable    ${comp['name']}
410     \    ${uid}    Set Variable    ${comp['uniqueId']}
411     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=${nf_role}    nf_type_uid=${uid}
412     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=${nf_role}   nf_role_uid=${uid}
413     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
414     ${data}=   Apply Template    sdc   ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    ${dict}
415     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
416     [Return]    ${response}
417
418 Setup ASDC Catalog Resource CDS Properties
419     [Documentation]    Set up vfwng VNF properties and inputs for CDS
420     [Arguments]    ${catalog_resource_id}
421     # Set vnf module properties
422     ${resp}=    Get ASDC Catalog Resource Component Instances   ${catalog_resource_id}
423     :FOR    ${comp}    IN    @{resp['componentInstances']}
424     \    ${name}    Set Variable   ${comp['name']}
425     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
426     \    ${actualComponentUid}    Set Variable    ${comp['actualComponentUid']}
427     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    abstract_
428     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
429     \    ${response}=    Get ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${actualComponentUid}
430     \    ${dict}=    Create Dictionary    parent_id=${response[6]['parentUniqueId']}
431     \    Run Keyword If   '${name}'=='abstract_vfw'   Set To Dictionary    ${dict}    nfc_function=vfw    nfc_naming_policy=SDNC_Policy.ONAP_VFW_NAMING_TIMESTAMP
432     \    Run Keyword If   '${name}'=='abstract_vpg'   Set To Dictionary    ${dict}    nfc_function=vpg    nfc_naming_policy=SDNC_Policy.ONAP_VPG_NAMING_TIMESTAMP
433     \    Run Keyword If   '${name}'=='abstract_vsn'   Set To Dictionary    ${dict}    nfc_function=vsn    nfc_naming_policy=SDNC_Policy.ONAP_VSN_NAMING_TIMESTAMP
434     \    Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
435     \    ${data}=   Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    ${dict}
436     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${data}
437     \    Log To Console    resp=${response}
438
439     # Set vnf inputs
440     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
441     ${dict}=    Create Dictionary
442     :FOR    ${comp}    IN    @{resp['inputs']}
443     \    ${name}    Set Variable    ${comp['name']}
444     \    ${uid}    Set Variable    ${comp['uniqueId']}
445     \    Run Keyword If    '${name}'=='nf_function'    Set To Dictionary    ${dict}    nf_function=ONAP-FIREWALL    nf_function_uid=${uid}
446     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=FIREWALL    nf_type_uid=${uid}
447     \    Run Keyword If    '${name}'=='nf_naming_code'    Set To Dictionary    ${dict}    nf_naming_code=vfw    nf_naming_code_uid=${uid}
448     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=vFW    nf_role_uid=${uid}
449     \    Run Keyword If    '${name}'=='cloud_env'    Set To Dictionary    ${dict}    cloud_env=openstack    cloud_env_uid=${uid}
450     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
451     ${data}=   Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    ${dict}
452     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
453
454 Add ASDC License Model
455     [Documentation]    Creates an ASDC License Model and returns its id
456     ${uuid}=    Generate UUID4
457     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
458     ${map}=    Create Dictionary    vendor_name=${shortened_uuid}
459     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
460     ${data}=   Apply Template    sdc   ${ASDC_LICENSE_MODEL_TEMPLATE}    ${map}
461     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
462     Should Be Equal As Strings  ${resp.status_code}     200
463     [Return]    ${resp.json()['itemId']}    ${resp.json()['version']['id']}
464 Get ASDC License Model
465     [Documentation]    gets an asdc license model by its id
466     [Arguments]    ${id}   ${version_id}=0.1
467     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
468     [Return]    ${resp.json()}
469
470 Get ASDC License Models
471     [Documentation]    Gets all ASDC License Models
472     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
473     [Return]    ${resp.json()}
474
475 Checkin ASDC License Model
476     [Documentation]    Checks in an ASDC License Model by its id
477     [Arguments]    ${id}   ${version_id}=0.1
478     ${map}=    Create Dictionary    action=Checkin
479     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
480     ${data}=   Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
481     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
482     Should Be Equal As Strings  ${resp.status_code}     200
483     [Return]    ${resp.json()}
484
485 Submit ASDC License Model
486     [Documentation]    Submits an ASDC License Model by its id
487     [Arguments]    ${id}   ${version_id}=0.1
488     ${map}=    Create Dictionary    action=Submit
489     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
490     ${data}=   Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
491     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
492     Should Be Equal As Strings  ${resp.status_code}     200
493     [Return]    ${resp.json()}
494
495 Checkin ASDC Software Product
496     [Documentation]    Checks in an ASDC Software Product by its id
497     [Arguments]    ${id}   ${version_id}=0.1
498     ${map}=    Create Dictionary    action=Checkin
499     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
500     ${data}=   Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
501     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
502     Should Be Equal As Strings  ${resp.status_code}     200
503     [Return]    ${resp.json()}
504
505 Validate ASDC Software Product
506     [Documentation]    Validates an ASDC Software Product by its id
507     [Arguments]    ${id}   ${version_id}=0.1
508     ${data}=   Catenate
509     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}/orchestration-template-candidate/process    ${data}    ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
510     Should Be Equal As Strings  ${resp.status_code}     200
511     [Return]    ${resp.json()}
512
513 Submit ASDC Software Product
514     [Documentation]    Submits an ASDC Software Product by its id
515     [Arguments]    ${id}   ${version_id}=0.1
516     ${map}=    Create Dictionary    action=Submit
517     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
518     ${data}=   Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
519     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
520     Should Be Equal As Strings  ${resp.status_code}     200
521     [Return]    ${resp.json()}
522
523 Package ASDC Software Product
524     [Documentation]    Creates a package of an ASDC Software Product by its id
525     [Arguments]    ${id}   ${version_id}=0.1
526     ${map}=    Create Dictionary    action=Create_Package
527     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
528     ${data}=   Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
529     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
530     Should Be Equal As Strings  ${resp.status_code}     200
531     [Return]    ${resp.json()}
532
533 Add ASDC Entitlement Pool
534     [Documentation]    Creates an ASDC Entitlement Pool and returns its id
535     [Arguments]    ${license_model_id}   ${version_id}=0.1     ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
536     ${uuid}=    Generate UUID4
537     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
538     ${map}=    Create Dictionary    entitlement_pool_name=${shortened_uuid}  license_start_date=${license_start_date}  license_end_date=${license_end_date}
539     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
540     ${data}=   Apply Template    sdc   ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    ${map}
541     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}     ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
542     Should Be Equal As Strings  ${resp.status_code}     200
543     [Return]    ${resp.json()['value']}
544
545 Get ASDC Entitlement Pool
546     [Documentation]    Gets an ASDC Entitlement Pool by its id
547     [Arguments]    ${license_model_id}    ${pool_id}
548     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}/${pool_id}  ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
549     [Return]    ${resp.json()}
550
551 Add ASDC License Group
552     [Documentation]    Creates an ASDC License Group and returns its id
553     [Arguments]    ${license_model_id}   ${version_id}=1.0   ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
554     ${uuid}=    Generate UUID4
555     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
556     ${map}=    Create Dictionary    key_group_name=${shortened_uuid}   license_start_date=${license_start_date}  license_end_date=${license_end_date}
557     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
558     ${data}=   Apply Template    sdc   ${ASDC_KEY_GROUP_TEMPLATE}    ${map}
559     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}     ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
560     Should Be Equal As Strings  ${resp.status_code}     200
561     [Return]    ${resp.json()['value']}
562
563 Get ASDC License Group
564     [Documentation]    Gets an ASDC License Group by its id
565     [Arguments]    ${license_model_id}    ${group_id}      ${version_id}
566     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
567     [Return]    ${resp.json()}
568
569 Add ASDC Feature Group
570     [Documentation]    Creates an ASDC Feature Group and returns its id
571     [Arguments]    ${license_model_id}    ${key_group_id}    ${entitlement_pool_id}      ${version_id}=0.1
572     ${uuid}=    Generate UUID4
573     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
574     ${map}=    Create Dictionary    feature_group_name=${shortened_uuid}    key_group_id=${key_group_id}    entitlement_pool_id=${entitlement_pool_id}   manufacturer_reference_number=mrn${shortened_uuid}
575     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
576     ${data}=   Apply Template    sdc   ${ASDC_FEATURE_GROUP_TEMPLATE}    ${map}
577     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
578     Should Be Equal As Strings  ${resp.status_code}     200
579     [Return]    ${resp.json()['value']}
580
581 Get ASDC Feature Group
582     [Documentation]    Gets an ASDC Feature Group by its id
583     [Arguments]    ${license_model_id}    ${group_id}
584     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
585     [Return]    ${resp.json()}
586
587 Add ASDC License Agreement
588     [Documentation]    Creates an ASDC License Agreement and returns its id
589     [Arguments]    ${license_model_id}    ${feature_group_id}      ${version_id}=0.1
590     ${uuid}=    Generate UUID4
591     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
592     ${map}=    Create Dictionary    license_agreement_name=${shortened_uuid}    feature_group_id=${feature_group_id}
593     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
594     ${data}=   Apply Template    sdc   ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    ${map}
595     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
596     Should Be Equal As Strings  ${resp.status_code}     200
597     [Return]    ${resp.json()['value']}
598
599 Get ASDC License Agreement
600     [Documentation]    Gets an ASDC License Agreement by its id
601     [Arguments]    ${license_model_id}    ${agreement_id}
602     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}/${agreement_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
603     [Return]    ${resp.json()}
604
605 Add ASDC Software Product
606     [Documentation]    Creates an ASDC Software Product and returns its id
607     [Arguments]    ${license_agreement_id}    ${feature_group_id}    ${license_model_name}    ${license_model_id}   ${license_model_version_id}  ${name_prefix}
608     ${uuid}=    Generate UUID4
609     ${shortened_uuid}=     Evaluate    str("${uuid}")[:13]
610     ${software_product_name}=  Catenate   ${name_prefix}   ${shortened_uuid}
611     ${map}=    Create Dictionary    software_product_name=${software_product_name}    feature_group_id=${feature_group_id}    license_agreement_id=${license_agreement_id}    vendor_name=${license_model_name}    vendor_id=${license_model_id}    version_id=${license_model_version_id}
612     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
613     ${data}=   Apply Template    sdc   ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    ${map}
614     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
615     Should Be Equal As Strings  ${resp.status_code}     200
616     [Return]    ${resp.json()['itemId']}   ${resp.json()['version']['id']}
617
618 Get ASDC Software Product
619     [Documentation]    Gets an ASDC Software Product by its id
620     [Arguments]    ${software_product_id}   ${version_id}=0.1
621     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
622     [Return]    ${resp.json()}
623
624 Add ASDC Catalog Resource
625     [Documentation]    Creates an ASDC Catalog Resource and returns its id
626     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}
627     ${map}=    Create Dictionary    software_product_id=${software_product_id}    software_product_name=${software_product_name}    license_agreement_id=${license_agreement_id}    vendor_name=${license_model_name}
628     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
629     ${data}=   Apply Template    sdc   ${ASDC_CATALOG_RESOURCE_TEMPLATE}    ${map}
630     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
631     Should Be Equal As Strings  ${resp.status_code}     201
632     [Return]    ${resp.json()['uniqueId']}
633
634 Add ASDC Allotted Resource Catalog Resource
635     [Documentation]    Creates an ASDC Allotted Resource Catalog Resource and returns its id
636     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}   ${subcategory}
637     ${map}=    Create Dictionary    software_product_id=${software_product_id}    software_product_name=${software_product_name}    license_agreement_id=${license_agreement_id}    vendor_name=${license_model_name}   subcategory=${subcategory}
638     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
639     ${data}=   Apply Template    sdc   ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    ${map}
640     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
641     Should Be Equal As Strings  ${resp.status_code}     201
642     [Return]    ${resp.json()['uniqueId']}
643
644 Mark ASDC Catalog Resource Inactive
645     [Documentation]    Marks ASDC Catalog Resource as inactive
646     [Arguments]    ${catalog_resource_id}
647     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}     ${ASDC_DESIGNER_USER_ID}
648     Should Be Equal As Strings  ${resp.status_code}     204
649     [Return]    ${resp}
650
651 Delete Inactive ASDC Catalog Resources
652     [Documentation]    Delete all ASDC Catalog Resources that are inactive
653     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}     ${ASDC_DESIGNER_USER_ID}
654     Should Be Equal As Strings  ${resp.status_code}     200
655     [Return]    ${resp.json()}
656
657 Get ASDC Catalog Resource
658     [Documentation]    Gets an ASDC Catalog Resource by its id
659     [Arguments]    ${catalog_resource_id}
660     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}    ${ASDC_DESIGNER_USER_ID}
661     [Return]    ${resp.json()}
662
663 Get ASDC Catalog Resource Component Instances
664     [Documentation]    Gets component instances of an ASDC Catalog Resource by its id
665     [Arguments]    ${catalog_resource_id}
666     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
667     [Return]    ${resp.json()}
668
669 Get ASDC Catalog Resource Deployment Artifact Properties
670     [Documentation]    Gets deployment artifact properties of an ASDC Catalog Resource by its id
671     [Arguments]    ${catalog_resource_id}
672     #${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
673     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=deploymentArtifacts    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
674     [Return]    ${resp.json()}
675
676
677 Get ASDC Catalog Resource Component Instances Properties
678     [Documentation]    Gets ASDC Catalog Resource component instances properties by its id
679     [Arguments]    ${catalog_resource_id}
680     #${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
681     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_BE_ENDPOINT}
682     [Return]    ${resp.json()}
683
684 Get ASDC Catalog Resource Component Instances Properties For Resource
685     [Documentation]    Gets ASDC Catalog Resource component instances properties for a Resource (VF) by its id
686     [Arguments]    ${catalog_resource_id}
687     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
688     [Return]    ${resp.json()}
689
690 Get ASDC Catalog Resource Inputs
691     [Documentation]    Gets ASDC Catalog Resource inputs by its id
692     [Arguments]    ${catalog_resource_id}
693     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=inputs    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
694     [Return]    ${resp.json()}
695
696 Get ASDC Catalog Resource Component Instance Properties
697     [Documentation]    Gets component instance properties of an ASDC Catalog Resource by their ids
698     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${component_id}
699     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/componentInstances/${component_instance_id}/${component_id}/inputs    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
700     [Return]    ${resp.json()}
701
702 Set ASDC Catalog Resource Component Instance Properties
703     [Documentation]    Sets ASDC Catalog Resource component instance properties by ids
704     [Arguments]    ${catalog_resource_id}    ${component_parent_service_id}    ${data}
705     #${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${component_parent_service_id}/resourceInstance/${catalog_resource_id}/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
706     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_SERVICES_PATH}/${component_parent_service_id}/resourceInstance/${catalog_resource_id}/properties    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
707     [Return]   ${resp.json()}
708
709 Set ASDC Catalog Resource Component Instance Properties For Resource
710     [Documentation]    Sets ASDC Resource component instance properties by ids
711     [Arguments]    ${catalog_parent_resource_id}    ${catalog_resource_id}    ${data}
712     #${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_parent_resource_id}/resourceInstance/${catalog_resource_id}/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
713     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_parent_resource_id}/resourceInstance/${catalog_resource_id}/properties   ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
714     [Return]   ${resp.json()}
715
716 Set CDS Catalog Resource Component Instance Properties
717     [Documentation]    Sets CDS Catalog Resource component instance properties by ids
718     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${data}
719     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/resourceInstance/${component_instance_id}/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
720     [Return]    ${resp.json()}
721
722 Set ASDC Catalog Resource VNF Inputs
723     [Documentation]    Sets VNF Inputs for an ASDC Catalog Resource by its id
724     [Arguments]    ${catalog_resource_id}    ${data}
725     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/update/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
726     [Return]    ${resp.json()}
727
728 Get SDC Demo Vnf Catalog Resource
729     [Documentation]  Gets Resource ids of demonstration VNFs for instantiation
730     [Arguments]    ${service_name}
731     ${resp}=   Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/serviceName/${service_name}/serviceVersion/1.0
732     @{ITEMS}=    Copy List    ${resp.json()['componentInstances']}
733     ${demo_catalog_resource}=   Create Dictionary
734     :FOR    ${ELEMENT}    IN    @{ITEMS}
735     \    Log    ${ELEMENT['name']}
736     \    Log    ${ELEMENT['groupInstances'][0]['groupName']}
737     \    ${vnf}=   Get VNF From Group Name     ${ELEMENT['groupInstances'][0]['groupName']}     ${service_name}
738     \    ${vnf_data}=    Create Dictionary    vnf_type=${ELEMENT['name']}  vf_module=${ELEMENT['groupInstances'][0]['groupName']}
739     \    LOG     ${vnf_data}
740     \    Set To Dictionary    ${demo_catalog_resource}    ${vnf}=${vnf_data}
741     \    LOG     ${demo_catalog_resource}
742     [Return]    ${demo_catalog_resource}
743
744 Get VNF From Group Name
745     [Documentation]   Looks up VNF key from service mapping for a regex on group_name and service_name
746     [Arguments]   ${group_name}    ${service_name}
747     ${vnf}=   Set Variable If
748     ...                      ('${service_name}'=='demoVFWCL') and ('base_vfw' in '${group_name}')   vFWCLvFWSNK
749     ...                      ('${service_name}'=='demoVFWCL') and ('base_vpkg' in '${group_name}')   vFWCLvPKG
750     ...                      ('${service_name}'=='demoVLB') and ('base_vlb' in '${group_name}')   vLB
751     [Return]   ${vnf}
752
753 Checkin ASDC Catalog Resource
754     [Documentation]    Checks in an ASDC Catalog Resource by its id
755     [Arguments]    ${catalog_resource_id}
756     ${map}=    Create Dictionary    user_remarks=Robot remarks
757     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
758     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
759     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
760     Should Be Equal As Strings  ${resp.status_code}     200
761     [Return]    ${resp.json()}
762
763 Request Certify ASDC Catalog Resource
764     [Documentation]    Requests certification of an ASDC Catalog Resource by its id
765     [Arguments]    ${catalog_resource_id}
766     ${map}=    Create Dictionary    user_remarks=Robot remarks
767     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
768     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
769     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
770     Should Be Equal As Strings  ${resp.status_code}     200
771     [Return]    ${resp.json()}
772
773 Start Certify ASDC Catalog Resource
774     [Documentation]    Start certification of an ASDC Catalog Resource by its id
775     [Arguments]    ${catalog_resource_id}
776     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
777     Should Be Equal As Strings  ${resp.status_code}     200
778     [Return]    ${resp.json()}
779
780 Certify ASDC Catalog Resource
781     [Documentation]    Certifies an ASDC Catalog Resource by its id and returns the new id
782     [Arguments]    ${catalog_resource_id}    ${user_id}=${ASDC_TESTER_USER_ID}
783     ${map}=    Create Dictionary    user_remarks=Robot remarks
784     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
785     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
786     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${user_id}
787     Should Be Equal As Strings  ${resp.status_code}     200
788     [Return]    ${resp.json()['uniqueId']}
789
790 Upload ASDC Heat Package
791     [Documentation]    Creates an ASDC Software Product and returns its id
792     [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
793      ${files}=     Create Dictionary
794      Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
795     ${resp}=    Run ASDC Post Files Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}     ${files}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
796         Should Be Equal As Strings      ${resp.status_code}     200
797
798 Add ASDC Catalog Service
799     [Documentation]    Creates an ASDC Catalog Service and returns its id
800     [Arguments]   ${catalog_service_name}
801     ${uuid}=    Generate UUID4
802     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
803     ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
804     ${map}=    Create Dictionary    service_name=${catalog_service_name}
805     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
806     ${data}=   Apply Template    sdc   ${ASDC_CATALOG_SERVICE_TEMPLATE}    ${map}
807     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
808     Should Be Equal As Strings  ${resp.status_code}     201
809     [Return]    ${resp.json()['uniqueId']}
810
811 Mark ASDC Catalog Service Inactive
812     [Documentation]    Deletes an ASDC Catalog Service
813     [Arguments]    ${catalog_service_id}
814     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}     ${ASDC_DESIGNER_USER_ID}
815     Should Be Equal As Strings  ${resp.status_code}     204
816     [Return]    ${resp}
817
818 Delete Inactive ASDC Catalog Services
819     [Documentation]    Delete all ASDC Catalog Services that are inactive
820     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}     ${ASDC_DESIGNER_USER_ID}
821     Should Be Equal As Strings  ${resp.status_code}     200
822     [Return]    ${resp.json()}
823
824 Get ASDC Catalog Service
825     [Documentation]    Gets an ASDC Catalog Service by its id
826     [Arguments]    ${catalog_service_id}
827     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}    ${ASDC_DESIGNER_USER_ID}
828     [Return]    ${resp.json()}
829
830 Checkin ASDC Catalog Service
831     [Documentation]    Checks in an ASDC Catalog Service by its id
832     [Arguments]    ${catalog_service_id}
833     ${map}=    Create Dictionary    user_remarks=Robot remarks
834     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
835     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
836     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
837     Should Be Equal As Strings  ${resp.status_code}     200
838     [Return]    ${resp.json()}
839
840 Request Certify ASDC Catalog Service
841     [Documentation]    Requests certification of an ASDC Catalog Service by its id
842     [Arguments]    ${catalog_service_id}
843     ${map}=    Create Dictionary    user_remarks=Robot remarks
844     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
845     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
846     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
847     Should Be Equal As Strings  ${resp.status_code}     200
848     [Return]    ${resp.json()}
849
850 Start Certify ASDC Catalog Service
851     [Documentation]    Start certification of an ASDC Catalog Service by its id
852     [Arguments]    ${catalog_service_id}
853     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
854     Should Be Equal As Strings  ${resp.status_code}     200
855     [Return]    ${resp.json()}
856
857 Certify ASDC Catalog Service
858     [Documentation]    Certifies an ASDC Catalog Service by its id and returns the new id
859     [Arguments]    ${catalog_service_id}
860     ${map}=    Create Dictionary    user_remarks=Robot remarks
861     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
862     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
863     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}
864     Should Be Equal As Strings  ${resp.status_code}     200
865     [Return]    ${resp.json()['uniqueId']}
866
867 Approve ASDC Catalog Service
868     [Documentation]    Approves an ASDC Catalog Service by its id
869     [Arguments]    ${catalog_service_id}
870     ${map}=    Create Dictionary    user_remarks=Robot remarks
871     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
872     ${data}=   Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
873     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    ${data}    ${ASDC_GOVERNOR_USER_ID}
874     Should Be Equal As Strings  ${resp.status_code}     200
875     [Return]    ${resp.json()}
876 Distribute ASDC Catalog Service
877     [Documentation]    distribute an asdc Catalog Service by its id
878     [Arguments]    ${catalog_service_id}
879     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    ${None}    ${ASDC_OPS_USER_ID}
880     Should Be Equal As Strings  ${resp.status_code}     200
881     [Return]    ${resp.json()}
882
883 Add ASDC Resource Instance
884     [Documentation]    Creates an ASDC Resource Instance and returns its id
885     [Arguments]    ${catalog_service_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}   ${resourceType}=VF
886     ${milli_timestamp}=    Generate Timestamp
887     ${xoffset}=    Set Variable   ${xoffset+306}
888     ${yoffset}=    Set Variable   ${yoffset+248}
889     ${map}=    Create Dictionary    catalog_resource_id=${catalog_resource_id}    catalog_resource_name=${catalog_resource_name}    milli_timestamp=${milli_timestamp}   posX=${xoffset}    posY=${yoffset}    originType=${resourceType}
890     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
891     ${data}=   Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
892     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
893     Should Be Equal As Strings  ${resp.status_code}     201
894     [Return]    ${resp.json()['uniqueId']}
895
896 Add ASDC Resource Instance To Resource
897     [Documentation]    Creates an ASDC Resource Instance in a Resource (VF) and returns its id
898     [Arguments]    ${parent_catalog_resource_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}    ${resourceType}=VF
899     ${milli_timestamp}=    Generate Timestamp
900     ${xoffset}=    Set Variable   ${xoffset+306}
901     ${yoffset}=    Set Variable   ${yoffset+248}
902     ${map}=    Create Dictionary    catalog_resource_id=${catalog_resource_id}    catalog_resource_name=${catalog_resource_name}    milli_timestamp=${milli_timestamp}   posX=${xoffset}    posY=${yoffset}    originType=${resourceType}
903     Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
904     ${data}=   Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
905     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${parent_catalog_resource_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
906     Should Be Equal As Strings  ${resp.status_code}     201
907     [Return]    ${resp.json()['uniqueId']}
908
909 Get Catalog Service Distribution
910     [Documentation]    Gets an ASDC Catalog Service distribution
911     [Arguments]    ${catalog_service_uuid}
912     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_uuid}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    ${ASDC_OPS_USER_ID}
913     Should Be Equal As Strings  ${resp.status_code}     200
914     [Return]    ${resp.json()}
915
916 Check Catalog Service Distributed
917     [Documentation]    Checks if an ASDC Catalog Service is distributed
918     [Arguments]    ${catalog_service_uuid}    ${dist_status}
919     ${dist_resp}=    Get Catalog Service Distribution    ${catalog_service_uuid}
920     Should Be Equal As Strings  ${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']}         Distributed
921     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
922     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
923     Should Not Be Empty   ${ITEMS}
924     ${SO_COMPLETE}   Set Variable   FALSE
925     ${dist_status}   Set Variable   CONTINUE
926     Should Not Be Empty   ${ITEMS}
927     :FOR    ${ELEMENT}    IN    @{ITEMS}
928     \    Log    ${ELEMENT['omfComponentID']}
929     \    Log    ${ELEMENT['status']}
930     \    ${SO_COMPLETE}   Set Variable If   (('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_OK')) or ('${SO_COMPLETE}'=='TRUE')  TRUE
931     \    Exit For Loop If   ('${SO_COMPLETE}'=='TRUE')
932     \    Exit For Loop If   ('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_ERROR')
933     \    ${dist_status}=  Set Variable If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))  EXIT
934     \    Exit For Loop If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))
935     Should Be True   ( '${SO_COMPLETE}'=='TRUE')   SO Test
936
937 Get Catalog Service Distribution Details
938     [Documentation]    Gets ASDC Catalog Service distribution details
939     [Arguments]    ${catalog_service_distribution_id}
940     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}/${catalog_service_distribution_id}    ${ASDC_OPS_USER_ID}
941     Should Be Equal As Strings  ${resp.status_code}     200
942     [Return]    ${resp.json()}
943 Run ASDC Health Check
944     [Documentation]    Runs a ASDC health check
945     ${session}=    Create Session       asdc    ${ASDC_FE_ENDPOINT}
946     ${uuid}=    Generate UUID4
947     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
948     ${resp}=    Get Request     asdc    ${ASDC_HEALTH_CHECK_PATH}     headers=${headers}
949     # only test for HTTP 200 to determine SDC Health. SDC_DE_HEALTH is informational
950     Should Be Equal As Strings  ${resp.status_code}     200    SDC DOWN
951     ${SDC_DE_HEALTH}=    Catenate   DOWN
952     @{ITEMS}=    Copy List    ${resp.json()['componentsInfo']}
953     :FOR    ${ELEMENT}    IN    @{ITEMS}
954     \    Log    ${ELEMENT['healthCheckStatus']}
955     \    ${SDC_DE_HEALTH}  Set Variable If   (('DE' in '${ELEMENT['healthCheckComponent']}') and ('${ELEMENT['healthCheckStatus']}' == 'UP')) or ('${SDC_DE_HEALTH}'=='UP')  UP
956     Log To Console   (DMaaP:${SDC_DE_HEALTH})    no_newline=true
957 Run ASDC Get Request
958     [Documentation]    Runs an ASDC get request
959     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
960     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
961     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
962     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
963     ${uuid}=    Generate UUID4
964     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
965     ${resp}=    Get Request     asdc    ${data_path}     headers=${headers}
966     Log    Received response from asdc ${resp.text}
967     [Return]    ${resp}
968 Run ASDC Put Request
969     [Documentation]    Runs an ASDC put request
970     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
971     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
972     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
973     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
974     ${uuid}=    Generate UUID4
975     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
976     ${resp}=    Put Request     asdc    ${data_path}     data=${data}    headers=${headers}
977     Log    Received response from asdc ${resp.text}
978     [Return]    ${resp}
979
980 Run ASDC Post Files Request
981     [Documentation]    Runs an ASDC post request
982     [Arguments]    ${data_path}    ${files}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
983     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
984     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
985     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
986     ${uuid}=    Generate UUID4
987     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=multipart/form-data    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
988     ${resp}=    Post Request    asdc    ${data_path}     files=${files}    headers=${headers}
989     Log    Received response from asdc ${resp.text}
990     [Return]    ${resp}
991
992 Run ASDC MD5 Post Request
993     [Documentation]    Runs an ASDC post request with MD5 Checksum header
994     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
995     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
996     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
997     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
998     ${uuid}=    Generate UUID4
999     ${data_string}=   Evaluate    json.dumps(${data})     json
1000     ${md5checksum}=   Evaluate    md5.new('''${data_string}''').hexdigest()   modules=md5
1001     ${base64md5checksum}=  Evaluate     base64.b64encode("${md5checksum}")     modules=base64
1002     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}   Content-MD5=${base64md5checksum}
1003     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
1004     Log    Received response from asdc ${resp.text}
1005     [Return]    ${resp}
1006
1007 Run ASDC Post Request
1008     [Documentation]    Runs an ASDC post request
1009     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
1010     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
1011     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
1012     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
1013     ${uuid}=    Generate UUID4
1014     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
1015     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
1016     Log    Received response from asdc ${resp.text}
1017     [Return]    ${resp}
1018
1019 Run ASDC Delete Request
1020     [Documentation]    Runs an ASDC delete request
1021     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
1022     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
1023     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
1024     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
1025     ${uuid}=    Generate UUID4
1026     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
1027     ${resp}=    Delete Request  asdc    ${data_path}        headers=${headers}
1028     Log    Received response from asdc ${resp.text}
1029     [Return]    ${resp}
1030 Open ASDC GUI
1031     [Documentation]   Logs in to ASDC GUI
1032     [Arguments]    ${PATH}
1033     ## Setup Browever now being managed by the test case
1034     ##Setup Browser
1035     Go To    ${ASDC_FE_ENDPOINT}${PATH}
1036     Maximize Browser Window
1037
1038     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
1039     Log    Logging in to ${ASDC_FE_ENDPOINT}${PATH}
1040     Title Should Be    ASDC
1041     Wait Until Page Contains Element    xpath=//div/a[text()='SDC']    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
1042     Log    Logged in to ${ASDC_FE_ENDPOINT}${PATH}
1043
1044
1045 Create Multi Part
1046    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}
1047    ${fileData}=   Get Binary File  ${filePath}
1048    ${fileDir}  ${fileName}=  Split Path  ${filePath}
1049    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
1050    Set To Dictionary  ${addTo}  ${partName}=${partData}
1051