+ /**
+ * Create the VNF. It consists of the following steps
+ * <ul>
+ * <li>upload the VNF package to CBAM package (if not already there)</li>
+ * <li>create the VNF on CBAM</li>
+ * <li>modify attributes of the VNF (add onapCsarId field)</li>
+ * </ul>
+ * The rollback of the failed operation is not implemented
+ * <ul>
+ * <li>delete the VNF if error occurs before instantiation</li>
+ * <li>terminate & delete VNF if error occurs after instantiation</li>
+ * </ul>
+ *
+ * @param vnfmId the identifier of the VNFM
+ * @param csarId the identifier of the VNF package
+ * @param vnfName the name of the VNF
+ * @param description the description of the VNF
+ * @param addtionalParams additional parameters for the VNF instantiation request
+ * @return the VNF creation result
+ */
+ public VnfCreationResult create(String vnfmId, String csarId, String vnfName, String description, AdditionalParameters addtionalParams) {
+ logOperationInput("not yet specified", "create", addtionalParams);
+ validateVimType(addtionalParams.getVimType());
+ try {
+ CatalogAdapterVnfpackage cbamPackage = catalogManager.preparePackageInCbam(vnfmId, csarId);
+ CreateVnfRequest vnfCreateRequest = new CreateVnfRequest();
+ vnfCreateRequest.setVnfdId(cbamPackage.getVnfdId());
+ vnfCreateRequest.setName(vnfName);
+ vnfCreateRequest.setDescription(description);
+ com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsPost(vnfCreateRequest, NOKIA_LCM_API_VERSION);
+ addVnfdIdToVnfModifyableAttributeExtensions(vnfmId, vnfInfo.getId(), csarId);
+ return new VnfCreationResult(vnfInfo, cbamPackage.getVnfdId());
+ } catch (Exception e) {
+ throw buildFatalFailure(logger, "Unable to create the VNF", e);
+ }
+ }
+
+ private void logOperationInput(String vnfId, String operationName, Object payload){
+ if(logger.isInfoEnabled()){
+ logger.info("Starting {} operation on VNF with {} identifier with {} parameter", operationName, vnfId, new Gson().toJson(payload));
+ }
+ }
+
+ /**
+ * Instantiate the VNF
+ *
+ * @param vnfmId the identifier of the VNFM
+ * @param request the VNF instantiation request
+ * @param httpResponse the HTTP response that corresponds to the VNF instantiation request
+ * @param additionalParameters additional parameters
+ * @param vnfId thr identifier of the VNF
+ * @param vnfdId the identifier of the VNF package in CBAM
+ * @return the instantiation response
+ */
+ public VnfInstantiateResponse instantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse, AdditionalParameters additionalParameters, String vnfId, String vnfdId) {
+ logOperationInput(vnfId, "instantiate", request);
+ validateVimType(additionalParameters.getVimType());
+ VnfInstantiateResponse response = new VnfInstantiateResponse();
+ response.setVnfInstanceId(vnfId);
+ String vimId = getVimId(request.getAdditionalParam());
+ JobInfo spawnJob = scheduleExecution(vnfId, httpResponse, "instantiate", jobInfo ->
+ instantiateVnf(vnfmId, request, additionalParameters, vnfdId, vnfId, vimId, jobInfo)
+ );
+ response.setJobId(spawnJob.getJobId());
+ return response;
+ }
+