Search in sources :

Example 11 with Resource

use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.

the class VnfEBBLoader method findVnfWithGivenIdAndAddCustomizationUUID.

private void findVnfWithGivenIdAndAddCustomizationUUID(ServiceInstance serviceInstanceMSO, String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource serviceResource, DelegateExecution execution) {
    for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
        if (vnf.getVnfId().equals(vnfId)) {
            aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
            org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
            Resource vnfResource = new Resource(WorkflowType.VNF, aaiGenericVnf.getModelCustomizationId(), false, serviceResource);
            vnfResource.setModelCustomizationId(aaiGenericVnf.getModelCustomizationId());
            vnfResource.setModelVersionId(aaiGenericVnf.getModelVersionId());
            resourceList.add(vnfResource);
            processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution);
            processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource);
            break;
        }
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 12 with Resource

use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.

the class VnfEBBLoader method addConfigToResources.

private void addConfigToResources(Optional<Relationships> relationshipsOp, List<Resource> resourceList, Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) {
    if (relationshipsOp.isPresent()) {
        Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
        if (config.isPresent()) {
            aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
            resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false, vfModuleResource));
        }
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 13 with Resource

use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.

the class ServiceEBBLoader method traverseNetworkCollectionResourceCustomization.

private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) {
    if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, serviceResource, collectionResourceCustomization))
        return;
    int minNetworks = 0;
    org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = collectionResourceCustomization.getCollectionResource().getInstanceGroup();
    CollectionResourceInstanceGroupCustomization collectionInstCust = null;
    if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) {
        for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup.getCollectionInstanceGroupCustomizations()) {
            if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
                collectionInstCust = collectionInstanceGroupTemp;
                break;
            }
        }
        if (interfaceNetworkQuantityIsAvailableInCollection(collectionInstCust)) {
            minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
        }
    }
    logger.debug("minNetworks: {}", minNetworks);
    CollectionNetworkResourceCustomization collectionNetworkResourceCust = getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup);
    for (int i = 0; i < minNetworks; i++) {
        if (collectionNetworkResourceCust != null) {
            Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, collectionNetworkResourceCust.getModelCustomizationUUID(), false, serviceResource);
            resource.setVirtualLinkKey(Integer.toString(i));
            resourceList.add(resource);
        }
    }
}
Also used : CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)

Example 14 with Resource

use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.

the class ServiceEBBLoader method collectionResourceCustomizationShouldNotBeProcessed.

private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList, Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) {
    if (collectionResourceCustomization == null) {
        logger.debug("No Network Collection Customization found");
        return true;
    }
    resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, collectionResourceCustomization.getModelCustomizationUUID(), false, serviceResource));
    logger.debug("Found a network collection");
    if (collectionResourceCustomization.getCollectionResource() == null) {
        logger.debug("No Network Collection found. collectionResource is null");
        return true;
    }
    if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() == null) {
        logger.debug("No Instance Group found for network collection.");
        return true;
    }
    String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType();
    if (!toscaNodeTypeHasNetworkCollection(toscaNodeType)) {
        logger.debug("Instance Group tosca node type does not contain NetworkCollection:  {}", toscaNodeType);
        return true;
    }
    return false;
}
Also used : Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 15 with Resource

use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.

the class ServiceEBBLoader method traverseAAIService.

public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) {
    try {
        ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
        org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
        var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
        serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
        serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId());
        resourceList.add(serviceResource);
        traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        if (serviceInstanceMSO.getNetworks() != null) {
            for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO.getNetworks()) {
                aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
                Resource networkResource = new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource);
                ModelInfoNetwork modelInfoNetwork = network.getModelInfoNetwork();
                if (modelInfoNetwork != null) {
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                    networkResource.setModelVersionId(modelInfoNetwork.getModelUUID());
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                }
                resourceList.add(networkResource);
            }
        }
        if (serviceInstanceMSO.getCollection() != null) {
            logger.debug("found networkcollection");
            aaiResourceIds.add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
            resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId(), false, serviceResource));
        }
        if (serviceInstanceMSO.getConfigurations() != null) {
            for (Configuration config : serviceInstanceMSO.getConfigurations()) {
                Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId());
                if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
                    for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
                        if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) {
                            aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
                            resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false, serviceResource));
                            break;
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        logger.error("Exception in traverseAAIService", ex);
        buildAndThrowException(execution, "Could not find existing Service Instance or related Instances to execute the request on.");
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)

Aggregations

Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)40 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)9 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)8 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)6 Pair (org.javatuples.Pair)5 Service (org.onap.so.db.catalog.beans.Service)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 Mockito.anyString (org.mockito.Mockito.anyString)3 Relationship (org.onap.aai.domain.yang.Relationship)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)3 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)3