use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class SniroHomingV2 method callSniro.
/**
* Generates the request payload then sends to sniro manager to perform homing and licensing for the provided
* demands
*
* @param execution
*/
public void callSniro(BuildingBlockExecution execution) {
logger.debug("Started Sniro Homing Call Sniro");
try {
GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
RequestContext requestContext = bb.getRequestContext();
RequestParameters requestParams = requestContext.getRequestParameters();
String requestId = requestContext.getMsoRequestId();
ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
Customer customer = bb.getCustomer();
String timeout = execution.getVariable("timeout");
if (isBlank(timeout)) {
timeout = env.getProperty("sniro.manager.timeout", "PT30M");
}
SniroManagerRequest request = new SniroManagerRequest();
RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
request.setRequestInformation(requestInfo);
ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
request.setServiceInformation(serviceInfo);
PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams);
List<Demand> placementDemands = buildPlacementDemands(serviceInstance);
placementInfo.setDemands(placementDemands);
request.setPlacementInformation(placementInfo);
LicenseInfo licenseInfo = new LicenseInfo();
List<Demand> licenseDemands = buildLicenseDemands(serviceInstance);
licenseInfo.setDemands(licenseDemands);
request.setLicenseInformation(licenseInfo);
if (!placementDemands.isEmpty() || !licenseDemands.isEmpty()) {
client.postDemands(request);
} else {
logger.debug(SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
}
// Variables for ReceiveWorkflowMessage subflow
execution.setVariable("asyncCorrelator", requestId);
execution.setVariable("asyncMessageType", "SNIROResponse");
execution.setVariable("asyncTimeout", timeout);
logger.trace("Completed Sniro Homing Call Sniro");
} catch (BpmnError e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage(), ONAPComponents.SNIRO);
} catch (BadResponseException e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage(), ONAPComponents.SNIRO);
} catch (Exception e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing sniro request: " + e.getMessage(), ONAPComponents.SO);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class VnfAdapterCreateTasks method createVfModule.
/**
* This method is used for creating the request for the VfModule.
*
* @param execution
* @return
*/
public void createVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = null;
try {
volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
} catch (BBObjectNotFoundException bbException) {
logger.info("Volume Group not found in GBB. ");
}
CloudRegion cloudRegion = gBBInput.getCloudRegion();
RequestContext requestContext = gBBInput.getRequestContext();
OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
} 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 VnfAdapterCreateTasks method createVolumeGroupRequest.
/**
* This method is used for creating the request for the VolumeGroup.
*
* @param execution
* @return
*/
public void createVolumeGroupRequest(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
VfModule vfModule;
String sdncVfModuleQueryResponse = null;
try {
vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
} else {
throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
}
} catch (BBObjectNotFoundException bbException) {
logger.error("Exception occurred", bbException);
// If there is not a vf module in the general building block (in aLaCarte case),
// we will not retrieve
// the SDNCQueryResponse and proceed as normal without throwing an error
}
CreateVolumeGroupRequest createVolumeGroupRequest = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVolumeGroupRequest.toXmlString());
} 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 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.entities.GeneralBuildingBlock in project so by onap.
the class NetworkAdapterDeleteTasks method deleteNetwork.
public void deleteNetwork(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network);
execution.setVariable("networkAdapterRequest", deleteNetworkRequest.toXmlString());
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
Aggregations