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