Search in sources :

Example 21 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class BBInputSetupMapperLayer method mapAAIVolumeGroup.

protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) {
    VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class);
    ModelInfoVfModule modelInfo = new ModelInfoVfModule();
    modelInfo.setModelCustomizationUUID(aaiVolumeGroup.getModelCustomizationId());
    volumeGroup.setModelInfoVfModule(modelInfo);
    volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus()));
    return volumeGroup;
}
Also used : ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)

Example 22 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class VfModuleTopologyOperationRequestMapperTest method assignGenericResourceApiVfModuleInformationTest.

@Test
public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
    // prepare and set service instance
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("serviceInstanceId");
    ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
    modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
    modelInfoServiceInstance.setModelName("serviceModelName");
    modelInfoServiceInstance.setModelUuid("serviceModelUuid");
    modelInfoServiceInstance.setModelVersion("serviceModelVersion");
    serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
    // prepare Customer object
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    serviceSubscription.setServiceType("productFamilyId");
    customer.setServiceSubscription(serviceSubscription);
    customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
    // 
    RequestContext requestContext = new RequestContext();
    Map<String, Object> userParams = new HashMap<>();
    userParams.put("key1", "value1");
    requestContext.setUserParams(userParams);
    requestContext.setProductFamilyId("productFamilyId");
    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setUsePreload(true);
    requestContext.setRequestParameters(requestParameters);
    requestContext.setMsoRequestId("MsoRequestId");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("testVnfId");
    vnf.setVnfType("testVnfType");
    vnf.setVnfName("testVnfName");
    ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
    modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
    modelInfoGenericVnf.setModelName("vnfModelName");
    modelInfoGenericVnf.setModelVersion("vnfModelVersion");
    modelInfoGenericVnf.setModelUuid("vnfModelUuid");
    modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
    vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("testVfModuleId");
    vfModule.setVfModuleName("testVfModuleName");
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
    modelInfoVfModule.setModelName("vfModuleModelName");
    modelInfoVfModule.setModelVersion("vfModuleModelVersion");
    modelInfoVfModule.setModelUUID("vfModuleModelUuid");
    modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
    vfModule.setModelInfoVfModule(modelInfoVfModule);
    HashMap<String, String> cloudParams = new HashMap<String, String>();
    cloudParams.put("key2", "value2");
    vfModule.setCloudParams(cloudParams);
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("volumeGroupId");
    volumeGroup.setVolumeGroupName("volumeGroupName");
    CloudRegion cloudRegion = new CloudRegion();
    GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080"));
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
    ObjectMapper omapper = new ObjectMapper();
    GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
    assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId").ignoring("requestInformation.requestId"));
    assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) URI(java.net.URI) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) GenericResourceApiVfModuleOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) GeneralTopologyObjectMapper(org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 23 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup 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);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 24 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup 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);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 25 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup 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);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) DeleteVolumeGroupRequest(org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Aggregations

VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)44 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)28 Test (org.junit.Test)23 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)20 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)17 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)15 HashMap (java.util.HashMap)13 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)13 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)13 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)11 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)10 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)8 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)8 Service (org.onap.so.db.catalog.beans.Service)8 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)7 Map (java.util.Map)6 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)6 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)5 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)5