use of org.onap.so.db.catalog.beans.NetworkResourceCustomization in project so by onap.
the class ToscaResourceInstaller method createNetworkResourceCustomization.
protected NetworkResourceCustomization createNetworkResourceCustomization(IEntityDetails networkEntity, ToscaResourceStructure toscaResourceStructure) {
NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
networkResourceCustomization.setModelInstanceName(testNull(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
networkResourceCustomization.setModelCustomizationUUID(testNull(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
networkResourceCustomization.setNetworkTechnology(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
networkResourceCustomization.setNetworkType(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
networkResourceCustomization.setNetworkRole(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
networkResourceCustomization.setNetworkScope(getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
return networkResourceCustomization;
}
use of org.onap.so.db.catalog.beans.NetworkResourceCustomization 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.NetworkResourceCustomization in project so by onap.
the class BBInputSetupMapperLayerTest method testMapCollectionNetworkResourceCustToNetworkResourceCust.
@Test
public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
String modelCustomizationUUID = "modelCustomizationUUID";
String modelInstanceName = "modelInstanceName";
String networkRole = "networkRole";
String networkScope = "networkScope";
String networkTechnology = "networkTechnology";
String networkType = "networkType";
NetworkResourceCustomization expected = new NetworkResourceCustomization();
expected.setModelCustomizationUUID(modelCustomizationUUID);
expected.setModelInstanceName(modelInstanceName);
expected.setNetworkRole(networkRole);
expected.setNetworkScope(networkScope);
expected.setNetworkTechnology(networkTechnology);
expected.setNetworkType(networkType);
CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
collectionNetworkResourceCust.setNetworkRole(networkRole);
collectionNetworkResourceCust.setNetworkScope(networkScope);
collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
collectionNetworkResourceCust.setNetworkType(networkType);
NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.db.catalog.beans.NetworkResourceCustomization 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.NetworkResourceCustomization 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