Search in sources :

Example 86 with GeneralBuildingBlock

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);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) SDNCRequest(org.onap.so.client.sdnc.beans.SDNCRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) GenericResourceApiNetworkOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)

Example 87 with GeneralBuildingBlock

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);
    }
}
Also used : SDNCRequest(org.onap.so.client.sdnc.beans.SDNCRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)

Example 88 with GeneralBuildingBlock

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);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) CloudInformation(org.onap.so.cloud.resource.beans.CloudInformation) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Example 89 with GeneralBuildingBlock

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");
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)

Example 90 with GeneralBuildingBlock

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;
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ArrayList(java.util.ArrayList) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) HashMap(java.util.HashMap) Map(java.util.Map) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Aggregations

GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)117 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)61 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)51 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)40 Test (org.junit.Test)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)37 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)35 File (java.io.File)34 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)34 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)29 Service (org.onap.so.db.catalog.beans.Service)27 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)25 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)23 HashMap (java.util.HashMap)22 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)20 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)19 SDNCRequest (org.onap.so.client.sdnc.beans.SDNCRequest)19 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)16 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)16