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