Search in sources :

Example 76 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetup method getGBBALaCarteService.

protected GeneralBuildingBlock getGBBALaCarteService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
    Customer customer = getCustomerAndServiceSubscription(requestDetails, resourceId);
    if (customer != null) {
        Project project = null;
        OwningEntity owningEntity = null;
        if (requestDetails.getProject() != null)
            project = mapperLayer.mapRequestProject(requestDetails.getProject());
        if (requestDetails.getOwningEntity() != null)
            owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
        String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
        if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
            for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
                if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
                    modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
                    break;
                }
            }
        }
        Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
        if (service == null) {
            service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
            if (service == null) {
                throw new Exception("Could not find service for model version Id: " + requestDetails.getModelInfo().getModelVersionId() + " and for model invariant Id: " + requestDetails.getModelInfo().getModelInvariantId());
            }
        }
        ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName());
        BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
        return this.populateGBBWithSIAndAdditionalInfo(parameter);
    } else {
        throw new Exception("Could not find customer");
    }
}
Also used : Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException)

Example 77 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetup method getALaCarteServiceInstance.

protected ServiceInstance getALaCarteServiceInstance(Service service, RequestDetails requestDetails, Customer customer, Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception {
    ServiceInstance serviceInstance = this.getServiceInstanceHelper(requestDetails, customer, project, owningEntity, lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
    org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
    if (customer != null && customer.getServiceSubscription() != null) {
        serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType(), serviceInstanceId);
    } else {
        serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
    }
    if (serviceInstanceAAI != null && !serviceInstanceAAI.getModelVersionId().equalsIgnoreCase(service.getModelUUID())) {
        Service tempService = this.bbInputSetupUtils.getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
        if (tempService != null) {
            serviceInstance.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(tempService));
            return serviceInstance;
        } else {
            throw new Exception("Could not find model of existing SI. Service Instance in AAI already exists with different model version id: " + serviceInstanceAAI.getModelVersionId());
        }
    }
    serviceInstance.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(service));
    return serviceInstance;
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Service(org.onap.so.db.catalog.beans.Service) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException)

Example 78 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetup method mapCatalogVfModule.

protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) {
    if (modelInfo.getModelCustomizationUuid() != null) {
        modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
    }
    VnfResourceCustomization vnfResourceCustomization = null;
    for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
        if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) {
            vnfResourceCustomization = resourceCust;
            break;
        }
    }
    VfModuleCustomization vfResourceCustomization = null;
    if (vnfResourceCustomization != null) {
        vfResourceCustomization = // Convert to steam
        vnfResourceCustomization.getVfModuleCustomizations().stream().filter(// find
        x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID())).findAny().orElse(null);
    }
    if (vfResourceCustomization == null) {
        vfResourceCustomization = bbInputSetupUtils.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
    }
    if (vfResourceCustomization != null) {
        vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization));
    }
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StringUtils(org.apache.commons.lang3.StringUtils) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Tenant(org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) UUID(java.util.UUID) Pair(org.javatuples.Pair) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) Objects(java.util.Objects) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) HashMap(java.util.HashMap) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) VfModules(org.onap.so.serviceinstancebeans.VfModules) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Logger(org.slf4j.Logger) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Networks(org.onap.so.serviceinstancebeans.Networks) Component(org.springframework.stereotype.Component) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Resources(org.onap.so.serviceinstancebeans.Resources) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 79 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetup method getGBBMacro.

protected GeneralBuildingBlock getGBBMacro(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId, String vnfType) throws Exception {
    String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
    String key = executeBB.getBuildingBlock().getKey();
    if (requestAction.equalsIgnoreCase("deleteInstance") || requestAction.equalsIgnoreCase("unassignInstance") || requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") || requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck")) {
        return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration());
    }
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    GeneralBuildingBlock gBB = this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, serviceInstanceId);
    RequestParameters requestParams = requestDetails.getRequestParameters();
    Service service = null;
    if (gBB != null && gBB.getServiceInstance() != null && gBB.getServiceInstance().getModelInfoServiceInstance() != null && gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid() != null) {
        service = bbInputSetupUtils.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    } else {
        throw new Exception("Could not get service instance for macro request");
    }
    if (requestParams != null && requestParams.getUserParams() != null) {
        for (Map<String, Object> userParams : requestParams.getUserParams()) {
            if (userParams.containsKey("service")) {
                String input = mapper.writeValueAsString(userParams.get("service"));
                return getGBBMacroUserParams(executeBB, requestDetails, lookupKeyMap, vnfType, bbName, key, gBB, requestParams, service, input);
            }
        }
    }
    if (requestAction.equalsIgnoreCase("deactivateInstance")) {
        return gBB;
    } else if (requestAction.equalsIgnoreCase("createInstance")) {
        return getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, bbName, key, gBB, service);
    } else {
        throw new IllegalArgumentException("No user params on requestAction: assignInstance. Please specify user params.");
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Service(org.onap.so.db.catalog.beans.Service) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters)

Example 80 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class QueryServiceInfo method JSON2.

@Override
public String JSON2(boolean isArray, boolean isEmbed) {
    if (serviceInfo == null) {
        return "\"serviceInfo\": null";
    }
    StringBuilder sb = new StringBuilder();
    sb.append("\"serviceInfo\": ");
    sb.append("\n");
    Map<String, String> valueMap = new HashMap<>();
    Service service = serviceInfo.getService();
    put(valueMap, "ID", null == serviceInfo ? null : serviceInfo.getId());
    put(valueMap, "SERVICE_INPUT", null == serviceInfo ? null : serviceInfo.getServiceInput());
    put(valueMap, "SERVICE_PROPERTIES", null == serviceInfo ? null : serviceInfo.getServiceProperties());
    String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
    valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));
    sb.append(this.setTemplate(TEMPLATE, valueMap));
    sb.append("}");
    return sb.toString();
}
Also used : HashMap(java.util.HashMap) Service(org.onap.so.db.catalog.beans.Service)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18