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