use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class SDNCUnassignTasks method unassignNetwork.
/**
* This method is used to prepare a SDNC request and set it to the execution Object.
*
* Which is used for unassign the Network.
*
* @param execution
*/
public void unassignNetwork(BuildingBlockExecution execution) throws Exception {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
Customer customer = gBBInput.getCustomer();
RequestContext requestContext = gBBInput.getRequestContext();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
String cloudRegionSdnc = execution.getVariable("cloudRegionSdnc");
cloudRegion.setLcpCloudRegionId(cloudRegionSdnc);
GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
SDNCRequest sdncRequest = new SDNCRequest();
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.NETWORK);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCUnassignTasks unassignNetwork", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class SDNCUnassignTasks method unassignServiceInstance.
/**
* This method is used to prepare a SDNC request and set it to the execution Object.
*
* Which is used for unassign the ServiceInstance.
*
* @param execution
*/
public void unassignServiceInstance(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
GenericResourceApiServiceOperationInformation req = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext);
SDNCRequest sdncRequest = new SDNCRequest();
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.SERVICE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCUnassignTasks unassignServiceInstance", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class DeleteVFModule method createInventoryVariable.
public void createInventoryVariable(BuildingBlockExecution execution) {
try {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
CloudInformation cloudInformation = new CloudInformation();
cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
cloudInformation.setTenantId(gBBInput.getTenant().getTenantId());
cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
cloudInformation.setTemplateInstanceId(vfModule.getHeatStackId());
cloudInformation.setVnfName(vnf.getVnfName());
cloudInformation.setVnfId(vnf.getVnfId());
cloudInformation.setVfModuleId(vfModule.getVfModuleId());
execution.setVariable("cloudInformation", cloudInformation);
} catch (Exception e) {
logger.error("Error building CloudInformation Object for NC Inventory", e);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class SDNOHealthCheckTasks method sdnoHealthCheck.
public void sdnoHealthCheck(BuildingBlockExecution execution) {
boolean response = false;
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
RequestContext requestContext = gBBInput.getRequestContext();
GenericVnf vnf = null;
Map<ResourceKey, String> lookupMap = execution.getLookupMap();
for (Map.Entry<ResourceKey, String> entry : lookupMap.entrySet()) {
if (entry.getKey().equals(ResourceKey.GENERIC_VNF_ID)) {
vnf = extractPojosForBB.extractByKey(execution, entry.getKey());
}
}
response = sdnoHealthCheckResources.healthCheck(vnf, requestContext);
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex.getMessage());
}
if (!response) {
logger.error("SDNO Health Check failed");
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SDNO Health Check failed");
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class HomingV2Test method createBuildingBlockExecutionMock.
private BuildingBlockExecution createBuildingBlockExecutionMock(Map<String, Object> userParams) {
BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
GeneralBuildingBlock generalBuildingBlock = mock(GeneralBuildingBlock.class);
RequestContext requestContext = mock(RequestContext.class);
RequestParameters requestParameters = mock(RequestParameters.class);
List<Map<String, Object>> userParamsList = new ArrayList<>();
userParamsList.add(userParams);
when(execution.getGeneralBuildingBlock()).thenReturn(generalBuildingBlock);
when(generalBuildingBlock.getRequestContext()).thenReturn(requestContext);
when(requestContext.getRequestParameters()).thenReturn(requestParameters);
when(requestParameters.getUserParams()).thenReturn(userParamsList);
return execution;
}
Aggregations