2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 TechMahindra.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
24 import java.util.UUID;
25 import org.onap.so.bpmn.common.BuildingBlockExecution;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
28 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
29 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
30 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
31 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
32 import org.onap.so.client.cds.beans.ConfigAssignPropertiesForVnf;
33 import org.onap.so.client.cds.beans.ConfigAssignRequestVnf;
34 import org.onap.so.client.exception.ExceptionBuilder;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.stereotype.Component;
42 * Get vnf related data and config assign
46 public class ConfigAssignVnf {
48 private static final Logger logger = LoggerFactory.getLogger(ConfigAssignVnf.class);
49 private static final String ORIGINATOR_ID = "SO";
50 private static final String ACTION_NAME = "config-assign";
51 private static final String MODE = "sync";
54 private ExceptionBuilder exceptionUtil;
56 private ExtractPojosForBB extractPojosForBB;
59 * Getting the vnf data, blueprint name, blueprint version etc and setting them in execution object and calling the
64 public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
65 logger.info("Start preProcessAbstractCDSProcessing ");
67 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
68 ServiceInstance serviceInstance =
69 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
71 Map<String, Object> userParams = execution.getGeneralBuildingBlock().getRequestContext().getUserParams();
73 ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf();
74 configAssignPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
75 configAssignPropertiesForVnf
76 .setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
77 configAssignPropertiesForVnf
78 .setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
79 configAssignPropertiesForVnf.setVnfId(vnf.getVnfId());
80 configAssignPropertiesForVnf.setVnfName(vnf.getVnfName());
82 for (Map.Entry<String, Object> entry : userParams.entrySet()) {
83 configAssignPropertiesForVnf.setUserParam(entry.getKey(), entry.getValue());
86 ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf();
87 configAssignRequestVnf.setResolutionKey(vnf.getVnfName());
88 configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf);
90 String blueprintName = vnf.getBlueprintName();
91 String blueprintVersion = vnf.getBlueprintVersion();
93 AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
95 abstractCDSPropertiesBean.setBlueprintName(blueprintName);
96 abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
97 abstractCDSPropertiesBean.setRequestObject(configAssignRequestVnf.toString());
99 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
101 abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
102 abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
103 abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
104 abstractCDSPropertiesBean.setActionName(ACTION_NAME);
105 abstractCDSPropertiesBean.setMode(MODE);
106 execution.setVariable("executionObject", abstractCDSPropertiesBean);
108 } catch (Exception ex) {
109 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);