use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class CnfAdapterCreateTasks method prepareForCnfUpdateOrDelete.
public void prepareForCnfUpdateOrDelete(BuildingBlockExecution execution) {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
GenericVnf genericVnfId = null;
VfModule vfModuleId = null;
try {
genericVnfId = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
vfModuleId = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
} catch (Exception ex) {
logger.error("Exception occurred", ex);
}
String heatStackId = execution.getVariable("heatStackId");
logger.debug("heatStackId: {}", heatStackId);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
String requestId = execution.getVariable("mso-request-id");
String callbackUrl = "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
CnfAaiUpdateRequest aaiRequest = createCnfAaiUpdateRequest(heatStackId, cloudRegion, callbackUrl, genericVnfId, vfModuleId);
logger.debug("aaiRequest: {}", aaiRequest);
String cnfRequestPayload = "";
try {
cnfRequestPayload = mapper.writeValueAsString(aaiRequest);
} catch (JsonProcessingException e) {
logger.error("Exception occurred", e);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
}
// Prepare values to pass in execution variable for CNF Adapter async Handling
execution.setVariable("messageType", CNF_ADAPTER_MESSAGE_TYPE);
execution.setVariable("correlator", requestId);
execution.setVariable("timeout", CNF_ADAPTER_CALLBACK_TIMEOUT);
String currentFlow = execution.getFlowToBeCalled();
logger.debug("currentFlow: {}", currentFlow);
String apiPath = "http://so-cnf-adapter:8090";
if ("CreateVfModuleBB".equals(currentFlow)) {
apiPath = apiPath + "/api/cnf-adapter/v1/aai-update/";
} else if ("DeleteVfModuleBB".equals(currentFlow)) {
apiPath = apiPath + "/api/cnf-adapter/v1/aai-delete/";
}
// Set variables in execution variable\
execution.setVariable("apiPath", apiPath);
execution.setVariable("cnfRequestPayload", cnfRequestPayload);
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class CnfAdapterCreateTasks method createInstance.
/**
* This method is used for creating the request for an Instance in Multicloud K8s Plugin.
*
* @param execution
* @return
*/
public void createInstance(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
RequestContext requestContext = gBBInput.getRequestContext();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
Map<String, Object> paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
Map<String, String> sdncDirectives = getSdncDirectives(paramsMap);
InstanceRequest createInstanceRequest = createInstanceRequest(vfModule, cloudRegion, sdncDirectives);
InstanceResponse response = cnfAdapterClient.createVfModule(createInstanceRequest);
execution.setVariable("heatStackId", response.getId());
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class NetworkAdapterCreateTasks method createNetwork.
public void createNetwork(BuildingBlockExecution execution) {
execution.setVariable("networkAdapterCreateRollback", false);
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
Map<String, String> userInput = gBBInput.getUserInput();
String cloudRegionPo = execution.getVariable("cloudRegionPo");
CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
execution.setVariable("networkAdapterRequest", createNetworkRequest.toXmlString());
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class VnfAdapterDeleteTasks method deleteVolumeGroup.
public void deleteVolumeGroup(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
execution.setVariable("deleteVolumeGroupRequest", "true");
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class VnfmAdapterCreateVnfTask method buildCreateVnfRequest.
/**
* Create {@link CreateVnfRequest} object with required fields and store it in
* {@link org.camunda.bpm.engine.delegate.DelegateExecution}
*
* @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
*/
public void buildCreateVnfRequest(final BuildingBlockExecution execution) {
try {
LOGGER.debug("Executing buildCreateVnfRequest ...");
final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
final CloudRegion cloudRegion = buildingBlock.getCloudRegion();
final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
final ModelInfoGenericVnf modelInfoGenericVnf = vnf.getModelInfoGenericVnf();
final InputParameter inputParameter = getInputParameter(execution);
final CreateVnfRequest createVnfRequest = new CreateVnfRequest();
createVnfRequest.setName(getName(vnf.getVnfName(), modelInfoGenericVnf.getModelInstanceName()));
createVnfRequest.setTenant(getTenant(cloudRegion));
createVnfRequest.setAdditionalParams(inputParameter.getAdditionalParams());
createVnfRequest.setExternalVirtualLinks(inputParameter.getExtVirtualLinks());
LOGGER.info("CreateVnfRequest : {}", createVnfRequest);
execution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, createVnfRequest);
LOGGER.debug("Finished executing buildCreateVnfRequest ...");
} catch (final Exception exception) {
LOGGER.error("Unable to execute buildCreateVnfRequest", exception);
exceptionUtil.buildAndThrowWorkflowException(execution, 1200, exception);
}
}
Aggregations