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