use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.
the class CatalogDbAdapterRest method serviceAllottedResourcesImpl.
public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
QueryAllottedResourceCustomization qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
List<AllottedResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (smUuid != null && !"".equals(smUuid)) {
uuid = smUuid;
service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
} else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
uuid = serviceModelInvariantUuid;
if (smVer != null && !"".equals(smVer)) {
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
} else {
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
}
} else if (aUuid != null && !"".equals(aUuid)) {
uuid = aUuid;
ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service != null)
ret = service.getAllottedCustomizations();
if (ret == null || ret.isEmpty()) {
logger.debug("AllottedResourceCustomization not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryAllottedResourceCustomization();
} else {
qryResp = new QueryAllottedResourceCustomization(ret);
logger.debug("AllottedResourceCustomization qryResp= {}", qryResp);
}
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryAllottedResourceCustomization", e);
CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
}).build();
}
}
use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.
the class ToscaResourceInstaller method createAllottedResource.
protected AllottedResourceCustomization createAllottedResource(IEntityDetails arEntity, ToscaResourceStructure toscaResourceStructure, Service service) {
AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo.findOneByModelCustomizationUUID(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
if (allottedResourceCustomization == null) {
AllottedResource allottedResource = findExistingAllottedResource(service, arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (allottedResource == null)
allottedResource = createAR(arEntity);
toscaResourceStructure.setAllottedResource(allottedResource);
allottedResourceCustomization = createAllottedResourceCustomization(arEntity, toscaResourceStructure);
allottedResourceCustomization.setAllottedResource(allottedResource);
allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
}
return allottedResourceCustomization;
}
use of org.onap.so.db.catalog.beans.AllottedResourceCustomization in project so by onap.
the class ToscaResourceStructureTest method toscaResourceStructureBeanTest.
@Test
public void toscaResourceStructureBeanTest() {
artifactInfo = mock(ArtifactInfoImpl.class);
sdcCsarHelper = mock(SdcCsarHelperImpl.class);
toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
toscaResourceStructure.setCatalogService(new Service());
toscaResourceStructure.setNetworkTypes(new ArrayList<>());
toscaResourceStructure.setVfTypes(new ArrayList<>());
toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
toscaResourceStructure.setCatalogVfModule(new VfModule());
toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
toscaResourceStructure.setAllottedResource(new AllottedResource());
toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
toscaResourceStructure.setToscaArtifact(artifactInfo);
toscaResourceStructure.setToscaCsar(new ToscaCsar());
toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
toscaResourceStructure.setServiceVersion("serviceVersion");
toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
toscaResourceStructure.setVfModule(new VfModule());
toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
toscaResourceStructure.setSuccessfulDeployment();
assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
assertThat(toscaResourceStructure.getCatalogResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(), sameBeanAs(new NetworkResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
assertThat(toscaResourceStructure.getAllottedResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
}
Aggregations