use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class AAIObjectMapperTest method vfModuleMap.
@Test
public void vfModuleMap() throws Exception {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("a");
vfModule.setVfModuleName("b");
vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelCustomizationUUID("f");
modelInfoVfModule.setModelInvariantUUID("g");
modelInfoVfModule.setModelUUID("h");
modelInfoVfModule.setIsBaseBoolean(false);
vfModule.setModelInfoVfModule(modelInfoVfModule);
org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
ObjectMapper omapper = new ObjectMapper();
org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
assertThat(reqMapper1, sameBeanAs(AAIVfModule));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class AAIObjectMapperTest method vfModuleBaseMap.
@Test
public void vfModuleBaseMap() throws Exception {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("a");
vfModule.setVfModuleName("b");
vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelCustomizationUUID("f");
modelInfoVfModule.setModelInvariantUUID("g");
modelInfoVfModule.setModelUUID("h");
modelInfoVfModule.setIsBaseBoolean(true);
vfModule.setModelInfoVfModule(modelInfoVfModule);
org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
ObjectMapper omapper = new ObjectMapper();
org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
assertThat(reqMapper1, sameBeanAs(AAIVfModule));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class BBInputSetup method createVfModule.
protected VfModule createVfModule(Map<ResourceKey, String> lookupKeyMap, String vfModuleId, String instanceName, List<Map<String, String>> instanceParams) {
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
VfModule vfModule = new VfModule();
vfModule.setVfModuleId(vfModuleId);
vfModule.setVfModuleName(instanceName);
vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
if (instanceParams != null) {
for (Map<String, String> params : instanceParams) {
vfModule.getCloudParams().putAll(params);
}
}
return vfModule;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class BBInputSetup method mapCatalogVfModule.
protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) {
if (modelInfo.getModelCustomizationUuid() != null) {
modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
}
VnfResourceCustomization vnfResourceCustomization = null;
for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) {
vnfResourceCustomization = resourceCust;
break;
}
}
VfModuleCustomization vfResourceCustomization = null;
if (vnfResourceCustomization != null) {
vfResourceCustomization = // Convert to steam
vnfResourceCustomization.getVfModuleCustomizations().stream().filter(// find
x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID())).findAny().orElse(null);
}
if (vfResourceCustomization == null) {
vfResourceCustomization = bbInputSetupUtils.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
}
if (vfResourceCustomization != null) {
vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization));
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class BBInputSetup method populateVfModule.
protected void populateVfModule(BBInputSetupParameter parameter) throws Exception {
String vnfModelCustomizationUUID = null;
String replaceVnfModelCustomizationUUID = null;
if (parameter.getRelatedInstanceList() != null) {
for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
if (parameter.getIsReplace()) {
replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
} else {
vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
}
}
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) {
parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, relatedInstance.getInstanceId());
}
}
}
GenericVnf vnf = null;
for (GenericVnf tempVnf : parameter.getServiceInstance().getVnfs()) {
if (tempVnf.getVnfId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID))) {
vnf = tempVnf;
vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
ModelInfo vnfModelInfo = new ModelInfo();
if (parameter.getIsReplace()) {
vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getNewService());
} else {
vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getCurrentService());
}
Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, parameter.getModelInfo(), parameter.getCloudConfiguration().getCloudOwner(), parameter.getCloudConfiguration().getLcpCloudRegionId(), parameter.getLookupKeyMap());
if (volumeGroupIdOp.isPresent()) {
parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
}
break;
}
}
if (vnf != null) {
VfModule vfModule = null;
for (VfModule vfModuleTemp : vnf.getVfModules()) {
if (parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
vfModule = vfModuleTemp;
}
String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModuleTemp.getVfModuleId()).getModelCustomizationId();
ModelInfo modelInfoVfModule = new ModelInfo();
modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
if (parameter.getIsReplace() && parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
} else {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
}
}
if (vfModule == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) {
vfModule = createVfModule(parameter.getLookupKeyMap(), parameter.getResourceId(), parameter.getInstanceName(), parameter.getInstanceParams());
vnf.getVfModules().add(vfModule);
if (parameter.getIsReplace()) {
mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
} else {
mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
}
}
if (vfModule != null && vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null && vfModule.getModelInfoVfModule().getModelName().contains("helm")) {
parameter.setIsHelm(true);
}
} else {
logger.debug("Related VNF instance Id not found: {}", parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID));
throw new Exception("Could not find relevant information for related VNF");
}
}
Aggregations