Search in sources :

Example 1 with NetworkResourceCustomization

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;
}
Also used : CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization)

Example 2 with 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;
}
Also used : NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization)

Example 3 with 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));
}
Also used : CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Test(org.junit.Test)

Example 4 with NetworkResourceCustomization

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;
}
Also used : NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ValidationException(org.onap.so.exceptions.ValidationException) VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) Recipe(org.onap.so.db.catalog.beans.Recipe) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization)

Example 5 with NetworkResourceCustomization

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;
}
Also used : NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) VduException(org.onap.so.adapters.vdu.VduException) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) MsoException(org.onap.so.openstack.exceptions.MsoException) MsoOpenstackException(org.onap.so.openstack.exceptions.MsoOpenstackException) IOException(java.io.IOException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Aggregations

NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)24 Test (org.junit.Test)14 CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)14 Service (org.onap.so.db.catalog.beans.Service)10 ArrayList (java.util.ArrayList)8 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)6 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)5 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)5 File (java.io.File)4 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)4 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)3 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)3 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)3 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)3 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)3 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)3 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)3 HashMap (java.util.HashMap)2 List (java.util.List)2