Search in sources :

Example 1 with Service

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

the class ConfigAssignVnf method setUserParamsInConfigAssignPropertiesForVnf.

private void setUserParamsInConfigAssignPropertiesForVnf(ConfigAssignPropertiesForVnf configAssignProperties, List<Map<String, Object>> userParamsFromRequest, GenericVnf vnf) throws Exception {
    Service service = getServiceFromRequestUserParams(userParamsFromRequest);
    List<Map<String, String>> instanceParamsList = getInstanceParamForVnf(service, vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
    instanceParamsList.forEach(instanceParamsMap -> instanceParamsMap.forEach(configAssignProperties::setUserParam));
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) Map(java.util.Map)

Example 2 with Service

use of org.onap.so.serviceinstancebeans.Service 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 3 with Service

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

the class UserParamsServiceTraversal method getResourceListFromUserParams.

public List<Resource> getResourceListFromUserParams(DelegateExecution execution, List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction) throws IOException {
    if (userParams != null) {
        for (Map<String, Object> params : userParams) {
            if (params.containsKey(USER_PARAM_SERVICE)) {
                ObjectMapper obj = new ObjectMapper();
                String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
                Service validate = obj.readValue(input, Service.class);
                return getResourceList(execution, serviceModelVersionId, requestAction, validate);
            }
        }
    }
    return Collections.emptyList();
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with Service

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

the class ConfigAssignVnfTest method createService.

private Service createService(List<Vnfs> vnfList) {
    Service service = new Service();
    Resources resources = new Resources();
    resources.setVnfs(vnfList);
    service.setResources(resources);
    return service;
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) Resources(org.onap.so.serviceinstancebeans.Resources)

Example 5 with Service

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

the class GenericPnfCDSControllerRunnableBBTest method createService.

private Service createService(List<Pnfs> pnfList) {
    Service service = new Service();
    Resources resources = new Resources();
    resources.setPnfs(pnfList);
    service.setResources(resources);
    return service;
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) Resources(org.onap.so.serviceinstancebeans.Resources)

Aggregations

Service (org.onap.so.serviceinstancebeans.Service)19 Resources (org.onap.so.serviceinstancebeans.Resources)7 JsonObject (com.google.gson.JsonObject)4 Map (java.util.Map)4 Test (org.junit.Test)4 PayloadGenerationException (org.onap.so.client.exception.PayloadGenerationException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Networks (org.onap.so.serviceinstancebeans.Networks)3 VfModules (org.onap.so.serviceinstancebeans.VfModules)3 Vnfs (org.onap.so.serviceinstancebeans.Vnfs)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RequestParameters (org.onap.so.serviceinstancebeans.RequestParameters)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Actions (org.onap.so.apihandlerinfra.Actions)1 ApplyUpdatedConfigValidation (org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation)1 CloudConfigurationValidation (org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation)1 ConfigurationParametersValidation (org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation)1 CustomWorkflowValidation (org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation)1