2 Documentation This test can be used for an arbitrary VNF.
3 Resource ../vid/vid_interface.robot
4 Resource ../vid/create_vid_vnf.robot
5 Resource ../sdnc_interface.robot
7 Library ONAPLibrary.Openstack
8 Library SeleniumLibrary
10 Library ONAPLibrary.Utilities
11 Library ONAPLibrary.JSON
12 Library ONAPLibrary.ServiceMapping WITH NAME ServiceMapping
16 [Documentation] Log into VID, create service instance, vnf instance, and module. This handles an arbitrary, single VNF service w/ volume modules.
17 [Arguments] ${customer_name} ${service} ${service_type} ${service_name} ${service_model_type} ${vnf_type} ${vf_modules} ${catalog_resources} ${product_family} ${tenant_name} ${lcp_region} ${cloud_owner} ${project_name} ${owning_entity} ${api_type} ${line_of_business}=LOB-Demonstration ${platform}=Platform-Demonstration
18 ${uuid}= Generate UUID4
20 ${report_data}= Create List
22 Login To VID GUI api_type=${api_type}
24 Log Creating ${service_name} in VID console=yes
25 ${service_instance_id}= Wait Until Keyword Succeeds 900s 5s Create VID Service Instance ${customer_name} ${service_model_type} ${service_type} ${service_name} ${project_name} ${owning_entity}
27 Validate Service Instance ${service_instance_id} ${service_type} ${customer_name}
28 ServiceMapping.Set Directory default ${GLOBAL_SERVICE_MAPPING_DIRECTORY}
29 ${vnflist}= ServiceMapping.Get Service Vnf Mapping default ${service}
30 ${vnf_name_index}= Set Variable 0
31 ${vf_module_name_list}= Create List
32 ${uuid}= Evaluate str("${uuid}")[:8]
34 ##### INSTANTIATING VNF IN VID #####
35 :FOR ${vnf} IN @{vnflist}
36 # APPC max is 50 characters
37 \ ${vnf_name}= Catenate Ete_${vnf}_${uuid}_${vnf_name_index}
38 \ ${generic_vnf_type}= Set Variable ${service_name}/${vnf_type} ${vnf_name_index}
39 \ ${vnf_name_index}= Evaluate ${vnf_name_index} + 1
40 \ Log Creating VNF ${vnf_name} in VID console=yes
41 \ Wait Until Keyword Succeeds 900s 5s Create VID VNF ${service_instance_id} ${vnf_name} ${product_family} ${lcp_region} ${tenant_name} ${vnf_type} ${CUSTOMER_NAME} line_of_business=${line_of_business} platform=${platform} cloud_owner_uc=${cloud_owner}
43 #### Calling Keyword To Create Each Module ####
44 \ ${report_data}= Loop and Create Modules in VID ${vf_modules} ${vnf_name} ${generic_vnf_type} ${service_instance_id} ${lcp_region} ${tenant_name} ${cloud_owner} ${customer_name} ${vnf} ${catalog_resources}
46 [Return] ${report_data}
48 Loop and Create Modules in VID
49 [Documentation] Loops through the VF modules in a VNF and instantiates in VID
50 [Arguments] ${vf_modules} ${vnf_name} ${generic_vnf_type} ${service_instance_id} ${lcp_region} ${tenant_name} ${cloud_owner} ${customer_name} ${vnf} ${resources}
51 ${temp_list_for_report} Create List
54 :FOR ${module} IN @{vf_modules}
55 \ ${vf_module_type}= Get From Dictionary ${module} name
56 \ ${template_name}= Get Heat Template Name From Catalog Resource ${resources} ${vnf} ${vf_module_type}
57 \ ${preload_file} ${isBase}= Retrieve Module Preload and isBase ${template_name}
58 \ ${temp_dict_for_report} = Run Keyword If "${isBase}"=="true" Create Module in VID ${vnf_name} ${template_name} ${vf_module_type} ${generic_vnf_type} ${preload_file} ${service_instance_id} ${lcp_region} ${tenant_name} ${customer_name} ${cloud_owner}
59 \ Run Keyword If "${isBase}"=="true" Append To List ${temp_list_for_report} ${temp_dict_for_report}
61 ### Incremental Modules
62 :FOR ${module} IN @{vf_modules}
63 \ ${vf_module_type}= Get From Dictionary ${module} name
64 \ ${template_name}= Get Heat Template Name From Catalog Resource ${resources} ${vnf} ${vf_module_type}
65 \ ${preload_file} ${isBase}= Retrieve Module Preload and isBase ${template_name}
66 \ ${temp_dict_for_report} = Run Keyword If "${isBase}"=="false" Create Module in VID ${vnf_name} ${template_name} ${vf_module_type} ${generic_vnf_type} ${preload_file} ${service_instance_id} ${lcp_region} ${tenant_name} ${customer_name} ${cloud_owner}
67 \ Run Keyword If "${isBase}"=="false" Append To List ${temp_list_for_report} ${temp_dict_for_report}
69 [Return] ${temp_list_for_report}
72 [Arguments] ${vnf_name} ${template_name} ${vf_module_type} ${generic_vnf_type} ${preload_file} ${service_instance_id} ${lcp_region} ${tenant_name} ${customer_name} ${cloud_owner}
74 ${vf_module_name}= Catenate Vfmodule_${vnf_name}_${template_name}
75 ${vf_module_name}= Remove String ${vf_module_name} .yaml .yml
76 ${Module_name}= Set Variable
77 ${api_type}= Retrieve Manifest Data api_type
79 Create Preload From JSON ${BUILD_DIR}/preloads/${preload_file} ${api_type} ${vf_module_name} ${vf_module_type} ${vnf_name} ${generic_vnf_type}
81 ${temp_dict_for_report} Create Dictionary stack_name=${vf_module_name} template_name=${BUILD_DIR}/templates/${template_name} preload_name=${BUILD_DIR}/preloads/${preload_file}
83 Log Creating ${vf_module_name} in VID console=yes
84 ${vf_module_id}= Create VID VNF module ${service_instance_id} ${vf_module_name} ${lcp_region} ${tenant_name} ${vf_module_type} ${customer_name} ${vnf_name} cloud_owner_uc=${cloud_owner}
85 [Return] ${temp_dict_for_report}
87 Retrieve Module Preload and isBase
88 [Arguments] ${file_name}
89 ${json}= OperatingSystem.Get File ${BUILD_DIR}/vnf-details.json
90 ${object}= Evaluate json.loads('''${json}''') json
91 :FOR ${vnf} IN @{object["modules"]}
92 \ ${module_present}= set variable True
93 \ ${file_name_m}= set variable ${vnf["filename"]}
94 \ ${preload_name}= set variable if '${file_name_m}' == '${file_name}' ${vnf["preload"]}
95 \ ${isBase}= set variable if '${file_name_m}' == '${file_name}' ${vnf["isBase"]}
96 \ Exit For Loop If '${file_name_m}' == '${file_name}'
97 \ ${module_present}= set variable False
98 Return From Keyword If ${module_present}==True ${preload_name} ${isBase}
99 Fail msg=ERROR: A module with the file name: ${file_name} is not present.
101 ##### Getting The Heat Template Name From the Module ID, using the catalog data #####
102 Get Heat Template Name From Catalog Resource
103 [Documentation] Searching through the catalog resources looking for the heat template name
104 [Arguments] ${resources} ${vnf} ${module_id}
106 ${keys}= Get Dictionary Keys ${resources}
107 ${artifact_ids}= Get Artifact IDs From CSAR ${resources} ${vnf} ${module_id}
109 :FOR ${key} IN @{keys}
110 \ ${cr}= Get From Dictionary ${resources} ${key}
111 \ ${artifacts}= Set Variable ${cr['allArtifacts']}
112 \ ${artifactName}= Get Artifact Name From Artifacts ${artifacts} ${artifact_ids}
113 \ Return From Keyword If "${artifactName}" != "NOTFOUND" ${artifactName}
115 Get Artifact Name From Artifacts
116 [Arguments] ${artifacts} ${artifact_ids}
118 ${keys}= Get Dictionary Keys ${artifacts}
120 :FOR ${key} IN @{keys}
121 \ ${artifact}= Get From Dictionary ${artifacts} ${key}
122 \ ${artifactType}= Get From Dictionary ${artifact} artifactType
123 \ ${csar_id}= Set Variable ''
124 \ ${csar_id}= Run Keyword If "${artifactType}"=="HEAT" Get From Dictionary ${artifact} artifactUUID
125 \ ${artifactName}= Run Keyword If $csar_id in $artifact_ids Get From Dictionary ${artifact} artifactName
126 \ Return From Keyword If $csar_id in $artifact_ids ${artifactName}
130 Get Artifact IDs From CSAR
131 [Documentation] Looking for the artifact ID for a given module
132 [Arguments] ${resources} ${vnf} ${module_id}
134 ${keys}= Get Dictionary Keys ${resources}
136 :FOR ${key} IN @{keys}
137 \ ${cr}= Get From Dictionary ${resources} ${key}
138 \ ${groups}= Set Variable ${cr['groups']}
139 \ ${artifact_ids}= Get Artifact IDs From Module ${groups} ${module_id}
140 \ Return From Keyword If ${artifact_ids} is not None ${artifact_ids}
142 ${empty_list}= Create List
144 [Return] ${empty_list}
146 Get Artifact IDs From Module
147 [Arguments] ${groups} ${module_id}
149 :FOR ${group} IN @{groups}
150 \ ${invariant_name}= Get From Dictionary ${group} invariantName
151 \ ${artifact_ids}= Create List
152 \ ${artifact_ids}= Run Keyword If "${invariant_name}"== "${module_id}" Get From Dictionary ${group} artifactsUuid
153 \ Return From Keyword If ${artifact_ids} is not None ${artifact_ids}
155 ${empty_list}= Create List
157 [Return] ${empty_list}
158 ##### End of catalog manipulation #####