use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class CnfAdapterDeleteTasks method deleteInstance.
/**
* This method is used for deleting the instance with Multicloud K8s Plugin.
*
* @param execution
* @return
*/
public void deleteInstance(BuildingBlockExecution execution) {
try {
logger.debug("Running delete instance - Helm");
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
String heatStackId = vfModule.getHeatStackId();
execution.setVariable("heatStackId", heatStackId);
cnfAdapterClient.deleteVfModule(heatStackId);
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class CnfHealthCheckTasks method prepareCnfAdaperRequest.
public void prepareCnfAdaperRequest(BuildingBlockExecution execution) {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = serviceInstance.getVnfs().get(0);
List<VfModule> listOfVfModules = genericVnf.getVfModules();
List<String> listOfHeatStackIds = listOfVfModules.stream().map(x -> x.getHeatStackId()).collect(Collectors.toList());
LOGGER.debug("listOfHeatStackIds from prepareCnfAdaperRequest: {}", listOfHeatStackIds);
// Prepare values to pass in execution variable for CNF Adapter async Handling
String requestId = execution.getVariable("mso-request-id");
execution.setVariable("messageType", CNF_ADAPTER_MESSAGE_TYPE);
execution.setVariable("correlator", requestId);
execution.setVariable("timeout", "PT30M");
// Replace with environment values
String callBackUrl = "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
HealthcheckInstanceRequest request = new HealthcheckInstanceRequest();
try {
request = createStatusCheckRequest(listOfHeatStackIds, callBackUrl);
} catch (JsonProcessingException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 6822, e);
}
LOGGER.debug("request: {}", request);
String requestPayload = "";
try {
requestPayload = mapper.writeValueAsString(request);
} catch (JsonProcessingException e) {
LOGGER.error("Error in JSON");
}
execution.setVariable("cnfRequestPayload", requestPayload);
ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
// Replace values with environment values
String uri = "http://so-cnf-adapter:8090";
String apiPath = "";
if (STATUS_CHECK_SCOPE.equals(action)) {
apiPath = uri + "/api/cnf-adapter/v1/statuscheck/";
} else if (HEALTH_CHECK_SCOPE.equals(action)) {
apiPath = uri + "/api/cnf-adapter/v1/healthcheck/";
}
LOGGER.debug("apiPath: {}", apiPath);
execution.setVariable("apiPath", apiPath);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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.bbobjects.VfModule 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.bbobjects.VfModule in project so by onap.
the class AuditTasks method createAuditInventory.
private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException {
AuditInventory auditInventory = new AuditInventory();
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
auditInventory.setMsoRequestId(gBBInput.getRequestContext().getMsoRequestId());
auditInventory.setCloudOwner(cloudRegion.getCloudOwner());
auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId());
auditInventory.setTenantId(cloudRegion.getTenantId());
auditInventory.setVfModuleId(vfModule.getVfModuleId());
auditInventory.setHeatStackName(vfModule.getVfModuleName());
auditInventory.setGenericVnfId(genericVnf.getVnfId());
return auditInventory;
}
Aggregations