Search in sources :

Example 1 with NoServiceInstanceFoundException

use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException in project so by onap.

the class BBInputSetup method getGBBALaCarteNonService.

protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId, String vnfType) throws Exception {
    String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
    ServiceModel serviceModel = new ServiceModel();
    Service service = null;
    Service newService = null;
    boolean isReplace = false;
    if (serviceInstanceId != null) {
        aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
        if (aaiServiceInstance != null) {
            if (requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
                RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
                if (relatedInstanceList != null) {
                    for (RelatedInstanceList relatedInstList : relatedInstanceList) {
                        RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
                        if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
                            newService = bbInputSetupUtils.getCatalogServiceByModelUUID(relatedInstance.getModelInfo().getModelVersionId());
                            isReplace = true;
                        }
                    }
                }
            }
            service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
            serviceModel.setNewService(newService);
            serviceModel.setCurrentService(service);
            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 if (newService == null && isReplace) {
                String message = "Related service instance model in Request not found in MSO CatalogDB";
                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);
    if (isReplace) {
        serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getNewService()));
    } else {
        serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getCurrentService()));
    }
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(executeBB.getRequestId()).setRequestDetails(requestDetails).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setVnfType(vnfType).setKey(executeBB.getBuildingBlock().getKey()).setConfigurationResourceKeys(executeBB.getConfigurationResourceKeys()).setExecuteBB(executeBB).setRequestAction(requestAction).setIsReplace(isReplace).setServiceModel(serviceModel).build();
    this.populateObjectsOnAssignAndCreateFlows(parameter);
    return this.populateGBBWithSIAndAdditionalInfo(parameter);
}
Also used : RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Example 2 with NoServiceInstanceFoundException

use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException 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 3 with NoServiceInstanceFoundException

use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException in project so by onap.

the class BBInputSetupUtils method getRelatedServiceInstanceFromInstanceGroup.

public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception {
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroupId)).relatedTo(Types.SERVICE_INSTANCES.getFragment());
    Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri);
    ServiceInstance serviceInstance = null;
    if (!serviceInstances.isPresent()) {
        logger.debug("No ServiceInstances were found");
        return Optional.empty();
    } else {
        if (serviceInstances.get().getServiceInstance().isEmpty()) {
            throw new NoServiceInstanceFoundException("No ServiceInstances Returned");
        } else if (serviceInstances.get().getServiceInstance().size() > 1) {
            String message = String.format("Mulitple service instances were found for instance-group-id: %s.", instanceGroupId);
            throw new MultipleObjectsFoundException(message);
        } else {
            serviceInstance = serviceInstances.get().getServiceInstance().get(0);
        }
        return Optional.of(serviceInstance);
    }
}
Also used : MultipleObjectsFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException) ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Example 4 with NoServiceInstanceFoundException

use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException in project so by onap.

the class BBInputSetup method getGBBCM.

protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
    ServiceInstance serviceInstance = new ServiceInstance();
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    serviceInstance.setServiceInstanceId(serviceInstanceId);
    Customer customer = new Customer();
    List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
    String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
    if (vnfId != null) {
        org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
        GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
        genericVnfs.add(genericVnf);
    }
    String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID);
    if (instanceGroupId != null && !instanceGroupId.isEmpty()) {
        org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
        InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup);
        instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
        if (serviceInstanceId == null) {
            Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
            if (aaiServiceInstanceOpt.isPresent()) {
                org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get();
                serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance);
                WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds();
                workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId());
                lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
            } else {
                throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI.");
            }
        }
        RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
        if (relatedInstanceList != null) {
            for (RelatedInstanceList relatedInstList : relatedInstanceList) {
                RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
                if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                    org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId());
                    GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf);
                    instanceGroup.getVnfs().add(vnf);
                }
            }
        }
        serviceInstance.getInstanceGroups().add(instanceGroup);
        customer.setServiceSubscription(new ServiceSubscription());
    }
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
    return this.populateGBBWithSIAndAdditionalInfo(parameter);
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Aggregations

NoServiceInstanceFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)4 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 ServiceModelNotFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException)2 ExceptionBuilder (org.onap.so.client.exception.ExceptionBuilder)2 Service (org.onap.so.db.catalog.beans.Service)2 RelatedInstance (org.onap.so.serviceinstancebeans.RelatedInstance)2 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)2 Optional (java.util.Optional)1 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)1 ServiceInstances (org.onap.aai.domain.yang.ServiceInstances)1 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)1 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)1 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)1 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)1 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1