Search in sources :

Example 1 with Vnfs

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

the class UserParamsValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    Service validate = info.getUserParams();
    if (validate.getModelInfo() == null) {
        throw new ValidationException("modelInfo in userParams", true);
    } else if (validate.getModelInfo().getModelType() == null) {
        throw new ValidationException("modelType in userParams service modelInfo", true);
    } else if (validate.getModelInfo().getModelVersionId() == null) {
        throw new ValidationException("modelVersionId in userParams service modelInfo", true);
    }
    modelInfoValidation(info.getSir().getRequestDetails().getModelInfo(), validate.getModelInfo());
    if (validate.getInstanceName() != null && info.getRequestInfo().getInstanceName() != null) {
        instanceNameValidation(info, validate);
    }
    Actions action = info.getAction();
    Map<String, Set<String>> vnfCustomIdToInstanceNames = new HashMap<>();
    Map<String, Set<String>> vfModuleCustomIdToInstanceNames = new HashMap<>();
    for (Vnfs vnf : validate.getResources().getVnfs()) {
        if (vnf.getModelInfo() == null) {
            throw new ValidationException("modelInfo in userParams vnf resources", true);
        } else if (vnf.getModelInfo().getModelCustomizationId() == null) {
            throw new ValidationException("modelCustomizationId in userParams vnf resources", true);
        } else if (vnf.getModelInfo().getModelVersionId() == null) {
            throw new ValidationException("modelVersionId in userParams vnf resources", true);
        }
        if (vnf.getCloudConfiguration() == null) {
            throw new ValidationException("cloudConfiguration in userParams vnf resources", true);
        }
        if (action == Action.createInstance || action == Action.assignInstance) {
            if (vnf.getPlatform() == null) {
                throw new ValidationException("platform in userParams vnf resources", true);
            }
            if (vnf.getProductFamilyId() == null) {
                throw new ValidationException("productFamilyId in userParams vnf resources", true);
            }
        }
        if (vnf.getPlatform() != null && vnf.getPlatform().getPlatformName() == null) {
            throw new ValidationException("platformName in userParams vnf resources", true);
        }
        String vnfCustomizationId = vnf.getModelInfo().getModelCustomizationId();
        vnfCustomIdToInstanceNames.putIfAbsent(vnfCustomizationId, new HashSet<>());
        String vnfInstanceName = StringUtils.defaultString(vnf.getInstanceName());
        Set<String> vnfVisitedInstanceNames = vnfCustomIdToInstanceNames.get(vnfCustomizationId);
        if (!vnfVisitedInstanceNames.add(vnfInstanceName)) {
            throw new ValidationException("instanceName: same instanceName with same modelCustomizationId in userParams vnf resources", true);
        }
        if (vnf.getVfModules().isEmpty()) {
            throw new ValidationException("vfModules in userParams vnf resources", true);
        }
        for (VfModules vfModule : vnf.getVfModules()) {
            if (vfModule.getModelInfo() == null) {
                throw new ValidationException("modelInfo in userParams vfModules resources", true);
            } else if (vfModule.getModelInfo().getModelCustomizationId() == null) {
                throw new ValidationException("modelCustomizationId in userParams vfModule resources", true);
            } else if (vfModule.getModelInfo().getModelVersionId() == null) {
                throw new ValidationException("modelVersionId in userParams vfModule resources", true);
            }
            String vfModulecustomizationId = vfModule.getModelInfo().getModelCustomizationId();
            vfModuleCustomIdToInstanceNames.putIfAbsent(vfModulecustomizationId, new HashSet<>());
            String vfModuleInstanceName = StringUtils.defaultString(vfModule.getInstanceName());
            Set<String> vfModuleVisitedInstanceNames = vfModuleCustomIdToInstanceNames.get(vfModulecustomizationId);
            if (!vfModuleVisitedInstanceNames.add(vfModuleInstanceName)) {
                throw new ValidationException("instanceName: same instanceName with same modelCustomizationId in userParams vfModule resources", true);
            }
        }
    }
    validateDuplicateInstanceNames(vnfCustomIdToInstanceNames, "vnf");
    validateDuplicateInstanceNames(vfModuleCustomIdToInstanceNames, "vfModule");
    List<Networks> validateNetworks = new ArrayList<>();
    validateNetworks = validate.getResources().getNetworks();
    if (validateNetworks != null) {
        for (Networks networks : validateNetworks) {
            if (networks.getModelInfo() == null) {
                throw new ValidationException("modelInfo in userParams network resources", true);
            } else if (networks.getModelInfo().getModelCustomizationId() == null) {
                throw new ValidationException("modelCustomizationId in userParams network resources", true);
            } else if (networks.getModelInfo().getModelVersionId() == null) {
                throw new ValidationException("modelVersionId in userParams network resources", true);
            }
            if (networks.getCloudConfiguration() == null) {
                throw new ValidationException("cloudConfiguration in userParams network resources", true);
            }
        }
    }
    return info;
}
Also used : VfModules(org.onap.so.serviceinstancebeans.VfModules) Networks(org.onap.so.serviceinstancebeans.Networks) ValidationException(org.onap.so.exceptions.ValidationException) Set(java.util.Set) HashSet(java.util.HashSet) Actions(org.onap.so.apihandlerinfra.Actions) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(org.onap.so.serviceinstancebeans.Service) Vnfs(org.onap.so.serviceinstancebeans.Vnfs)

Example 2 with Vnfs

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

the class UserParamsServiceTraversal method setResourceListForVnfs.

private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Resource serviceResource, Service validate) {
    for (Vnfs vnf : validate.getResources().getVnfs()) {
        setVnfCustomizationUUID(vnf);
        Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false, serviceResource);
        vnfResource.setProcessingPriority(vnf.getProcessingPriority());
        vnfResource.setInstanceName(vnf.getInstanceName());
        ModelInfo modelInfo = vnf.getModelInfo();
        if (modelInfo != null) {
            vnfResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
            vnfResource.setModelVersionId(modelInfo.getModelVersionId());
        }
        resourceList.add(vnfResource);
        setResourceListForVfModules(execution, resourceList, vnfResource, validate, vnf);
    }
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Vnfs(org.onap.so.serviceinstancebeans.Vnfs)

Example 3 with Vnfs

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

the class ConfigAssignVnfTest method createVnfList.

private List<Vnfs> createVnfList() {
    List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>();
    Map<String, String> instanceParam = new HashMap<>();
    instanceParam.put(INSTANCE_PARAM1_NAME, INSTANCE_PARAM1_VALUE);
    instanceParam.put(INSTANCE_PARAM2_NAME, INSTANCE_PARAM2_VALUE);
    Map<String, String> instanceParam2 = new HashMap<>();
    instanceParam2.put(INSTANCE_PARAM3_NAME, INSTANCE_PARAM3_VALUE);
    instanceParamsListSearchedVnf.add(instanceParam);
    instanceParamsListSearchedVnf.add(instanceParam2);
    Vnfs searchedVnf = createVnf(VNF_MODEL_CUSTOMIZATION_ID, instanceParamsListSearchedVnf);
    List<Map<String, String>> instanceParamsListForAnotherVnf = new ArrayList<>();
    Map<String, String> instanceParam3 = new HashMap<>();
    instanceParam3.put(INSTANCE_PARAM4_NAME, INSTANCE_PARAM4_VALUE);
    instanceParam3.put(INSTANCE_PARAM5_NAME, INSTANCE_PARAM5_VALUE);
    instanceParamsListForAnotherVnf.add(instanceParam3);
    Vnfs anotherVnf = createVnf("2d1ac656-377e-467b-be50-6ce65f66a7ca", instanceParamsListForAnotherVnf);
    List<Vnfs> vnfList = new ArrayList<>();
    vnfList.add(searchedVnf);
    vnfList.add(anotherVnf);
    return vnfList;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Vnfs(org.onap.so.serviceinstancebeans.Vnfs)

Example 4 with Vnfs

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

the class ConfigAssignVnfTest method createVnf.

private Vnfs createVnf(String vnfModelCustomizationId, List<Map<String, String>> instanceParamsList) {
    Vnfs vnf = new Vnfs();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId(vnfModelCustomizationId);
    vnf.setModelInfo(modelInfo);
    vnf.setInstanceParams(instanceParamsList);
    return vnf;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Vnfs(org.onap.so.serviceinstancebeans.Vnfs)

Example 5 with Vnfs

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

the class GenericCDSProcessingBBTest method createVnfList.

private List<Vnfs> createVnfList() {
    List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>();
    Map<String, String> instanceParam = new HashMap<>();
    instanceParam.put("sec_group", "sec_group");
    instanceParam.put("net_id", "acl-cloud-region");
    instanceParamsListSearchedVnf.add(instanceParam);
    Vnfs searchedVnf = createVnf(instanceParamsListSearchedVnf);
    List<Vnfs> vnfList = new ArrayList<>();
    vnfList.add(searchedVnf);
    return vnfList;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Vnfs(org.onap.so.serviceinstancebeans.Vnfs)

Aggregations

Vnfs (org.onap.so.serviceinstancebeans.Vnfs)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)6 VfModules (org.onap.so.serviceinstancebeans.VfModules)6 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 Networks (org.onap.so.serviceinstancebeans.Networks)4 Map (java.util.Map)3 Service (org.onap.so.serviceinstancebeans.Service)3 File (java.io.File)2 Test (org.junit.Test)2 Resources (org.onap.so.serviceinstancebeans.Resources)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1 StringUtils (org.apache.commons.lang3.StringUtils)1