change properties to match what is in the new oom repo
[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    WITH NAME     ServiceMapping
14 Library           ONAPLibrary.Templating    WITH NAME    Templating
15 Library           ONAPLibrary.SDC    WITH NAME    SDC
16 Resource          global_properties.robot
17 Resource          browser_setup.robot
18
19 *** Variables ***
20 ${ASDC_DESIGNER_USER_ID}    cs0008
21 ${ASDC_TESTER_USER_ID}    jm0007
22 ${ASDC_GOVERNOR_USER_ID}    gv0001
23 ${ASDC_OPS_USER_ID}    op0001
24 ${ASDC_HEALTH_CHECK_PATH}    /sdc1/rest/healthCheck
25 ${ASDC_VENDOR_LICENSE_MODEL_PATH}    /onboarding-api/v1.0/vendor-license-models
26 ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}    /onboarding-api/v1.0/vendor-software-products
27 ${ASDC_VENDOR_KEY_GROUP_PATH}    /license-key-groups
28 ${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}    /entitlement-pools
29 ${ASDC_VENDOR_FEATURE_GROUP_PATH}    /feature-groups
30 ${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}    /license-agreements
31 ${ASDC_VENDOR_ACTIONS_PATH}    /actions
32 ${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}    /orchestration-template-candidate
33 ${ASDC_FE_CATALOG_RESOURCES_PATH}    /sdc1/feProxy/rest/v1/catalog/resources
34 ${ASDC_FE_CATALOG_SERVICES_PATH}    /sdc1/feProxy/rest/v1/catalog/services
35 ${ASDC_CATALOG_RESOURCES_PATH}    /sdc2/rest/v1/catalog/resources
36 ${ASDC_CATALOG_SERVICES_PATH}    /sdc2/rest/v1/catalog/services
37 ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}    /sdc2/rest/v1/inactiveComponents/resource
38 ${ASDC_CATALOG_RESOURCES_QUERY_PATH}    /sdc2/rest/v1/catalog/resources/resourceName
39 ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}    /sdc2/rest/v1/inactiveComponents/service
40 ${ASDC_CATALOG_LIFECYCLE_PATH}    /lifecycleState
41 ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}    /resourceInstance
42 ${ASDC_CATALOG_SERVICE_RESOURCE_ARTIFACT_PATH}    /artifacts
43 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}    /distribution-state
44 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    /distribution
45 ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    /approve
46 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    /distribution/PROD/activate
47 ${ASDC_LICENSE_MODEL_TEMPLATE}    asdc/license_model.jinja
48 ${ASDC_KEY_GROUP_TEMPLATE}    asdc/key_group.jinja
49 ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    asdc/entitlement_pool.jinja
50 ${ASDC_FEATURE_GROUP_TEMPLATE}    asdc/feature_group.jinja
51 ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    asdc/license_agreement.jinja
52 ${ASDC_ACTION_TEMPLATE}    asdc/action.jinja
53 ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    asdc/software_product.jinja
54 ${ASDC_ARTIFACT_UPLOAD_TEMPLATE}    asdc/artifact_upload.jinja
55 ${ASDC_CATALOG_RESOURCE_TEMPLATE}    asdc/catalog_resource.jinja
56 ${ASDC_USER_REMARKS_TEMPLATE}    asdc/user_remarks.jinja
57 ${ASDC_CATALOG_SERVICE_TEMPLATE}    asdc/catalog_service.jinja
58 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    asdc/resource_instance.jinja
59 ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    asdc/catalog_vnf_properties.jinja
60 ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    asdc/catalog_vnf_inputs.jinja
61 ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    asdc/catalog_net_input_properties.jinja
62 ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    asdc/catalog_resource_alloted_resource.jinja
63 ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    asdc/catalog_allotted_properties.jinja
64 ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    asdc/catalog_allotted_inputs.jinja
65 ${SDC_CATALOG_DEPLOYMENT_ARTIFACT_PATH}     robot/assets/asdc/blueprints/
66 ${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_FE_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
67 ${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
68 ${ASDC_BE_ONBOARD_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_ONBOARD_IP_ADDR}:${GLOBAL_ASDC_BE_ONBOARD_PORT}
69
70 *** Keywords ***
71 Distribute Model From ASDC
72     [Documentation]    Goes end to end creating all the ASDC objects based ONAP model and distributing it to the systems. It then returns the service name, VF name and VF module name
73     [Arguments]    ${model_zip_path}   ${catalog_service_name}=    ${cds}=False    ${service}=
74     # For Testing use random service names
75     #${random}=    Get Current Date
76     #${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}_${random}
77     ${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
78     ${catalog_resource_ids}=    Create List
79     ${catalog_resources}=   Create Dictionary
80     #####  TODO: Support for Multiple resources of one type in a service  ######
81     #   The zip list is the resources - no mechanism to indicate more than 1 of the items in the zip list
82     #   Get Service Vnf Mapping  has the logical mapping but it is not the same key as model_zip_path
83     #   ${vnflist}=   Get Service Vnf Mapping    alias    ${service}
84     #   Save the resource_id in a dictionary keyed by the resource name in the zipfile name (vFWDT_vFWSNK.zip or vFWDT_vPKG.zip)
85     #   Create the resources but do not immediately add resource
86     #   Add Resource to Service in a separate FOR loop
87     ${resource_types}=   Create Dictionary
88
89     :FOR    ${zip}     IN     @{model_zip_path}
90     \    ${loop_catalog_resource_id}=    Setup ASDC Catalog Resource    ${zip}    ${cds}
91     #     zip can be vFW.zip or vFWDT_VFWSNK.zip
92     \    ${resource_type_match}=    Get Regexp Matches    ${zip}   ${service}_(.*)\.zip    1
93     #  Need to be able to distribute preload for vFWCL vFWSNK and vFWDT vFWSNK to prepend service to vnf_type
94     \    ${resource_type_string}=   Set Variable If   len(${resource_type_match})==0    ${service}    ${service}${resource_type_match[0]}
95     \    Set To Dictionary    ${resource_types}    ${resource_type_string}    ${loop_catalog_resource_id}   
96     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
97
98     ServiceMapping.Set Directory    default    ${GLOBAL_SERVICE_MAPPING_DIRECTORY}
99     ${vnflist}=    ServiceMapping.Get Service Vnf Mapping    default    ${service}
100
101     # Spread the icons on the pallette starting on the left
102     ${xoffset}=    Set Variable    ${0}
103
104     :FOR  ${vnf}   IN   @{vnflist}
105     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource      ${resource_types['${vnf}']}
106     \    Set To Dictionary    ${catalog_resources}   ${resource_types['${vnf}']}=${loop_catalog_resource_resp}
107     \    ${catalog_resource_unique_name}=   Add ASDC Resource Instance    ${catalog_service_id}    ${resource_types['${vnf}']}    ${loop_catalog_resource_resp['name']}    ${xoffset}
108     \    ${xoffset}=   Set Variable   ${xoffset+100}
109     #
110     # do this here because the loop_catalog_resource_resp is different format after adding networks
111     ${vf_module}=   Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
112     #
113     #  do network
114     ${networklist}=    ServiceMapping.Get Service Neutron Mapping    default    ${service}
115     ${generic_neutron_net_uuid}=   Get Generic NeutronNet UUID
116     :FOR   ${network}   IN   @{networklist}
117     \    ${loop_catalog_resource_id}=   Set Variable    ${generic_neutron_net_uuid}
118     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
119     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
120     \    ${loop_catalog_resource_id}=   Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${network}    ${xoffset}      ${0}    VL
121     \    ${nf_role}=   Convert To Lowercase   ${network}
122     \    Setup SDC Catalog Resource GenericNeutronNet Properties      ${catalog_service_id}    ${nf_role}   ${loop_catalog_resource_id}
123     \    ${xoffset}=   Set Variable   ${xoffset+100}
124     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
125     ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
126     #
127     # do deployment artifacts
128     #
129     ${deploymentlist}=    ServiceMapping.Get Service Deployment Artifact Mapping    default    ${service}
130     :FOR  ${deployment}  IN   @{deploymentlist}
131     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
132     \    Setup SDC Catalog Resource Deployment Artifact Properties      ${catalog_service_id}   ${loop_catalog_resource_resp}  ${catalog_resource_unique_name}  ${deployment}
133     Run Keyword If  ${cds} == True  Add CDS Parameters  ${catalog_service_name}
134     Checkin ASDC Catalog Service    ${catalog_service_id}
135     Wait Until Keyword Succeeds    600s    15s    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 UUID4
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    ${\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}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['invariantUUID']}
182     ${tunnelxconn_uuid}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['UUID']}
183     ${tunnelxconn_node_type}=    Catenate    ${vcpe_ar_data_file.json()['tunnelxconn']['node_type']}
184     ${brg_invariant_uuid}=    Catenate    ${vcpe_ar_data_file.json()['brg']['invariantUUID']}
185     ${brg_uuid}=    Catenate    ${vcpe_ar_data_file.json()['brg']['UUID']}
186     ${brg_node_type}=    Catenate    ${vcpe_ar_data_file.json()['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 Allotted 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    ${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}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/filteredDataByParams?include=toscaArtifacts    ${ASDC_DESIGNER_USER_ID}        auth=${GLOBAL_ASDC_AUTHENTICATION}
256    ${csar_resource_id}=    Set Variable   ${resp.json()['toscaArtifacts']['assettoscacsar']['uniqueId']}
257    ${resp}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/artifacts/${csar_resource_id}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
258    ${csar_file_name}=   Set Variable    ${resp.json()['artifactName']}
259    ${base64Obj}=   Set Variable    ${resp.json()['base64Contents']}
260    ${binObj}=   Base64 Decode   ${base64Obj}
261    Create Binary File  ${save_directory}/${csar_file_name}  ${binObj}
262    Log      ${\n}Downloaded:${csar_file_name}
263
264
265 Get Generic NeutronNet UUID
266    [Documentation]   Look up the UUID of the Generic NeutronNetwork Resource
267    ${resp}=    SDC.Run Get Request   ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_QUERY_PATH}/Generic%20NeutronNet/resourceVersion/1.0   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
268    [Return]    ${resp.json()['allVersions']['1.0']}
269
270 Get AllottedResource UUID
271    [Documentation]   Look up the UUID of the Allotted Resource
272    # if this fails then the AllottedResource template got deleted from SDC by mistake
273    ${resp}=    SDC.Run Get Request   ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_QUERY_PATH}/AllottedResource/resourceVersion/1.0   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
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}=None
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     ${blueprint_data}    OperatingSystem.Get File    ${SDC_CATALOG_DEPLOYMENT_ARTIFACT_PATH}${blueprint_file}
325     ${payloadData}=      Base64 Encode   ${blueprint_data}
326     ${dict}=    Create Dictionary  artifactLabel=blueprint  artifactName=${blueprint_file}   artifactType=DCAE_INVENTORY_BLUEPRINT  artifactGroupType=DEPLOYMENT  description=${blueprint_file}   payloadData=${payloadData}
327     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
328     ${data}=   Templating.Apply Template    sdc   ${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}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${artifact_upload_path}    ${data}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
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     \    Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
362     \    ${data}=   Templating.Apply Template    sdc   ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    ${dict}
363     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_parent_service_id}    ${catalog_service_id}    ${data}
364
365
366 Setup SDC Catalog Resource AllottedResource Properties
367     [Documentation]    Set up Allotted Resource properties and inputs
368     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}   ${invariantUUID}   ${UUID}     ${node_type}
369     # Set component instances properties
370     ${nf_role_lc}=   Convert To Lowercase   ${nf_role}
371     ${resp}=    Get ASDC Catalog Resource Component Instances Properties For Resource     ${catalog_resource_id}
372     ${componentInstances}  Set Variable   @{resp['componentInstancesProperties']}
373     # componentInstances can have 1 or more than 1 entry
374     ${passed}=    Run Keyword And Return Status   Evaluate    type(${componentInstances})
375     ${type}=      Run Keyword If     ${passed}    Evaluate    type(${componentInstances})
376     ${componentInstancesList}=    Run Keyword If   "${type}"!="<type 'list'>"    Create List  ${componentInstances}
377     ...    ELSE   Set Variable    ${componentInstances}
378     :FOR   ${item}  IN   @{componentInstancesList}
379     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${item}     ${nf_role_lc}
380     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
381     \    ${componentInstance1}=   Set Variable    ${item}
382     ${dict}=    Create Dictionary
383     :FOR    ${comp}    IN    @{resp['componentInstancesProperties']["${componentInstance1}"]}
384     \    ${name}    Set Variable   ${comp['name']}
385     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain Any     ${name}    network_role  providing_service_invariant_uuid  providing_service_uuid  providing_service_name   uniqueId
386     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
387     \    ${parentUniqueId}    Set Variable    ${comp['parentUniqueId']}
388     \    ${ownerId}    Set Variable    ${comp['ownerId']}
389     \    Set To Dictionary     ${dict}    parentUniqueId=${parentUniqueId}   ownerId=${ownerId}
390     \    Run Keyword If   '${name}'=='providing_service_invariant_uuid'   Set To Dictionary    ${dict}    providing_service_invariant_uuid=${invariantUUID}
391     \    Run Keyword If   '${name}'=='providing_service_uuid'   Set To Dictionary    ${dict}    providing_service_uuid=${UUID}
392     \    Run Keyword If   '${name}'=='providing_service_name'   Set To Dictionary    ${dict}    providing_service_name=${node_type}
393     #    Sets it for each loop but should be one
394     \    ${uniqueId}    Set Variable     ${comp['uniqueId']}
395     \    ${uniqueId}   Fetch From Left   ${uniqueId}   .
396     \    Set To Dictionary    ${dict}    uniqueId=${uniqueId}
397     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
398     ${data}=   Templating.Apply Template    sdc   ${SDC_CATALOG_ALLOTTED_RESOURCE_PROPERTIES_TEMPLATE}    ${dict}
399     ${response}=    Set ASDC Catalog Resource Component Instance Properties For Resource    ${catalog_resource_id}    ${componentInstance1}    ${data}
400     Log    resp=${response}
401
402
403 Setup SDC Catalog Resource AllottedResource Inputs
404     [Documentation]    Set up Allotted Resource inputs
405     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_resource_id}
406     # Set vnf inputs
407     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
408     ${dict}=    Create Dictionary
409     :FOR    ${comp}    IN    @{resp['inputs']}
410     \    ${name}    Set Variable    ${comp['name']}
411     \    ${uid}    Set Variable    ${comp['uniqueId']}
412     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=${nf_role}    nf_type_uid=${uid}
413     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=${nf_role}   nf_role_uid=${uid}
414     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
415     ${data}=   Templating.Apply Template    sdc   ${SDC_CATALOG_ALLOTTED_RESOURCE_INPUTS_TEMPLATE}    ${dict}
416     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
417     [Return]    ${response}
418
419 Setup ASDC Catalog Resource CDS Properties
420     [Documentation]    Set up vfwng VNF properties and inputs for CDS
421     [Arguments]    ${catalog_resource_id}
422     # Set vnf module properties
423     ${resp}=    Get ASDC Catalog Resource Component Instances   ${catalog_resource_id}
424     :FOR    ${comp}    IN    @{resp['componentInstances']}
425     \    ${name}    Set Variable   ${comp['name']}
426     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
427     \    ${actualComponentUid}    Set Variable    ${comp['actualComponentUid']}
428     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    abstract_
429     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
430     \    ${response}=    Get ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${actualComponentUid}
431     \    ${dict}=    Create Dictionary    parent_id=${response[6]['parentUniqueId']}
432     \    Run Keyword If   '${name}'=='abstract_vfw'   Set To Dictionary    ${dict}    nfc_function=vfw    nfc_naming_policy=SDNC_Policy.ONAP_VFW_NAMING_TIMESTAMP
433     \    Run Keyword If   '${name}'=='abstract_vpg'   Set To Dictionary    ${dict}    nfc_function=vpg    nfc_naming_policy=SDNC_Policy.ONAP_VPG_NAMING_TIMESTAMP
434     \    Run Keyword If   '${name}'=='abstract_vsn'   Set To Dictionary    ${dict}    nfc_function=vsn    nfc_naming_policy=SDNC_Policy.ONAP_VSN_NAMING_TIMESTAMP
435     \    Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
436     \    ${data}=   Templating.Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    ${dict}
437     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${data}
438     \    Log    resp=${response}
439
440     # Set vnf inputs
441     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
442     ${dict}=    Create Dictionary
443     :FOR    ${comp}    IN    @{resp['inputs']}
444     \    ${name}    Set Variable    ${comp['name']}
445     \    ${uid}    Set Variable    ${comp['uniqueId']}
446     \    Run Keyword If    '${name}'=='nf_function'    Set To Dictionary    ${dict}    nf_function=ONAP-FIREWALL    nf_function_uid=${uid}
447     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=FIREWALL    nf_type_uid=${uid}
448     \    Run Keyword If    '${name}'=='nf_naming_code'    Set To Dictionary    ${dict}    nf_naming_code=vfw    nf_naming_code_uid=${uid}
449     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=vFW    nf_role_uid=${uid}
450     \    Run Keyword If    '${name}'=='cloud_env'    Set To Dictionary    ${dict}    cloud_env=openstack    cloud_env_uid=${uid}
451     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
452     ${data}=   Templating.Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    ${dict}
453     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
454
455 Add ASDC License Model
456     [Documentation]    Creates an ASDC License Model and returns its id
457     ${uuid}=    Generate UUID4
458     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
459     ${map}=    Create Dictionary    vendor_name=${shortened_uuid}
460     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
461     ${data}=   Templating.Apply Template    sdc   ${ASDC_LICENSE_MODEL_TEMPLATE}    ${map}
462     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}      auth=${GLOBAL_ASDC_AUTHENTICATION}
463     Should Be Equal As Strings  ${resp.status_code}     200
464     [Return]    ${resp.json()['itemId']}    ${resp.json()['version']['id']}
465     
466 Get ASDC License Model
467     [Documentation]    gets an asdc license model by its id
468     [Arguments]    ${id}   ${version_id}=0.1
469     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
470     [Return]    ${resp.json()}
471
472 Get ASDC License Models
473     [Documentation]    Gets all ASDC License Models
474     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
475     [Return]    ${resp.json()}
476
477 Checkin ASDC License Model
478     [Documentation]    Checks in an ASDC License Model by its id
479     [Arguments]    ${id}   ${version_id}=0.1
480     ${map}=    Create Dictionary    action=Checkin
481     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
482     ${data}=   Templating.Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
483     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
484     Should Be Equal As Strings  ${resp.status_code}     200
485     [Return]    ${resp.json()}
486
487 Submit ASDC License Model
488     [Documentation]    Submits an ASDC License Model by its id
489     [Arguments]    ${id}   ${version_id}=0.1
490     ${map}=    Create Dictionary    action=Submit
491     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
492     ${data}=   Templating.Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
493     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
494     [Return]    ${resp.json()}
495
496 Checkin ASDC Software Product
497     [Documentation]    Checks in an ASDC Software Product by its id
498     [Arguments]    ${id}   ${version_id}=0.1
499     ${map}=    Create Dictionary    action=Checkin
500     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
501     ${data}=   Templating.Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
502     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
503     Should Be Equal As Strings  ${resp.status_code}     200
504     [Return]    ${resp.json()}
505
506 Validate ASDC Software Product
507     [Documentation]    Validates an ASDC Software Product by its id
508     [Arguments]    ${id}   ${version_id}=0.1
509     ${data}=   Catenate
510     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}/orchestration-template-candidate/process    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
511     Should Be Equal As Strings  ${resp.status_code}     200
512     [Return]    ${resp.json()}
513
514 Submit ASDC Software Product
515     [Documentation]    Submits an ASDC Software Product by its id
516     [Arguments]    ${id}   ${version_id}=0.1
517     ${map}=    Create Dictionary    action=Submit
518     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
519     ${data}=   Templating.Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
520     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
521     Should Be Equal As Strings  ${resp.status_code}     200
522     [Return]    ${resp.json()}
523
524 Package ASDC Software Product
525     [Documentation]    Creates a package of an ASDC Software Product by its id
526     [Arguments]    ${id}   ${version_id}=0.1
527     ${map}=    Create Dictionary    action=Create_Package
528     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
529     ${data}=   Templating.Apply Template    sdc   ${ASDC_ACTION_TEMPLATE}    ${map}
530     ${resp}=    SDC.Run Put Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}      auth=${GLOBAL_ASDC_AUTHENTICATION}
531     Should Be Equal As Strings  ${resp.status_code}     200
532     [Return]    ${resp.json()}
533
534 Add ASDC Entitlement Pool
535     [Documentation]    Creates an ASDC Entitlement Pool and returns its id
536     [Arguments]    ${license_model_id}   ${version_id}=0.1     ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
537     ${uuid}=    Generate UUID4
538     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
539     ${map}=    Create Dictionary    entitlement_pool_name=${shortened_uuid}  license_start_date=${license_start_date}  license_end_date=${license_end_date}
540     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
541     ${data}=   Templating.Apply Template    sdc   ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    ${map}
542     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}      auth=${GLOBAL_ASDC_AUTHENTICATION}
543     Should Be Equal As Strings  ${resp.status_code}     200
544     [Return]    ${resp.json()['value']}
545
546 Get ASDC Entitlement Pool
547     [Documentation]    Gets an ASDC Entitlement Pool by its id
548     [Arguments]    ${license_model_id}    ${pool_id}
549     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}/${pool_id}  ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
550     [Return]    ${resp.json()}
551
552 Add ASDC License Group
553     [Documentation]    Creates an ASDC License Group and returns its id
554     [Arguments]    ${license_model_id}   ${version_id}=1.0   ${license_start_date}="01/01/1960"   ${license_end_date}="01/01/1961"
555     ${uuid}=    Generate UUID4
556     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
557     ${map}=    Create Dictionary    key_group_name=${shortened_uuid}   license_start_date=${license_start_date}  license_end_date=${license_end_date}
558     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
559     ${data}=   Templating.Apply Template    sdc   ${ASDC_KEY_GROUP_TEMPLATE}    ${map}
560     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}     ${data}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
561     Should Be Equal As Strings  ${resp.status_code}     200
562     [Return]    ${resp.json()['value']}
563
564 Get ASDC License Group
565     [Documentation]    Gets an ASDC License Group by its id
566     [Arguments]    ${license_model_id}    ${group_id}      ${version_id}
567     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
568     [Return]    ${resp.json()}
569
570 Add ASDC Feature Group
571     [Documentation]    Creates an ASDC Feature Group and returns its id
572     [Arguments]    ${license_model_id}    ${key_group_id}    ${entitlement_pool_id}      ${version_id}=0.1
573     ${uuid}=    Generate UUID4
574     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
575     ${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}
576     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
577     ${data}=   Templating.Apply Template    sdc   ${ASDC_FEATURE_GROUP_TEMPLATE}    ${map}
578     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   auth=${GLOBAL_ASDC_AUTHENTICATION}
579     Should Be Equal As Strings  ${resp.status_code}     200
580     [Return]    ${resp.json()['value']}
581
582 Get ASDC Feature Group
583     [Documentation]    Gets an ASDC Feature Group by its id
584     [Arguments]    ${license_model_id}    ${group_id}
585     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
586     [Return]    ${resp.json()}
587
588 Add ASDC License Agreement
589     [Documentation]    Creates an ASDC License Agreement and returns its id
590     [Arguments]    ${license_model_id}    ${feature_group_id}      ${version_id}=0.1
591     ${uuid}=    Generate UUID4
592     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
593     ${map}=    Create Dictionary    license_agreement_name=${shortened_uuid}    feature_group_id=${feature_group_id}
594     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
595     ${data}=   Templating.Apply Template    sdc   ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    ${map}
596     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}     auth=${GLOBAL_ASDC_AUTHENTICATION}
597     Should Be Equal As Strings  ${resp.status_code}     200
598     [Return]    ${resp.json()['value']}
599
600 Get ASDC License Agreement
601     [Documentation]    Gets an ASDC License Agreement by its id
602     [Arguments]    ${license_model_id}    ${agreement_id}
603     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}/${agreement_id}   ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
604     [Return]    ${resp.json()}
605
606 Add ASDC Software Product
607     [Documentation]    Creates an ASDC Software Product and returns its id
608     [Arguments]    ${license_agreement_id}    ${feature_group_id}    ${license_model_name}    ${license_model_id}   ${license_model_version_id}  ${name_prefix}
609     ${uuid}=    Generate UUID4
610     ${shortened_uuid}=     Evaluate    str("${uuid}")[:13]
611     ${software_product_name}=  Catenate   ${name_prefix}   ${shortened_uuid}
612     ${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}
613     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
614     ${data}=   Templating.Apply Template    sdc   ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    ${map}
615     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   auth=${GLOBAL_ASDC_AUTHENTICATION}
616     Should Be Equal As Strings  ${resp.status_code}     200
617     [Return]    ${resp.json()['itemId']}   ${resp.json()['version']['id']}
618
619 Get ASDC Software Product
620     [Documentation]    Gets an ASDC Software Product by its id
621     [Arguments]    ${software_product_id}   ${version_id}=0.1
622     ${resp}=    SDC.Run Get Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}     auth=${GLOBAL_ASDC_AUTHENTICATION}
623     [Return]    ${resp.json()}
624
625 Add ASDC Catalog Resource
626     [Documentation]    Creates an ASDC Catalog Resource and returns its id
627     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}
628     ${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}
629     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
630     ${data}=   Templating.Apply Template    sdc   ${ASDC_CATALOG_RESOURCE_TEMPLATE}    ${map}
631     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
632     Should Be Equal As Strings  ${resp.status_code}     201
633     [Return]    ${resp.json()['uniqueId']}
634
635 Add ASDC Allotted Resource Catalog Resource
636     [Documentation]    Creates an ASDC Allotted Resource Catalog Resource and returns its id
637     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}   ${subcategory}
638     ${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}
639     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
640     ${data}=   Templating.Apply Template    sdc   ${ASDC_ALLOTTED_RESOURCE_CATALOG_RESOURCE_TEMPLATE}    ${map}
641     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
642     Should Be Equal As Strings  ${resp.status_code}     201
643     [Return]    ${resp.json()['uniqueId']}
644
645 Mark ASDC Catalog Resource Inactive
646     [Documentation]    Marks ASDC Catalog Resource as inactive
647     [Arguments]    ${catalog_resource_id}
648     ${resp}=    SDC.Run Delete Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}     ${None}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
649     Should Be Equal As Strings  ${resp.status_code}     204
650     [Return]    ${resp}
651
652 Delete Inactive ASDC Catalog Resources
653     [Documentation]    Delete all ASDC Catalog Resources that are inactive
654     ${resp}=    SDC.Run Delete Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}     ${None}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
655     Should Be Equal As Strings  ${resp.status_code}     200
656     [Return]    ${resp.json()}
657
658 Get ASDC Catalog Resource
659     [Documentation]    Gets an ASDC Catalog Resource by its id
660     [Arguments]    ${catalog_resource_id}
661     ${resp}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}   ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
662     [Return]    ${resp.json()}
663
664 Get ASDC Catalog Resource Component Instances
665     [Documentation]    Gets component instances of an ASDC Catalog Resource by its id
666     [Arguments]    ${catalog_resource_id}
667     ${resp}=    SDC.Run Get Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
668     [Return]    ${resp.json()}
669
670 Get ASDC Catalog Resource Deployment Artifact Properties
671     [Documentation]    Gets deployment artifact properties of an ASDC Catalog Resource by its id
672     [Arguments]    ${catalog_resource_id}
673     ${resp}=    SDC.Run Get Request    ${ASDC_FE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=deploymentArtifacts    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
674     [Return]    ${resp.json()}
675
676
677 Get ASDC Catalog Resource Component Instances Properties
678     [Documentation]    Gets ASDC Catalog Resource component instances properties by its id
679     [Arguments]    ${catalog_resource_id}
680     ${resp}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
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}=    SDC.Run Get Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
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}=    SDC.Run Get Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=inputs    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
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}=    SDC.Run Get Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/componentInstances/${component_instance_id}/${component_id}/inputs    ${ASDC_DESIGNER_USER_ID}auth=${GLOBAL_ASDC_AUTHENTICATION}
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}=    SDC.Run Post Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_SERVICES_PATH}/${component_parent_service_id}/resourceInstance/${catalog_resource_id}/properties    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
705     [Return]   ${resp.json()}
706
707 Set ASDC Catalog Resource Component Instance Properties For Resource
708     [Documentation]    Sets ASDC Resource component instance properties by ids
709     [Arguments]    ${catalog_parent_resource_id}    ${catalog_resource_id}    ${data}
710     ${resp}=    SDC.Run Post Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_parent_resource_id}/resourceInstance/${catalog_resource_id}/properties   ${data}    ${ASDC_DESIGNER_USER_ID}   auth=${GLOBAL_ASDC_AUTHENTICATION}
711     [Return]   ${resp.json()}
712
713 Set CDS Catalog Resource Component Instance Properties
714     [Documentation]    Sets CDS Catalog Resource component instance properties by ids
715     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${data}
716     ${resp}=    SDC.Run Post Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/resourceInstance/${component_instance_id}/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
717     [Return]    ${resp.json()}
718
719 Set ASDC Catalog Resource VNF Inputs
720     [Documentation]    Sets VNF Inputs for an ASDC Catalog Resource by its id
721     [Arguments]    ${catalog_resource_id}    ${data}
722     ${resp}=    SDC.Run Post Request    ${ASDC_FE_ENDPOINT}    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/update/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
723     [Return]    ${resp.json()}
724
725 Get SDC Demo Vnf Catalog Resource
726     [Documentation]  Gets Resource ids of demonstration VNFs for instantiation
727     [Arguments]    ${service_name}
728     ${resp}=   SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/serviceName/${service_name}/serviceVersion/1.0    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
729     @{ITEMS}=    Copy List    ${resp.json()['componentInstances']}
730     ${demo_catalog_resource}=   Create Dictionary
731     :FOR    ${ELEMENT}    IN    @{ITEMS}
732     \    Log    ${ELEMENT['name']}
733     \    Log    ${ELEMENT['groupInstances'][0]['groupName']}
734     \    ${vnf}=   Get VNF From Group Name     ${ELEMENT['groupInstances'][0]['groupName']}     ${service_name}
735     \    ${vnf_data}=    Create Dictionary    vnf_type=${ELEMENT['name']}  vf_module=${ELEMENT['groupInstances'][0]['groupName']}
736     \    LOG     ${vnf_data}
737     \    Set To Dictionary    ${demo_catalog_resource}    ${vnf}=${vnf_data}
738     \    LOG     ${demo_catalog_resource}
739     [Return]    ${demo_catalog_resource}
740
741 Get VNF From Group Name
742     [Documentation]   Looks up VNF key from service mapping for a regex on group_name and service_name
743     [Arguments]   ${group_name}    ${service_name}
744     ${vnf}=   Set Variable If
745     ...                      ('${service_name}'=='demoVFWCL') and ('base_vfw' in '${group_name}')   vFWCLvFWSNK
746     ...                      ('${service_name}'=='demoVFWCL') and ('base_vpkg' in '${group_name}')   vFWCLvPKG
747     ...                      ('${service_name}'=='demoVLB') and ('base_vlb' in '${group_name}')   vLB
748     [Return]   ${vnf}
749
750 Checkin ASDC Catalog Resource
751     [Documentation]    Checks in an ASDC Catalog Resource by its id
752     [Arguments]    ${catalog_resource_id}
753     ${map}=    Create Dictionary    user_remarks=Robot remarks
754     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
755     ${data}=   Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
756     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    auth=${GLOBAL_ASDC_AUTHENTICATION}
757     Should Be Equal As Strings  ${resp.status_code}     200
758     [Return]    ${resp.json()}
759
760 Request Certify ASDC Catalog Resource
761     [Documentation]    Requests certification of an ASDC Catalog Resource by its id
762     [Arguments]    ${catalog_resource_id}
763     ${map}=    Create Dictionary    user_remarks=Robot remarks
764     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
765     ${data}=   Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
766     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
767     Should Be Equal As Strings  ${resp.status_code}     200
768     [Return]    ${resp.json()}
769
770 Start Certify ASDC Catalog Resource
771     [Documentation]    Start certification of an ASDC Catalog Resource by its id
772     [Arguments]    ${catalog_resource_id}
773     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
774     Should Be Equal As Strings  ${resp.status_code}     200
775     [Return]    ${resp.json()}
776
777 Certify ASDC Catalog Resource
778     [Documentation]    Certifies an ASDC Catalog Resource by its id and returns the new id
779     [Arguments]    ${catalog_resource_id}    ${user_id}=${ASDC_TESTER_USER_ID}
780     ${map}=    Create Dictionary    user_remarks=Robot remarks
781     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
782     ${data}=   Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
783     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${user_id}    auth=${GLOBAL_ASDC_AUTHENTICATION}
784     Should Be Equal As Strings  ${resp.status_code}     200
785     [Return]    ${resp.json()['uniqueId']}
786
787 Upload ASDC Heat Package
788     [Documentation]    Creates an ASDC Software Product and returns its id
789     [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
790     ${files}=     Create Dictionary
791     Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
792     ${resp}=    SDC.Run Post Files Request    ${ASDC_BE_ONBOARD_ENDPOINT}    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}     ${files}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
793     Should Be Equal As Strings      ${resp.status_code}     200
794
795 Add ASDC Catalog Service
796     [Documentation]    Creates an ASDC Catalog Service and returns its id
797     [Arguments]   ${catalog_service_name}
798     ${uuid}=    Generate UUID4
799     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
800     ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
801     ${map}=    Create Dictionary    service_name=${catalog_service_name}
802     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
803     ${data}=   Templating.Apply Template    sdc   ${ASDC_CATALOG_SERVICE_TEMPLATE}    ${map}
804     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
805     Should Be Equal As Strings  ${resp.status_code}     201
806     [Return]    ${resp.json()['uniqueId']}
807
808 Mark ASDC Catalog Service Inactive
809     [Documentation]    Deletes an ASDC Catalog Service
810     [Arguments]    ${catalog_service_id}
811     ${resp}=    SDC.Run Delete Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}     ${None}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
812     Should Be Equal As Strings  ${resp.status_code}     204
813     [Return]    ${resp}
814
815 Delete Inactive ASDC Catalog Services
816     [Documentation]    Delete all ASDC Catalog Services that are inactive
817     ${resp}=    SDC.Run Delete Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}     ${None}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
818     Should Be Equal As Strings  ${resp.status_code}     200
819     [Return]    ${resp.json()}
820
821 Get ASDC Catalog Service
822     [Documentation]    Gets an ASDC Catalog Service by its id
823     [Arguments]    ${catalog_service_id}
824     ${resp}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
825     [Return]    ${resp.json()}
826
827 Checkin ASDC Catalog Service
828     [Documentation]    Checks in an ASDC Catalog Service by its id
829     [Arguments]    ${catalog_service_id}
830     ${map}=    Create Dictionary    user_remarks=Robot remarks
831     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
832     ${data}=  Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
833     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
834     Should Be Equal As Strings  ${resp.status_code}     200
835     [Return]    ${resp.json()}
836
837 Request Certify ASDC Catalog Service
838     [Documentation]    Requests certification of an ASDC Catalog Service by its id
839     [Arguments]    ${catalog_service_id}
840     ${map}=    Create Dictionary    user_remarks=Robot remarks
841     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
842     ${data}=  Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
843     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
844     Should Be Equal As Strings  ${resp.status_code}     200
845     [Return]    ${resp.json()}
846
847 Start Certify ASDC Catalog Service
848     [Documentation]    Start certification of an ASDC Catalog Service by its id
849     [Arguments]    ${catalog_service_id}
850     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
851     Should Be Equal As Strings  ${resp.status_code}     200
852     [Return]    ${resp.json()}
853
854 Certify ASDC Catalog Service
855     [Documentation]    Certifies an ASDC Catalog Service by its id and returns the new id
856     [Arguments]    ${catalog_service_id}
857     ${map}=    Create Dictionary    user_remarks=Robot remarks
858     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
859     ${data}=  Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
860     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
861     Should Be Equal As Strings  ${resp.status_code}     200
862     [Return]    ${resp.json()['uniqueId']}
863
864 Approve ASDC Catalog Service
865     [Documentation]    Approves an ASDC Catalog Service by its id
866     [Arguments]    ${catalog_service_id}
867     ${map}=    Create Dictionary    user_remarks=Robot remarks
868     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
869     ${data}=   Templating.Apply Template    sdc   ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
870     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    ${data}    ${ASDC_GOVERNOR_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
871     Should Be Equal As Strings  ${resp.status_code}     200
872     [Return]    ${resp.json()}
873     
874 Distribute ASDC Catalog Service
875     [Documentation]    distribute an asdc Catalog Service by its id
876     [Arguments]    ${catalog_service_id}
877     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    ${None}    ${ASDC_OPS_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
878     Should Be Equal As Strings  ${resp.status_code}     200
879     [Return]    ${resp.json()}
880
881 Add ASDC Resource Instance
882     [Documentation]    Creates an ASDC Resource Instance and returns its id
883     [Arguments]    ${catalog_service_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}   ${resourceType}=VF
884     ${milli_timestamp}=    Generate Timestamp
885     ${xoffset}=    Set Variable   ${xoffset+306}
886     ${yoffset}=    Set Variable   ${yoffset+248}
887     ${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}
888     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
889     ${data}=   Templating.Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
890     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
891     Should Be Equal As Strings  ${resp.status_code}     201
892     [Return]    ${resp.json()['uniqueId']}
893
894 Add ASDC Resource Instance To Resource
895     [Documentation]    Creates an ASDC Resource Instance in a Resource (VF) and returns its id
896     [Arguments]    ${parent_catalog_resource_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}    ${resourceType}=VF
897     ${milli_timestamp}=    Generate Timestamp
898     ${xoffset}=    Set Variable   ${xoffset+306}
899     ${yoffset}=    Set Variable   ${yoffset+248}
900     ${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}
901     Templating.Create Environment    sdc    ${GLOBAL_TEMPLATE_FOLDER}
902     ${data}=  Templating.Apply Template    sdc   ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
903     ${resp}=    SDC.Run Post Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_RESOURCES_PATH}/${parent_catalog_resource_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
904     Should Be Equal As Strings  ${resp.status_code}     201
905     [Return]    ${resp.json()['uniqueId']}
906
907 Get Catalog Service Distribution
908     [Documentation]    Gets an ASDC Catalog Service distribution
909     [Arguments]    ${catalog_service_uuid}
910     ${resp}=    SDC.Run Get Request   ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_uuid}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    ${ASDC_OPS_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
911     Should Be Equal As Strings  ${resp.status_code}     200
912     [Return]    ${resp.json()}
913
914 Check Catalog Service Distributed
915     [Documentation]    Checks if an ASDC Catalog Service is distributed
916     [Arguments]    ${catalog_service_uuid}    ${dist_status}
917     ${dist_resp}=    Get Catalog Service Distribution    ${catalog_service_uuid}
918     Should Be Equal As Strings  ${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']}         Distributed
919     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
920     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
921     Should Not Be Empty   ${ITEMS}
922     ${SO_COMPLETE}   Set Variable   FALSE
923     ${dist_status}   Set Variable   CONTINUE
924     Should Not Be Empty   ${ITEMS}
925     :FOR    ${ELEMENT}    IN    @{ITEMS}
926     \    Log    ${ELEMENT['omfComponentID']}
927     \    Log    ${ELEMENT['status']}
928     \    ${SO_COMPLETE}   Set Variable If   (('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_OK')) or ('${SO_COMPLETE}'=='TRUE')  TRUE
929     \    Exit For Loop If   ('${SO_COMPLETE}'=='TRUE')
930     \    Exit For Loop If   ('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_ERROR')
931     \    ${dist_status}=  Set Variable If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))  EXIT
932     \    Exit For Loop If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))
933     Should Be True   ( '${SO_COMPLETE}'=='TRUE')   SO Test
934
935 Get Catalog Service Distribution Details
936     [Documentation]    Gets ASDC Catalog Service distribution details
937     [Arguments]    ${catalog_service_distribution_id}
938     ${resp}=    SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}/${catalog_service_distribution_id}    ${ASDC_OPS_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
939     Should Be Equal As Strings  ${resp.status_code}     200
940     [Return]    ${resp.json()}
941     
942 Run ASDC Health Check
943     [Documentation]    Runs a ASDC health check
944     ${resp}=    SDC.Run Get Request     ${ASDC_FE_ENDPOINT}    ${ASDC_HEALTH_CHECK_PATH}    user=${None}
945     # only test for HTTP 200 to determine SDC Health. SDC_DE_HEALTH is informational
946     Should Be Equal As Strings  ${resp.status_code}     200    SDC DOWN
947     ${SDC_DE_HEALTH}=    Catenate   DOWN
948     @{ITEMS}=    Copy List    ${resp.json()['componentsInfo']}
949     :FOR    ${ELEMENT}    IN    @{ITEMS}
950     \    Log    ${ELEMENT['healthCheckStatus']}
951     \    ${SDC_DE_HEALTH}  Set Variable If   (('DE' in '${ELEMENT['healthCheckComponent']}') and ('${ELEMENT['healthCheckStatus']}' == 'UP')) or ('${SDC_DE_HEALTH}'=='UP')  UP
952     Log   (DMaaP:${SDC_DE_HEALTH})
953
954 Open ASDC GUI
955     [Documentation]   Logs in to ASDC GUI
956     [Arguments]    ${PATH}
957     ## Setup Browever now being managed by the test case
958     ##Setup Browser
959     Go To    ${ASDC_FE_ENDPOINT}${PATH}
960     Maximize Browser Window
961
962     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
963     Log    Logging in to ${ASDC_FE_ENDPOINT}${PATH}
964     Title Should Be    ASDC
965     Wait Until Page Contains Element    xpath=//div/a[text()='SDC']    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
966     Log    Logged in to ${ASDC_FE_ENDPOINT}${PATH}
967
968
969 Create Multi Part
970    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}
971    ${fileData}=   Get Binary File  ${filePath}
972    ${fileDir}  ${fileName}=  Split Path  ${filePath}
973    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
974    Set To Dictionary  ${addTo}  ${partName}=${partData}
975
976
977 Add CDS Parameters 
978     [Arguments]  ${catalog_service_name} 
979     ${resp}=   SDC.Run Get Request    ${ASDC_BE_ENDPOINT}    ${ASDC_CATALOG_SERVICES_PATH}/serviceName/${catalog_service_name}/serviceVersion/0.1  ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION}
980     #${resp_json}=  To Json  ${resp}
981     ${service_uuid}=  Set Variable  ${resp.json()['uniqueId']}
982     ${component_uuid}=  Set Variable  ${resp.json()['componentInstances'][0]['uniqueId']}
983     @{inputs}=   Copy List  ${resp.json()['componentInstances'][0]['inputs']}
984     :FOR  ${input}  IN  @{inputs}
985     \    Run Keyword If  '${input['name']}' == "sdnc_artifact_name"   Set Input Parameter  ${service_uuid}  ${component_uuid}  ${input}  string  vdns-vnf
986          ...  ELSE IF  '${input['name']}' == "sdnc_model_name"   Set Input Parameter  ${service_uuid}  ${component_uuid}  ${input}  string  test
987          ...  ELSE IF  '${input['name']}' == "sdnc_model_version"   Set Input Parameter  ${service_uuid}  ${component_uuid}  ${input}  string  1.0.0
988          ...  ELSE IF  '${input['name']}' == "skip_post_instantiation_configuration"   Set Input Parameter  ${service_uuid}  ${component_uuid}  ${input}  boolean  false
989     
990
991 Set Input Parameter 
992     [Arguments]   ${service_uuid}  ${component_uuid}  ${input}  ${input_type}  ${input_value}    
993     ${resp}=    SDC.Run Post Request  ${ASDC_BE_ENDPOINT}   ${ASDC_CATALOG_SERVICES_PATH}/${service_uuid}/resourceInstance/${component_uuid}/inputs    {"constraints":[],"name":"${input['name']}","parentUniqueId":"${input['parentUniqueId']}","password":false,"required":false,"schema":{"property":{}},"type":"${input_type}","uniqueId":"${input['uniqueId']}","value":"${input_value}","definition":false,"toscaPresentation":{"ownerId":"${input['ownerId']}"}}    ${ASDC_DESIGNER_USER_ID}    auth=${GLOBAL_ASDC_AUTHENTICATION} 
994     Should Be Equal As Strings  ${resp.status_code}     200