Search in sources :

Example 56 with VfModule

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

the class GeneralTopologyObjectMapperTest method buildVfModuleInformationTest_withNoModelNoRequestParameters.

@Test
public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("TestVfModuleId");
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("serviceInstanceId");
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setVnfId("TestVnfId");
    RequestContext requestContext = new RequestContext();
    GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
    try {
        gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
    } catch (MapperException ex) {
    }
    assertNotNull(gcRequestInput);
    assertNull(vfModule.getModelInfoVfModule());
    assertNull(gcRequestInput.getOnapModelInformation());
    assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
    assertNotNull(gcRequestInput.getVfModuleId());
    assertTrue(gcRequestInput.getFromPreload());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) MapperException(org.onap.so.client.exception.MapperException) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) GenericResourceApiVfmoduleinformationVfModuleInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) Test(org.junit.Test)

Example 57 with VfModule

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

the class DeleteVfModuleTest method prepareVmModule.

private VfModule prepareVmModule() {
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId(VF_MODULE_ID);
    vfModule.setHeatStackId(HEAT_STACK_ID);
    return vfModule;
}
Also used : VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Example 58 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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 59 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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 60 with VfModule

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

the class VnfAdapterImpl method processVfModuleOutputs.

private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String, String> vfModuleOutputs) {
    if (vfModuleOutputs == null) {
        return;
    }
    try {
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        List<String> contrailNetworkPolicyFqdnList = new ArrayList<>();
        Iterator<String> keys = vfModuleOutputs.keySet().iterator();
        while (keys.hasNext()) {
            String key = keys.next();
            if (key.equals("contrail-service-instance-fqdn")) {
                String contrailServiceInstanceFqdn = vfModuleOutputs.get(key);
                logger.debug("Obtained contrailServiceInstanceFqdn: {}", contrailServiceInstanceFqdn);
                vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
                execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn);
            } else if (key.endsWith("contrail_network_policy_fqdn")) {
                String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key);
                logger.debug("Obtained contrailNetworkPolicyFqdn: {}", contrailNetworkPolicyFqdn);
                contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn);
            } else if (key.equals("oam_management_v4_address")) {
                String oamManagementV4Address = vfModuleOutputs.get(key);
                logger.debug("Obtained oamManagementV4Address: {}", oamManagementV4Address);
                genericVnf.setIpv4OamAddress(oamManagementV4Address);
                execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address);
            } else if (key.equals("oam_management_v6_address")) {
                String oamManagementV6Address = vfModuleOutputs.get(key);
                logger.debug("Obtained oamManagementV6Address: {}", oamManagementV6Address);
                genericVnf.setManagementV6Address(oamManagementV6Address);
                execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address);
            }
            if (!contrailNetworkPolicyFqdnList.isEmpty()) {
                execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList));
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ArrayList(java.util.ArrayList) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) MarshallerException(org.onap.so.exceptions.MarshallerException)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11