Search in sources :

Example 6 with ModelInfo

use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.

the class BpmnRequestBuilder method mapServiceModelInformation.

protected ModelInfo mapServiceModelInformation(ServiceInstance serviceInstance) {
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelVersionId(serviceInstance.getModelVersionId());
    modelInfo.setModelType(ModelType.service);
    return modelInfo;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo)

Example 7 with ModelInfo

use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.

the class BpmnRequestBuilder method mapVfModuleModelInformation.

protected ModelInfo mapVfModuleModelInformation(VfModule vfModule, ModelType modelType) {
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId(vfModule.getModelCustomizationId());
    modelInfo.setModelCustomizationUuid(vfModule.getModelCustomizationId());
    modelInfo.setModelType(modelType);
    return modelInfo;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo)

Example 8 with ModelInfo

use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.

the class BpmnRequestBuilder method mapNetworkModelInformation.

protected ModelInfo mapNetworkModelInformation(L3Network network) {
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelType(ModelType.network);
    modelInfo.setModelCustomizationId(network.getModelCustomizationId());
    modelInfo.setModelCustomizationUuid(network.getModelCustomizationId());
    return modelInfo;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo)

Example 9 with ModelInfo

use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.

the class ModelInfoValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
    RequestParameters requestParameters = info.getReqParameters();
    String requestScope = info.getRequestScope();
    Actions action = info.getAction();
    int reqVersion = info.getReqVersion();
    Boolean aLaCarteFlag = info.getALaCarteFlag();
    if (!requestScope.equals(ModelType.instanceGroup.toString())) {
        if (!empty(modelInfo.getModelNameVersionId())) {
            modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
        }
        // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
        if (requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
            if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
                throw new ValidationException("modelCustomizationId");
            }
        }
        // modelCustomizationId is required for v5 and higher for VF Module Replace
        if (requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
            if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
                throw new ValidationException("modelCustomizationId");
            }
        }
        // modelCustomizationId or modelCustomizationName are required for VNF Replace
        if (requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) {
            if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
                throw new ValidationException("modelCustomizationId or modelCustomizationName");
            }
        }
        // create and updates except for network (except v4)
        if (empty(modelInfo.getModelInvariantId()) && ((reqVersion > 2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || !(reqVersion < 4 && requestScope.equalsIgnoreCase(ModelType.network.name())) && (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships || (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
            throw new ValidationException("modelInvariantId");
        }
        if (empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) {
            throw new ValidationException("modelInvariantId");
        }
        if (empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) {
            throw new ValidationException("modelInvariantId", true);
        }
        if (!empty(modelInfo.getModelInvariantId()) && !UUIDChecker.isValidUUID(modelInfo.getModelInvariantId())) {
            throw new ValidationException("modelInvariantId format");
        }
        if (reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty(modelInfo.getModelName()) && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()))))) {
            throw new ValidationException("modelName", true);
        }
        if (empty(modelInfo.getModelVersion()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (!(reqVersion < 4 && requestScope.equalsIgnoreCase(ModelType.network.name())) && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
            throw new ValidationException("modelVersion");
        }
        if (empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) {
            throw new ValidationException("modelVersion", true);
        }
        // is required for serviceInstance delete macro when aLaCarte=false in v4
        if (reqVersion >= 4 && empty(modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships || (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
            throw new ValidationException("modelVersionId");
        }
        if (empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) {
            throw new ValidationException("modelVersionId", true);
        }
        if (empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) {
            throw new ValidationException("modelVersionId");
        }
        if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty(modelInfo.getModelCustomizationName())) {
            if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
                throw new ValidationException("modelCustomizationId or modelCustomizationName");
            }
        }
        if (reqVersion >= 4 && (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase(ModelType.network.name()) || requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.updateInstance || action == Action.createInstance)) {
            throw new ValidationException("modelCustomizationId");
        }
        if (empty(modelInfo.getModelCustomizationId()) && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)) {
            throw new ValidationException("modelCustomizationId");
        }
    } else {
        if (empty(modelInfo.getModelVersionId()) && action == Action.createInstance) {
            throw new ValidationException("modelVersionId", true);
        }
    }
    return info;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ValidationException(org.onap.so.exceptions.ValidationException) Actions(org.onap.so.apihandlerinfra.Actions) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters)

Example 10 with ModelInfo

use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.

the class UserParamsServiceTraversal method setResourceListForPnfs.

private void setResourceListForPnfs(List<Resource> resourceList, Resource serviceResource, Service validate) {
    for (Pnfs pnf : validate.getResources().getPnfs()) {
        Resource pnfResource = new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false, serviceResource);
        ModelInfo modelInfo = pnf.getModelInfo();
        if (modelInfo != null) {
            pnfResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
            pnfResource.setModelVersionId(modelInfo.getModelVersionId());
        }
        pnfResource.setProcessingPriority(pnf.getProcessingPriority());
        resourceList.add(pnfResource);
    }
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Pnfs(org.onap.so.serviceinstancebeans.Pnfs)

Aggregations

ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)84 Test (org.junit.Test)46 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)35 Service (org.onap.so.db.catalog.beans.Service)30 HashMap (java.util.HashMap)18 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)18 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)17 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)17 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)15 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)14 RelatedInstance (org.onap.so.serviceinstancebeans.RelatedInstance)14 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)14 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)12 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)12 ServiceModel (org.onap.so.bpmn.servicedecomposition.entities.ServiceModel)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 File (java.io.File)10 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)10 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)10 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)10