Search in sources :

Example 26 with L3Network

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

the class AAINetworkResourcesTest method queryNetworkByIdTest.

@Test
public void queryNetworkByIdTest() throws Exception {
    final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
    L3Network network = new L3Network();
    network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
    network.setNetworkName("Dev_Bindings_1802_020118");
    network.setOrchestrationStatus(OrchestrationStatus.CREATED);
    doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
    Optional<org.onap.aai.domain.yang.L3Network> l3NetworkOpt = aaiNetworkResources.queryNetworkById(network);
    org.onap.aai.domain.yang.L3Network l3Network = l3NetworkOpt.isPresent() ? l3NetworkOpt.get() : null;
    verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
    assertNotNull(l3Network);
    assertEquals("0384d743-f69b-4cc8-9aa8-c3ae66662c44", l3Network.getNetworkId());
    assertEquals("Dev_Bindings_1802_020118", l3Network.getNetworkName());
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 27 with L3Network

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

the class BBInputSetup method populateL3Network.

protected void populateL3Network(BBInputSetupParameter parameter) {
    L3Network network = null;
    for (L3Network networkTemp : parameter.getServiceInstance().getNetworks()) {
        if (parameter.getLookupKeyMap().get(ResourceKey.NETWORK_ID) != null && networkTemp.getNetworkId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.NETWORK_ID))) {
            network = networkTemp;
            break;
        }
    }
    if (network == null && (parameter.getBbName().equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) || parameter.getBbName().equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) {
        network = createNetwork(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getResourceId(), parameter.getInstanceParams(), parameter);
        parameter.getServiceInstance().getNetworks().add(network);
    }
    if (network != null) {
        mapCatalogNetwork(network, parameter.getModelInfo(), parameter.getService());
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)

Example 28 with L3Network

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

the class BBInputSetup method getGBBMacroExistingService.

protected GeneralBuildingBlock getGBBMacroExistingService(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap, String bbName, String requestAction, CloudConfiguration cloudConfiguration) throws Exception {
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    RequestDetails requestDetails = executeBB.getRequestDetails();
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setExecuteBB(executeBB).setLookupKeyMap(lookupKeyMap).setBbName(bbName).setRequestAction(requestAction).setCloudConfiguration(cloudConfiguration).setRequestDetails(requestDetails).setResourceId(serviceInstanceId).build();
    GeneralBuildingBlock gBB = null;
    Service service = null;
    if (serviceInstanceId != null) {
        aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
        if (aaiServiceInstance != null) {
            String modelVersionId = aaiServiceInstance.getModelVersionId();
            if ("upgradeInstance".equalsIgnoreCase(requestAction)) {
                modelVersionId = requestDetails.getModelInfo().getModelVersionId();
            }
            service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
            if (service == null) {
                String message = String.format("Related service instance model not found in MSO CatalogDB: model-version-id=%s", aaiServiceInstance.getModelVersionId());
                throw new ServiceModelNotFoundException(message);
            }
        } else {
            String message = String.format("Related service instance from AAI not found: service-instance-id=%s", serviceInstanceId);
            throw new NoServiceInstanceFoundException(message);
        }
    }
    ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
    serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
    parameter.setServiceInstance(serviceInstance);
    gBB = populateGBBWithSIAndAdditionalInfo(parameter);
    serviceInstance = gBB.getServiceInstance();
    CloudRegion cloudRegion = null;
    if (cloudConfiguration == null) {
        Optional<CloudRegion> cloudRegionOp = cloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
        if (cloudRegionOp.isPresent()) {
            cloudRegion = cloudRegionOp.get();
        }
    }
    if (cloudConfiguration != null) {
        org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
        cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
    }
    gBB.setCloudRegion(cloudRegion);
    if (bbName.contains(VNF) || (bbName.contains(CONTROLLER) && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
        for (GenericVnf genericVnf : serviceInstance.getVnfs()) {
            if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null && genericVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
                org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId());
                ModelInfo modelInfo = new ModelInfo();
                if (vnf != null) {
                    modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId());
                }
                this.mapCatalogVnf(genericVnf, modelInfo, service);
            }
        }
    } else if (bbName.contains(VF_MODULE) || (bbName.contains(CONTROLLER) && (VF_MODULE).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
        for (GenericVnf vnf : serviceInstance.getVnfs()) {
            for (VfModule vfModule : vnf.getVfModules()) {
                if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null && vfModule.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) {
                    String vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
                    ModelInfo vnfModelInfo = new ModelInfo();
                    vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
                    this.mapCatalogVnf(vnf, vnfModelInfo, service);
                    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId());
                    String vfModuleCustomizationUUID = this.bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId();
                    ModelInfo vfModuleModelInfo = new ModelInfo();
                    vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
                    this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID);
                    if (cloudRegion != null) {
                        Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(vnf, vfModuleModelInfo, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), lookupKeyMap);
                        if (volumeGroupIdOp.isPresent()) {
                            lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
                        }
                    }
                    if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null && vfModule.getModelInfoVfModule().getModelName().contains("helm")) {
                        gBB.getRequestContext().setIsHelm(true);
                    }
                    break;
                }
            }
        }
    } else if (bbName.contains(VOLUME_GROUP)) {
        for (GenericVnf vnf : serviceInstance.getVnfs()) {
            for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
                if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) != null && volumeGroup.getVolumeGroupId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID))) {
                    String vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
                    ModelInfo vnfModelInfo = new ModelInfo();
                    vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
                    this.mapCatalogVnf(vnf, vnfModelInfo, service);
                    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId());
                    if (cloudRegion != null) {
                        String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId();
                        ModelInfo volumeGroupModelInfo = new ModelInfo();
                        volumeGroupModelInfo.setModelCustomizationId(volumeGroupCustomizationUUID);
                        this.mapCatalogVolumeGroup(volumeGroup, volumeGroupModelInfo, service, vnfModelCustomizationUUID);
                    }
                    break;
                }
            }
        }
    } else if (bbName.contains(NETWORK)) {
        for (L3Network network : serviceInstance.getNetworks()) {
            if (lookupKeyMap.get(ResourceKey.NETWORK_ID) != null && network.getNetworkId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.NETWORK_ID))) {
                String networkCustomizationUUID = this.bbInputSetupUtils.getAAIL3Network(network.getNetworkId()).getModelCustomizationId();
                ModelInfo modelInfo = new ModelInfo();
                modelInfo.setModelCustomizationUuid(networkCustomizationUUID);
                this.mapCatalogNetwork(network, modelInfo, service);
                break;
            }
        }
    } else if (bbName.contains("Fabric")) {
        for (Configuration configuration : serviceInstance.getConfigurations()) {
            if (lookupKeyMap.get(ResourceKey.CONFIGURATION_ID) != null && configuration.getConfigurationId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID))) {
                String configurationCustUUID = this.bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId()).getModelCustomizationId();
                ModelInfo modelInfo = new ModelInfo();
                modelInfo.setModelCustomizationUuid(configurationCustUUID);
                this.mapCatalogConfiguration(configuration, modelInfo, service, executeBB.getConfigurationResourceKeys());
                break;
            }
        }
    } else if (bbName.equals("HealthCheckBB") && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope())) {
        this.setisHelmforHealthCheckBB(service, serviceInstance, gBB);
    }
    if (executeBB.getWorkflowResourceIds() != null) {
        parameter.setResourceId(executeBB.getWorkflowResourceIds().getNetworkCollectionId());
        parameter.setKey(executeBB.getBuildingBlock().getKey());
        this.populateNetworkCollectionAndInstanceGroupAssign(parameter);
    }
    return gBB;
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Optional(java.util.Optional) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Example 29 with L3Network

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

the class BBInputSetup method createNetwork.

protected L3Network createNetwork(Map<ResourceKey, String> lookupKeyMap, String instanceName, String networkId, List<Map<String, String>> instanceParams, BBInputSetupParameter parameter) {
    lookupKeyMap.put(ResourceKey.NETWORK_ID, networkId);
    L3Network network = new L3Network();
    network.setNetworkId(networkId);
    network.setNetworkName(instanceName);
    network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    if (parameter != null) {
        if (parameter.getLineOfBusiness() != null) {
            network.setLineOfBusiness(this.mapperLayer.mapRequestLineOfBusiness(parameter.getLineOfBusiness()));
        }
        if (parameter.getLineOfBusiness() != null) {
            network.setPlatform(this.mapperLayer.mapRequestPlatform(parameter.getPlatform()));
        }
    }
    if (instanceParams != null) {
        for (Map<String, String> params : instanceParams) {
            network.getCloudParams().putAll(params);
        }
    }
    return network;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)

Example 30 with L3Network

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

the class BBInputSetup method getVirtualLinkL3Network.

protected L3Network getVirtualLinkL3Network(Map<ResourceKey, String> lookupKeyMap, String bbName, String key, String networkId, CollectionNetworkResourceCustomization collectionNetworkResourceCust, ServiceInstance serviceInstance) {
    if (collectionNetworkResourceCust != null) {
        if ((bbName.equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) || bbName.equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) {
            L3Network network = createNetwork(lookupKeyMap, null, networkId, null, null);
            serviceInstance.getNetworks().add(network);
            return network;
        } else {
            for (L3Network network : serviceInstance.getNetworks()) {
                if (network.getNetworkId().equalsIgnoreCase(networkId)) {
                    return network;
                }
            }
        }
    }
    return null;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)

Aggregations

L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)68 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)34 Test (org.junit.Test)29 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)18 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)13 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)12 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)11 Service (org.onap.so.db.catalog.beans.Service)11 File (java.io.File)10 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)10 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)9 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)9 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)9 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)8 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)8 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)8 ArrayList (java.util.ArrayList)7