2 * ============LICENSE_START======================================================= ONAP : SO
3 * ================================================================================ Copyright 2019 TechMahindra
4 * ================================================================================= Licensed under the Apache License,
5 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 * specific language governing permissions and limitations under the License.
13 * ============LICENSE_END=========================================================
16 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
18 import java.util.UUID;
19 import org.onap.so.bpmn.common.BuildingBlockExecution;
20 import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
21 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
22 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
23 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
24 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
25 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
26 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
27 import org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf;
28 import org.onap.so.client.cds.beans.ConfigDeployRequestVnf;
29 import org.onap.so.client.exception.ExceptionBuilder;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Component;
37 * Get vnf related data and config Deploy
41 public class ConfigDeployVnf {
42 private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class);
43 private static final String ORIGINATOR_ID = "SO";
44 private static final String ACTION_NAME = "config-deploy";
45 private static final String MODE = "async";
48 private ExceptionBuilder exceptionUtil;
50 private ExtractPojosForBB extractPojosForBB;
52 private AAIUpdateTasks aaiUpdateTask;
55 * Update vnf orch status to configure in AAI
59 public void updateAAIConfigure(BuildingBlockExecution execution) {
60 aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution);
65 * Getting the vnf object and set in execution object
71 public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
74 logger.info("Start preProcessAbstractCDSProcessing");
76 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
78 ServiceInstance serviceInstance =
79 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
81 ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
82 configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
83 configDeployPropertiesForVnf
84 .setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
85 configDeployPropertiesForVnf
86 .setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
87 configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
88 configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
90 ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
92 configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
93 configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
95 String blueprintName = vnf.getModelInfoGenericVnf().getBlueprintName();
96 String blueprintVersion = vnf.getModelInfoGenericVnf().getBlueprintVersion();
97 logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion);
99 AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
101 abstractCDSPropertiesBean.setBlueprintName(blueprintName);
102 abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
103 abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
106 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
108 abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
109 abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
110 abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
111 abstractCDSPropertiesBean.setActionName(ACTION_NAME);
112 abstractCDSPropertiesBean.setMode(MODE);
114 execution.setVariable("executionObject", abstractCDSPropertiesBean);
116 } catch (Exception ex) {
117 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
122 * Update vnf orch status to configured in AAI
126 public void updateAAIConfigured(BuildingBlockExecution execution) {
127 aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution);