use of org.onap.so.db.catalog.beans.NetworkResource in project so by onap.
the class ToscaResourceInstaller method createNetworkResource.
protected NetworkResource createNetworkResource(IEntityDetails vlEntity, ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
NetworkResource networkResource = new NetworkResource();
String providerNetwork = getLeafPropertyValue(vlEntity, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
if ("true".equalsIgnoreCase(providerNetwork)) {
networkResource.setNeutronNetworkType(PROVIDER);
} else {
networkResource.setNeutronNetworkType(BASIC);
}
networkResource.setModelName(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
networkResource.setModelInvariantUUID(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
networkResource.setModelUUID(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
networkResource.setModelVersion(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
networkResource.setAicVersionMax(aicMax);
networkResource.setAicVersionMin(aicMin);
networkResource.setToscaNodeType(vlEntity.getToscaType());
networkResource.setDescription(testNull(vlEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
networkResource.setOrchestrationMode(HEAT);
networkResource.setHeatTemplate(heatTemplate);
return networkResource;
}
use of org.onap.so.db.catalog.beans.NetworkResource in project so by onap.
the class ASDCRestInterfaceTest method test_Vcpe_Infra_Distribution.
@Test
public void test_Vcpe_Infra_Distribution() throws Exception {
wireMockServer.stubFor(post(urlPathMatching("/aai/.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.ACCEPTED.value())));
String resourceLocation = "src/test/resources/resource-examples/vcpe-infra/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demovcpeinfra-notification.json"), NotificationDataImpl.class);
headers.add("resource-location", resourceLocation);
HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, String.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
Optional<ToscaCsar> toscaCsar = toscaCsarRepo.findById("144606d8-a505-4ba0-90a9-6d1c6219fc6b");
assertTrue(toscaCsar.isPresent());
assertEquals("service-Demovcpeinfra-csar.csar", toscaCsar.get().getName());
Optional<Service> service = serviceRepo.findById("8a77cbbb-9850-40bb-a42f-7aec8e3e6ab7");
assertTrue(service.isPresent());
assertEquals("demoVCPEInfra", service.get().getModelName());
Optional<NetworkResource> networkResource = networkRepo.findById("89789b26-a46b-4cee-aed0-d46e21f93a5e");
assertTrue(networkResource.isPresent());
assertEquals("Generic NeutronNet", networkResource.get().getModelName());
List<VnfResourceCustomization> vnfCustomizationResources = vnfCustRepo.findByModelCustomizationUUID("01564fe7-0541-4d92-badc-464cc35f83ba");
for (VnfResourceCustomization vnfResourceCustomization : vnfCustomizationResources) {
assertTrue(vnfResourceCustomization.getVfModuleCustomizations().stream().anyMatch(vfModuleCust -> "354b1e83-47db-4af1-8af4-9c14b03b482d".equals(vfModuleCust.getModelCustomizationUUID())));
}
}
use of org.onap.so.db.catalog.beans.NetworkResource in project so by onap.
the class ToscaResourceInstaller method createNetwork.
protected NetworkResourceCustomization createNetwork(IEntityDetails networkEntity, ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin, Service service) {
NetworkResourceCustomization networkResourceCustomization = networkCustomizationRepo.findOneByModelCustomizationUUID(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
boolean networkUUIDsMatch = true;
// If not we'll update the Customization record with latest from the distribution
if (networkResourceCustomization != null) {
String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
String latestNetworkModelUUID = networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
networkUUIDsMatch = false;
}
}
if (networkResourceCustomization != null && !networkUUIDsMatch) {
NetworkResource networkResource = createNetworkResource(networkEntity, toscaResourceStructure, heatTemplate, aicMax, aicMin);
networkResourceCustomization.setNetworkResource(networkResource);
networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
} else if (networkResourceCustomization == null) {
networkResourceCustomization = createNetworkResourceCustomization(networkEntity, toscaResourceStructure);
NetworkResource networkResource = findExistingNetworkResource(service, networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (networkResource == null)
networkResource = createNetworkResource(networkEntity, toscaResourceStructure, heatTemplate, aicMax, aicMin);
networkResource.addNetworkResourceCustomization(networkResourceCustomization);
networkResourceCustomization.setNetworkResource(networkResource);
}
return networkResourceCustomization;
}
use of org.onap.so.db.catalog.beans.NetworkResource in project so by onap.
the class RequestHandlerUtils method getNetworkUri.
private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException {
String defaultNetworkType = getDefaultModel(sir);
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
String modelName = modelInfo.getModelName();
Recipe recipe = null;
if (modelInfo.getModelCustomizationId() != null) {
NetworkResourceCustomization networkResourceCustomization = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId());
if (networkResourceCustomization != null) {
NetworkResource networkResource = networkResourceCustomization.getNetworkResource();
if (networkResource != null) {
if (modelInfo.getModelVersionId() == null) {
modelInfo.setModelVersionId(networkResource.getModelUUID());
}
recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString());
} else {
throw new ValidationException("no catalog entry found");
}
} else if (action != Action.deleteInstance) {
throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true);
}
} else {
// ok for version < 3 and action delete
if (modelName != null) {
recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action.toString());
}
}
if (recipe == null) {
recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(defaultNetworkType, action.toString());
}
return recipe != null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null;
}
use of org.onap.so.db.catalog.beans.NetworkResource in project so by onap.
the class MsoHeatUtils method getNetworkHeatTimeoutValue.
public int getNetworkHeatTimeoutValue(String modelCustomizationUuid, String networkType) {
int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
try {
NetworkResource networkResource = null;
if (isBlank(modelCustomizationUuid)) {
if (isNotBlank(networkType)) {
networkResource = catalogClient.getNetworkResourceByModelName(networkType);
}
} else {
NetworkResourceCustomization nrc = catalogClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelCustomizationUuid);
if (nrc != null) {
networkResource = nrc.getNetworkResource();
}
}
if (networkResource != null) {
networkResource.getHeatTemplate().getTimeoutMinutes();
HeatTemplate heat = networkResource.getHeatTemplate();
if (heat != null && heat.getTimeoutMinutes() != null) {
if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
timeoutMinutes = heat.getTimeoutMinutes();
}
}
} else {
logger.debug("Unable to find Network Resource with model customization uuid {} or network type {}. Using default timeout {}", modelCustomizationUuid, networkType, timeoutMinutes);
}
} catch (Exception e) {
logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes, e);
}
return timeoutMinutes;
}
Aggregations