d91786cab1a25811e13873c7b6c7ac3ed90b8a30
[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 Resource          global_properties.robot
16 Resource          browser_setup.robot
17 Resource          json_templater.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}    robot/assets/templates/asdc/license_model.template
48 ${ASDC_KEY_GROUP_TEMPLATE}    robot/assets/templates/asdc/key_group.template
49 ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    robot/assets/templates/asdc/entitlement_pool.template
50 ${ASDC_FEATURE_GROUP_TEMPLATE}    robot/assets/templates/asdc/feature_group.template
51 ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    robot/assets/templates/asdc/license_agreement.template
52 ${ASDC_ACTION_TEMPLATE}    robot/assets/templates/asdc/action.template
53 ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    robot/assets/templates/asdc/software_product.template
54 ${ASDC_ARTIFACT_UPLOAD_TEMPLATE}    robot/assets/templates/asdc/artifact_upload.template
55 ${ASDC_CATALOG_RESOURCE_TEMPLATE}    robot/assets/templates/asdc/catalog_resource.template
56 ${ASDC_USER_REMARKS_TEMPLATE}    robot/assets/templates/asdc/user_remarks.template
57 ${ASDC_CATALOG_SERVICE_TEMPLATE}    robot/assets/templates/asdc/catalog_service.template
58 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    robot/assets/templates/asdc/resource_instance.template
59 ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    robot/assets/templates/asdc/catalog_vnf_properties.template
60 ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    robot/assets/templates/asdc/catalog_vnf_inputs.template
61 ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    robot/assets/templates/asdc/catalog_net_input_properties.template
62 ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    robot/assets/templates/asdc/catalog_resource_alloted_resource.template
63 ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    robot/assets/templates/asdc/catalog_allotted_properties.template
64 ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    robot/assets/templates/asdc/catalog_allotted_inputs.template
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     #${resp}=    Get ASDC Catalog Resource Deployment Artifact Properties  ${catalog_service_id}
324     ${blueprint_data}    OperatingSystem.Get File    ${SDC_CATALOG_DEPLOYMENT_ARTIFACT_PATH}${blueprint_file}
325     ${payloadData}=   Evaluate   base64.b64encode('''${blueprint_data}'''.encode('utf-8'))   modules=base64
326     ${dict}=    Create Dictionary  artifactLabel=blueprint  artifactName=${blueprint_file}   artifactType=DCAE_INVENTORY_BLUEPRINT  artifactGroupType=DEPLOYMENT  description=${blueprint_file}   payloadData=${payloadData}
327     ${data}=   Fill JSON Template File    ${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     \    ${data}=   Fill JSON Template File    ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    ${dict}
361     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_parent_service_id}    ${catalog_service_id}    ${data}
362
363
364 Setup SDC Catalog Resource AllottedResource Properties
365     [Documentation]    Set up Allotted Resource properties and inputs
366     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}   ${invariantUUID}   ${UUID}     ${node_type}
367     # Set component instances properties
368     ${nf_role_lc}=   Convert To Lowercase   ${nf_role}
369     ${resp}=    Get ASDC Catalog Resource Component Instances Properties For Resource     ${catalog_resource_id}
370     ${componentInstances}  Set Variable   @{resp['componentInstancesProperties']}
371     # componentInstances can have 1 or more than 1 entry
372     ${passed}=    Run Keyword And Return Status   Evaluate    type(${componentInstances})
373     ${type}=      Run Keyword If     ${passed}    Evaluate    type(${componentInstances})
374     ${componentInstancesList}=    Run Keyword If   "${type}"!="<type 'list'>"    Create List  ${componentInstances}
375     ...    ELSE   Set Variable    ${componentInstances}
376     :FOR   ${item}  IN   @{componentInstancesList}
377     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${item}     ${nf_role_lc}
378     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
379     \    ${componentInstance1}=   Set Variable    ${item}
380     ${dict}=    Create Dictionary
381     :FOR    ${comp}    IN    @{resp['componentInstancesProperties']["${componentInstance1}"]}
382     \    ${name}    Set Variable   ${comp['name']}
383     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain Any     ${name}    network_role  providing_service_invariant_uuid  providing_service_uuid  providing_service_name   uniqueId
384     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
385     \    ${parentUniqueId}    Set Variable    ${comp['parentUniqueId']}
386     \    ${ownerId}    Set Variable    ${comp['ownerId']}
387     \    Set To Dictionary     ${dict}    parentUniqueId=${parentUniqueId}   ownerId=${ownerId}
388     \    Run Keyword If   '${name}'=='providing_service_invariant_uuid'   Set To Dictionary    ${dict}    providing_service_invariant_uuid=${invariantUUID}
389     \    Run Keyword If   '${name}'=='providing_service_uuid'   Set To Dictionary    ${dict}    providing_service_uuid=${UUID}
390     \    Run Keyword If   '${name}'=='providing_service_name'   Set To Dictionary    ${dict}    providing_service_name=${node_type}
391     #    Sets it for each loop but should be one
392     \    ${uniqueId}    Set Variable     ${comp['uniqueId']}
393     \    ${uniqueId}   Fetch From Left   ${uniqueId}   .
394     \    Set To Dictionary    ${dict}    uniqueId=${uniqueId}
395     ${data}=   Fill JSON Template File    ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    ${dict}
396     ${response}=    Set ASDC Catalog Resource Component Instance Properties For Resource    ${catalog_resource_id}    ${componentInstance1}    ${data}
397     Log To Console    resp=${response}
398
399
400 Setup SDC Catalog Resource AllottedResource Inputs
401     [Documentation]    Set up Allotted Resource inputs
402     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}
403     # Set vnf inputs
404     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
405     ${dict}=    Create Dictionary
406     :FOR    ${comp}    IN    @{resp['inputs']}
407     \    ${name}    Set Variable    ${comp['name']}
408     \    ${uid}    Set Variable    ${comp['uniqueId']}
409     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=${nf_role}    nf_type_uid=${uid}
410     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=${nf_role}   nf_role_uid=${uid}
411     ${data}=   Fill JSON Template File    ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    ${dict}
412     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
413     [Return]    ${response}
414
415 Setup ASDC Catalog Resource CDS Properties
416     [Documentation]    Set up vfwng VNF properties and inputs for CDS
417     [Arguments]    ${catalog_resource_id}
418     # Set vnf module properties
419     ${resp}=    Get ASDC Catalog Resource Component Instances   ${catalog_resource_id}
420     :FOR    ${comp}    IN    @{resp['componentInstances']}
421     \    ${name}    Set Variable   ${comp['name']}
422     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
423     \    ${actualComponentUid}    Set Variable    ${comp['actualComponentUid']}
424     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    abstract_
425     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
426     \    ${response}=    Get ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${actualComponentUid}
427     \    ${dict}=    Create Dictionary    parent_id=${response[6]['parentUniqueId']}
428     \    Run Keyword If   '${name}'=='abstract_vfw'   Set To Dictionary    ${dict}    nfc_function=vfw    nfc_naming_policy=SDNC_Policy.ONAP_VFW_NAMING_TIMESTAMP
429     \    Run Keyword If   '${name}'=='abstract_vpg'   Set To Dictionary    ${dict}    nfc_function=vpg    nfc_naming_policy=SDNC_Policy.ONAP_VPG_NAMING_TIMESTAMP
430     \    Run Keyword If   '${name}'=='abstract_vsn'   Set To Dictionary    ${dict}    nfc_function=vsn    nfc_naming_policy=SDNC_Policy.ONAP_VSN_NAMING_TIMESTAMP
431     \    ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    ${dict}
432     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${data}
433     \    Log To Console    resp=${response}
434
435     # Set vnf inputs
436     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
437     ${dict}=    Create Dictionary
438     :FOR    ${comp}    IN    @{resp['inputs']}
439     \    ${name}    Set Variable    ${comp['name']}
440     \    ${uid}    Set Variable    ${comp['uniqueId']}
441     \    Run Keyword If    '${name}'=='nf_function'    Set To Dictionary    ${dict}    nf_function=ONAP-FIREWALL    nf_function_uid=${uid}
442     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=FIREWALL    nf_type_uid=${uid}
443     \    Run Keyword If    '${name}'=='nf_naming_code'    Set To Dictionary    ${dict}    nf_naming_code=vfw    nf_naming_code_uid=${uid}
444     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=vFW    nf_role_uid=${uid}
445     \    Run Keyword If    '${name}'=='cloud_env'    Set To Dictionary    ${dict}    cloud_env=openstack    cloud_env_uid=${uid}
446     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    ${dict}
447     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
448
449 Add ASDC License Model
450     [Documentation]    Creates an ASDC License Model and returns its id
451     ${uuid}=    Generate UUID4
452     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
453     ${map}=    Create Dictionary    vendor_name=${shortened_uuid}
454     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_MODEL_TEMPLATE}    ${map}
455     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
456     Should Be Equal As Strings  ${resp.status_code}     200
457     [Return]    ${resp.json()['itemId']}    ${resp.json()['version']['id']}
458 Get ASDC License Model
459     [Documentation]    gets an asdc license model by its id
460     [Arguments]    ${id}   ${version_id}=0.1
461     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
462     [Return]    ${resp.json()}
463
464 Get ASDC License Models
465     [Documentation]    Gets all ASDC License Models
466     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
467     [Return]    ${resp.json()}
468
469 Checkin ASDC License Model
470     [Documentation]    Checks in an ASDC License Model by its id
471     [Arguments]    ${id}   ${version_id}=0.1
472     ${map}=    Create Dictionary    action=Checkin
473     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
474     ${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}
475     Should Be Equal As Strings  ${resp.status_code}     200
476     [Return]    ${resp.json()}
477
478 Submit ASDC License Model
479     [Documentation]    Submits an ASDC License Model by its id
480     [Arguments]    ${id}   ${version_id}=0.1
481     ${map}=    Create Dictionary    action=Submit
482     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
483     ${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}
484     Should Be Equal As Strings  ${resp.status_code}     200
485     [Return]    ${resp.json()}
486
487 Checkin ASDC Software Product
488     [Documentation]    Checks in an ASDC Software Product by its id
489     [Arguments]    ${id}   ${version_id}=0.1
490     ${map}=    Create Dictionary    action=Checkin
491     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
492     ${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}
493     Should Be Equal As Strings  ${resp.status_code}     200
494     [Return]    ${resp.json()}
495
496 Validate ASDC Software Product
497     [Documentation]    Validates an ASDC Software Product by its id
498     [Arguments]    ${id}   ${version_id}=0.1
499     ${data}=   Catenate
500     ${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}
501     Should Be Equal As Strings  ${resp.status_code}     200
502     [Return]    ${resp.json()}
503
504 Submit ASDC Software Product
505     [Documentation]    Submits an ASDC Software Product by its id
506     [Arguments]    ${id}   ${version_id}=0.1
507     ${map}=    Create Dictionary    action=Submit
508     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
509     ${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}
510     Should Be Equal As Strings  ${resp.status_code}     200
511     [Return]    ${resp.json()}
512
513 Package ASDC Software Product
514     [Documentation]    Creates a package of an ASDC Software Product by its id
515     [Arguments]    ${id}   ${version_id}=0.1
516     ${map}=    Create Dictionary    action=Create_Package
517     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
518     ${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}
519     Should Be Equal As Strings  ${resp.status_code}     200
520     [Return]    ${resp.json()}
521
522 Add ASDC Entitlement Pool
523     [Documentation]    Creates an ASDC Entitlement Pool and returns its id
524     [Arguments]    ${license_model_id}   ${version_id}=0.1     ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
525     ${uuid}=    Generate UUID4
526     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
527     ${map}=    Create Dictionary    entitlement_pool_name=${shortened_uuid}  license_start_date=${license_start_date}  license_end_date=${license_end_date}
528     ${data}=   Fill JSON Template File    ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    ${map}
529     ${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}
530     Should Be Equal As Strings  ${resp.status_code}     200
531     [Return]    ${resp.json()['value']}
532
533 Get ASDC Entitlement Pool
534     [Documentation]    Gets an ASDC Entitlement Pool by its id
535     [Arguments]    ${license_model_id}    ${pool_id}
536     ${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}
537     [Return]    ${resp.json()}
538
539 Add ASDC License Group
540     [Documentation]    Creates an ASDC License Group and returns its id
541     [Arguments]    ${license_model_id}   ${version_id}=1.0   ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
542     ${uuid}=    Generate UUID4
543     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
544     ${map}=    Create Dictionary    key_group_name=${shortened_uuid}   license_start_date=${license_start_date}  license_end_date=${license_end_date}
545     ${data}=   Fill JSON Template File    ${ASDC_KEY_GROUP_TEMPLATE}    ${map}
546     ${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}
547     Should Be Equal As Strings  ${resp.status_code}     200
548     [Return]    ${resp.json()['value']}
549
550 Get ASDC License Group
551     [Documentation]    Gets an ASDC License Group by its id
552     [Arguments]    ${license_model_id}    ${group_id}      ${version_id}
553     ${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}
554     [Return]    ${resp.json()}
555
556 Add ASDC Feature Group
557     [Documentation]    Creates an ASDC Feature Group and returns its id
558     [Arguments]    ${license_model_id}    ${key_group_id}    ${entitlement_pool_id}      ${version_id}=0.1
559     ${uuid}=    Generate UUID4
560     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
561     ${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}
562     ${data}=   Fill JSON Template File    ${ASDC_FEATURE_GROUP_TEMPLATE}    ${map}
563     ${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}
564     Should Be Equal As Strings  ${resp.status_code}     200
565     [Return]    ${resp.json()['value']}
566
567 Get ASDC Feature Group
568     [Documentation]    Gets an ASDC Feature Group by its id
569     [Arguments]    ${license_model_id}    ${group_id}
570     ${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}
571     [Return]    ${resp.json()}
572
573 Add ASDC License Agreement
574     [Documentation]    Creates an ASDC License Agreement and returns its id
575     [Arguments]    ${license_model_id}    ${feature_group_id}      ${version_id}=0.1
576     ${uuid}=    Generate UUID4
577     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
578     ${map}=    Create Dictionary    license_agreement_name=${shortened_uuid}    feature_group_id=${feature_group_id}
579     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    ${map}
580     ${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}
581     Should Be Equal As Strings  ${resp.status_code}     200
582     [Return]    ${resp.json()['value']}
583
584 Get ASDC License Agreement
585     [Documentation]    Gets an ASDC License Agreement by its id
586     [Arguments]    ${license_model_id}    ${agreement_id}
587     ${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}
588     [Return]    ${resp.json()}
589
590 Add ASDC Software Product
591     [Documentation]    Creates an ASDC Software Product and returns its id
592     [Arguments]    ${license_agreement_id}    ${feature_group_id}    ${license_model_name}    ${license_model_id}   ${license_model_version_id}  ${name_prefix}
593     ${uuid}=    Generate UUID4
594     ${shortened_uuid}=     Evaluate    str("${uuid}")[:13]
595     ${software_product_name}=  Catenate   ${name_prefix}   ${shortened_uuid}
596     ${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}
597     ${data}=   Fill JSON Template File    ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    ${map}
598     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
599     Should Be Equal As Strings  ${resp.status_code}     200
600     [Return]    ${resp.json()['itemId']}   ${resp.json()['version']['id']}
601
602 Get ASDC Software Product
603     [Documentation]    Gets an ASDC Software Product by its id
604     [Arguments]    ${software_product_id}   ${version_id}=0.1
605     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
606     [Return]    ${resp.json()}
607
608 Add ASDC Catalog Resource
609     [Documentation]    Creates an ASDC Catalog Resource and returns its id
610     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}
611     ${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}
612     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_RESOURCE_TEMPLATE}    ${map}
613     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
614     Should Be Equal As Strings  ${resp.status_code}     201
615     [Return]    ${resp.json()['uniqueId']}
616
617 Add ASDC Allotted Resource Catalog Resource
618     [Documentation]    Creates an ASDC Allotted Resource Catalog Resource and returns its id
619     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}   ${subcategory}
620     ${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}
621     ${data}=   Fill JSON Template File    ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    ${map}
622     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
623     Should Be Equal As Strings  ${resp.status_code}     201
624     [Return]    ${resp.json()['uniqueId']}
625
626 Mark ASDC Catalog Resource Inactive
627     [Documentation]    Marks ASDC Catalog Resource as inactive
628     [Arguments]    ${catalog_resource_id}
629     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}     ${ASDC_DESIGNER_USER_ID}
630     Should Be Equal As Strings  ${resp.status_code}     204
631     [Return]    ${resp}
632
633 Delete Inactive ASDC Catalog Resources
634     [Documentation]    Delete all ASDC Catalog Resources that are inactive
635     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}     ${ASDC_DESIGNER_USER_ID}
636     Should Be Equal As Strings  ${resp.status_code}     200
637     [Return]    ${resp.json()}
638
639 Get ASDC Catalog Resource
640     [Documentation]    Gets an ASDC Catalog Resource by its id
641     [Arguments]    ${catalog_resource_id}
642     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}    ${ASDC_DESIGNER_USER_ID}
643     [Return]    ${resp.json()}
644
645 Get ASDC Catalog Resource Component Instances
646     [Documentation]    Gets component instances of an ASDC Catalog Resource by its id
647     [Arguments]    ${catalog_resource_id}
648     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
649     [Return]    ${resp.json()}
650
651 Get ASDC Catalog Resource Deployment Artifact Properties
652     [Documentation]    Gets deployment artifact properties of an ASDC Catalog Resource by its id
653     [Arguments]    ${catalog_resource_id}
654     #${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
655     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=deploymentArtifacts    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
656     [Return]    ${resp.json()}
657
658
659 Get ASDC Catalog Resource Component Instances Properties
660     [Documentation]    Gets ASDC Catalog Resource component instances properties by its id
661     [Arguments]    ${catalog_resource_id}
662     #${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
663     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_BE_ENDPOINT}
664     [Return]    ${resp.json()}
665
666 Get ASDC Catalog Resource Component Instances Properties For Resource
667     [Documentation]    Gets ASDC Catalog Resource component instances properties for a Resource (VF) by its id
668     [Arguments]    ${catalog_resource_id}
669     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
670     [Return]    ${resp.json()}
671
672 Get ASDC Catalog Resource Inputs
673     [Documentation]    Gets ASDC Catalog Resource inputs by its id
674     [Arguments]    ${catalog_resource_id}
675     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=inputs    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
676     [Return]    ${resp.json()}
677
678 Get ASDC Catalog Resource Component Instance Properties
679     [Documentation]    Gets component instance properties of an ASDC Catalog Resource by their ids
680     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${component_id}
681     ${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}
682     [Return]    ${resp.json()}
683
684 Set ASDC Catalog Resource Component Instance Properties
685     [Documentation]    Sets ASDC Catalog Resource component instance properties by ids
686     [Arguments]    ${catalog_resource_id}    ${component_parent_service_id}    ${data}
687     #${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}
688     ${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}
689     [Return]   ${resp.json()}
690
691 Set ASDC Catalog Resource Component Instance Properties For Resource
692     [Documentation]    Sets ASDC Resource component instance properties by ids
693     [Arguments]    ${catalog_parent_resource_id}    ${catalog_resource_id}    ${data}
694     #${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}
695     ${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}
696     [Return]   ${resp.json()}
697
698 Set CDS Catalog Resource Component Instance Properties
699     [Documentation]    Sets CDS Catalog Resource component instance properties by ids
700     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${data}
701     ${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}
702     [Return]    ${resp.json()}
703
704 Set ASDC Catalog Resource VNF Inputs
705     [Documentation]    Sets VNF Inputs for an ASDC Catalog Resource by its id
706     [Arguments]    ${catalog_resource_id}    ${data}
707     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/update/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
708     [Return]    ${resp.json()}
709
710 Get SDC Demo Vnf Catalog Resource
711     [Documentation]  Gets Resource ids of demonstration VNFs for instantiation
712     [Arguments]    ${service_name}
713     ${resp}=   Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/serviceName/${service_name}/serviceVersion/1.0
714     @{ITEMS}=    Copy List    ${resp.json()['componentInstances']}
715     ${demo_catalog_resource}=   Create Dictionary
716     :FOR    ${ELEMENT}    IN    @{ITEMS}
717     \    Log    ${ELEMENT['name']}
718     \    Log    ${ELEMENT['groupInstances'][0]['groupName']}
719     \    ${vnf}=   Get VNF From Group Name     ${ELEMENT['groupInstances'][0]['groupName']}     ${service_name}
720     \    ${vnf_data}=    Create Dictionary    vnf_type=${ELEMENT['name']}  vf_module=${ELEMENT['groupInstances'][0]['groupName']}
721     \    LOG     ${vnf_data}
722     \    Set To Dictionary    ${demo_catalog_resource}    ${vnf}=${vnf_data}
723     \    LOG     ${demo_catalog_resource}
724     [Return]    ${demo_catalog_resource}
725
726 Get VNF From Group Name
727     [Documentation]   Looks up VNF key from service mapping for a regex on group_name and service_name
728     [Arguments]   ${group_name}    ${service_name}
729     ${vnf}=   Set Variable If
730     ...                      ('${service_name}'=='demoVFWCL') and ('base_vfw' in '${group_name}')   vFWCLvFWSNK
731     ...                      ('${service_name}'=='demoVFWCL') and ('base_vpkg' in '${group_name}')   vFWCLvPKG
732     ...                      ('${service_name}'=='demoVLB') and ('base_vlb' in '${group_name}')   vLB
733     [Return]   ${vnf}
734
735 Checkin ASDC Catalog Resource
736     [Documentation]    Checks in an ASDC Catalog Resource by its id
737     [Arguments]    ${catalog_resource_id}
738     ${map}=    Create Dictionary    user_remarks=Robot remarks
739     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
740     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
741     Should Be Equal As Strings  ${resp.status_code}     200
742     [Return]    ${resp.json()}
743
744 Request Certify ASDC Catalog Resource
745     [Documentation]    Requests certification of an ASDC Catalog Resource by its id
746     [Arguments]    ${catalog_resource_id}
747     ${map}=    Create Dictionary    user_remarks=Robot remarks
748     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
749     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
750     Should Be Equal As Strings  ${resp.status_code}     200
751     [Return]    ${resp.json()}
752
753 Start Certify ASDC Catalog Resource
754     [Documentation]    Start certification of an ASDC Catalog Resource by its id
755     [Arguments]    ${catalog_resource_id}
756     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
757     Should Be Equal As Strings  ${resp.status_code}     200
758     [Return]    ${resp.json()}
759
760 Certify ASDC Catalog Resource
761     [Documentation]    Certifies an ASDC Catalog Resource by its id and returns the new id
762     [Arguments]    ${catalog_resource_id}    ${user_id}=${ASDC_TESTER_USER_ID}
763     ${map}=    Create Dictionary    user_remarks=Robot remarks
764     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
765     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${user_id}
766     Should Be Equal As Strings  ${resp.status_code}     200
767     [Return]    ${resp.json()['uniqueId']}
768
769 Upload ASDC Heat Package
770     [Documentation]    Creates an ASDC Software Product and returns its id
771     [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
772      ${files}=     Create Dictionary
773      Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
774     ${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}
775         Should Be Equal As Strings      ${resp.status_code}     200
776
777 Add ASDC Catalog Service
778     [Documentation]    Creates an ASDC Catalog Service and returns its id
779     [Arguments]   ${catalog_service_name}
780     ${uuid}=    Generate UUID4
781     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
782     ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
783     ${map}=    Create Dictionary    service_name=${catalog_service_name}
784     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_SERVICE_TEMPLATE}    ${map}
785     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
786     Should Be Equal As Strings  ${resp.status_code}     201
787     [Return]    ${resp.json()['uniqueId']}
788
789 Mark ASDC Catalog Service Inactive
790     [Documentation]    Deletes an ASDC Catalog Service
791     [Arguments]    ${catalog_service_id}
792     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}     ${ASDC_DESIGNER_USER_ID}
793     Should Be Equal As Strings  ${resp.status_code}     204
794     [Return]    ${resp}
795
796 Delete Inactive ASDC Catalog Services
797     [Documentation]    Delete all ASDC Catalog Services that are inactive
798     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}     ${ASDC_DESIGNER_USER_ID}
799     Should Be Equal As Strings  ${resp.status_code}     200
800     [Return]    ${resp.json()}
801
802 Get ASDC Catalog Service
803     [Documentation]    Gets an ASDC Catalog Service by its id
804     [Arguments]    ${catalog_service_id}
805     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}    ${ASDC_DESIGNER_USER_ID}
806     [Return]    ${resp.json()}
807
808 Checkin ASDC Catalog Service
809     [Documentation]    Checks in an ASDC Catalog Service by its id
810     [Arguments]    ${catalog_service_id}
811     ${map}=    Create Dictionary    user_remarks=Robot remarks
812     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
813     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
814     Should Be Equal As Strings  ${resp.status_code}     200
815     [Return]    ${resp.json()}
816
817 Request Certify ASDC Catalog Service
818     [Documentation]    Requests certification of an ASDC Catalog Service by its id
819     [Arguments]    ${catalog_service_id}
820     ${map}=    Create Dictionary    user_remarks=Robot remarks
821     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
822     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
823     Should Be Equal As Strings  ${resp.status_code}     200
824     [Return]    ${resp.json()}
825
826 Start Certify ASDC Catalog Service
827     [Documentation]    Start certification of an ASDC Catalog Service by its id
828     [Arguments]    ${catalog_service_id}
829     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
830     Should Be Equal As Strings  ${resp.status_code}     200
831     [Return]    ${resp.json()}
832
833 Certify ASDC Catalog Service
834     [Documentation]    Certifies an ASDC Catalog Service by its id and returns the new id
835     [Arguments]    ${catalog_service_id}
836     ${map}=    Create Dictionary    user_remarks=Robot remarks
837     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
838     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}
839     Should Be Equal As Strings  ${resp.status_code}     200
840     [Return]    ${resp.json()['uniqueId']}
841
842 Approve ASDC Catalog Service
843     [Documentation]    Approves an ASDC Catalog Service by its id
844     [Arguments]    ${catalog_service_id}
845     ${map}=    Create Dictionary    user_remarks=Robot remarks
846     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
847     ${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}
848     Should Be Equal As Strings  ${resp.status_code}     200
849     [Return]    ${resp.json()}
850 Distribute ASDC Catalog Service
851     [Documentation]    distribute 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_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    ${None}    ${ASDC_OPS_USER_ID}
854     Should Be Equal As Strings  ${resp.status_code}     200
855     [Return]    ${resp.json()}
856
857 Add ASDC Resource Instance
858     [Documentation]    Creates an ASDC Resource Instance and returns its id
859     [Arguments]    ${catalog_service_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}   ${resourceType}=VF
860     ${milli_timestamp}=    Generate Timestamp
861     ${xoffset}=    Set Variable   ${xoffset+306}
862     ${yoffset}=    Set Variable   ${yoffset+248}
863     ${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}
864     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
865     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
866     Should Be Equal As Strings  ${resp.status_code}     201
867     [Return]    ${resp.json()['uniqueId']}
868
869 Add ASDC Resource Instance To Resource
870     [Documentation]    Creates an ASDC Resource Instance in a Resource (VF) and returns its id
871     [Arguments]    ${parent_catalog_resource_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}    ${resourceType}=VF
872     ${milli_timestamp}=    Generate Timestamp
873     ${xoffset}=    Set Variable   ${xoffset+306}
874     ${yoffset}=    Set Variable   ${yoffset+248}
875     ${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}
876     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
877     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${parent_catalog_resource_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
878     Should Be Equal As Strings  ${resp.status_code}     201
879     [Return]    ${resp.json()['uniqueId']}
880
881 Get Catalog Service Distribution
882     [Documentation]    Gets an ASDC Catalog Service distribution
883     [Arguments]    ${catalog_service_uuid}
884     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_uuid}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    ${ASDC_OPS_USER_ID}
885     Should Be Equal As Strings  ${resp.status_code}     200
886     [Return]    ${resp.json()}
887
888 Check Catalog Service Distributed
889     [Documentation]    Checks if an ASDC Catalog Service is distributed
890     [Arguments]    ${catalog_service_uuid}    ${dist_status}
891     ${dist_resp}=    Get Catalog Service Distribution    ${catalog_service_uuid}
892     Should Be Equal As Strings  ${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']}         Distributed
893     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
894     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
895     Should Not Be Empty   ${ITEMS}
896     ${SO_COMPLETE}   Set Variable   FALSE
897     ${dist_status}   Set Variable   CONTINUE
898     Should Not Be Empty   ${ITEMS}
899     :FOR    ${ELEMENT}    IN    @{ITEMS}
900     \    Log    ${ELEMENT['omfComponentID']}
901     \    Log    ${ELEMENT['status']}
902     \    ${SO_COMPLETE}   Set Variable If   (('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_OK')) or ('${SO_COMPLETE}'=='TRUE')  TRUE
903     \    Exit For Loop If   ('${SO_COMPLETE}'=='TRUE')
904     \    Exit For Loop If   ('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_ERROR')
905     \    ${dist_status}=  Set Variable If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))  EXIT
906     \    Exit For Loop If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))
907     Should Be True   ( '${SO_COMPLETE}'=='TRUE')   SO Test
908
909 Get Catalog Service Distribution Details
910     [Documentation]    Gets ASDC Catalog Service distribution details
911     [Arguments]    ${catalog_service_distribution_id}
912     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}/${catalog_service_distribution_id}    ${ASDC_OPS_USER_ID}
913     Should Be Equal As Strings  ${resp.status_code}     200
914     [Return]    ${resp.json()}
915 Run ASDC Health Check
916     [Documentation]    Runs a ASDC health check
917     ${session}=    Create Session       asdc    ${ASDC_FE_ENDPOINT}
918     ${uuid}=    Generate UUID4
919     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
920     ${resp}=    Get Request     asdc    ${ASDC_HEALTH_CHECK_PATH}     headers=${headers}
921     # only test for HTTP 200 to determine SDC Health. SDC_DE_HEALTH is informational
922     Should Be Equal As Strings  ${resp.status_code}     200    SDC DOWN
923     ${SDC_DE_HEALTH}=    Catenate   DOWN
924     @{ITEMS}=    Copy List    ${resp.json()['componentsInfo']}
925     :FOR    ${ELEMENT}    IN    @{ITEMS}
926     \    Log    ${ELEMENT['healthCheckStatus']}
927     \    ${SDC_DE_HEALTH}  Set Variable If   (('DE' in '${ELEMENT['healthCheckComponent']}') and ('${ELEMENT['healthCheckStatus']}' == 'UP')) or ('${SDC_DE_HEALTH}'=='UP')  UP
928     Log To Console   (DMaaP:${SDC_DE_HEALTH})    no_newline=true
929 Run ASDC Get Request
930     [Documentation]    Runs an ASDC get request
931     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
932     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
933     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
934     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
935     ${uuid}=    Generate UUID4
936     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
937     ${resp}=    Get Request     asdc    ${data_path}     headers=${headers}
938     Log    Received response from asdc ${resp.text}
939     [Return]    ${resp}
940 Run ASDC Put Request
941     [Documentation]    Runs an ASDC put request
942     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
943     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
944     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
945     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
946     ${uuid}=    Generate UUID4
947     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
948     ${resp}=    Put Request     asdc    ${data_path}     data=${data}    headers=${headers}
949     Log    Received response from asdc ${resp.text}
950     [Return]    ${resp}
951
952 Run ASDC Post Files Request
953     [Documentation]    Runs an ASDC post request
954     [Arguments]    ${data_path}    ${files}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
955     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
956     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
957     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
958     ${uuid}=    Generate UUID4
959     ${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}
960     ${resp}=    Post Request    asdc    ${data_path}     files=${files}    headers=${headers}
961     Log    Received response from asdc ${resp.text}
962     [Return]    ${resp}
963
964 Run ASDC MD5 Post Request
965     [Documentation]    Runs an ASDC post request with MD5 Checksum header
966     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
967     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
968     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
969     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
970     ${uuid}=    Generate UUID4
971     ${data_string}=   Evaluate    json.dumps(${data})     json
972     ${md5checksum}=   Evaluate    md5.new('''${data_string}''').hexdigest()   modules=md5
973     ${base64md5checksum}=  Evaluate     base64.b64encode("${md5checksum}")     modules=base64
974     ${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}
975     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
976     Log    Received response from asdc ${resp.text}
977     [Return]    ${resp}
978
979 Run ASDC Post Request
980     [Documentation]    Runs an ASDC post request
981     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
982     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
983     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
984     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
985     ${uuid}=    Generate UUID4
986     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
987     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
988     Log    Received response from asdc ${resp.text}
989     [Return]    ${resp}
990
991 Run ASDC Delete Request
992     [Documentation]    Runs an ASDC delete request
993     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
994     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
995     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
996     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
997     ${uuid}=    Generate UUID4
998     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
999     ${resp}=    Delete Request  asdc    ${data_path}        headers=${headers}
1000     Log    Received response from asdc ${resp.text}
1001     [Return]    ${resp}
1002 Open ASDC GUI
1003     [Documentation]   Logs in to ASDC GUI
1004     [Arguments]    ${PATH}
1005     ## Setup Browever now being managed by the test case
1006     ##Setup Browser
1007     Go To    ${ASDC_FE_ENDPOINT}${PATH}
1008     Maximize Browser Window
1009
1010     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
1011     Log    Logging in to ${ASDC_FE_ENDPOINT}${PATH}
1012     Title Should Be    ASDC
1013     Wait Until Page Contains Element    xpath=//div/a[text()='SDC']    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
1014     Log    Logged in to ${ASDC_FE_ENDPOINT}${PATH}
1015
1016
1017 Create Multi Part
1018    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}
1019    ${fileData}=   Get Binary File  ${filePath}
1020    ${fileDir}  ${fileName}=  Split Path  ${filePath}
1021    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
1022    Set To Dictionary  ${addTo}  ${partName}=${partData}
1023