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));
}
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;
}
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();
}
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;
}
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;
}
Aggregations