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 final static String ORIGINATOR_ID = "SO";
44 private final static String ACTION_NAME = "config-deploy";
45 private final static 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.getBlueprintName();
96 String blueprintVersion = vnf.getBlueprintVersion();
97 AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
99 abstractCDSPropertiesBean.setBlueprintName(blueprintName);
100 abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
101 abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
104 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
106 abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
107 abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
108 abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
109 abstractCDSPropertiesBean.setActionName(ACTION_NAME);
110 abstractCDSPropertiesBean.setMode(MODE);
112 execution.setVariable("executionObject", abstractCDSPropertiesBean);
114 } catch (Exception ex) {
115 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
120 * Update vnf orch status to configured in AAI
124 public void updateAAIConfigured(BuildingBlockExecution execution) {
125 aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution);