Search in sources :

Example 1 with Relationship

use of org.onap.aai.domain.yang.Relationship 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)

Example 2 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class AAITransactionalClient method buildRelationship.

private Relationship buildRelationship(AAIResourceUri uri, Optional<AAIEdgeLabel> label) {
    final Relationship result = new Relationship();
    result.setRelatedLink(uri.build().toString());
    if (label.isPresent()) {
        result.setRelationshipLabel(label.toString());
    }
    return result;
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship)

Example 3 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class AAIResourcesClientTest method buildRelationshipTest.

@Test
public void buildRelationshipTest() {
    AAIResourcesClient client = aaiClient;
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test"));
    Relationship relationship = new Relationship();
    relationship.setRelatedLink(uri.build().toString());
    Relationship actual = client.buildRelationship(uri);
    assertThat("expect equal no label", actual, sameBeanAs(relationship));
    relationship.setRelationshipLabel(AAIEdgeLabel.USES.toString());
    actual = client.buildRelationship(uri, AAIEdgeLabel.USES);
    assertThat("expect equal has label", actual, sameBeanAs(relationship));
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Test(org.junit.Test)

Example 4 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class ServicePluginFactory method getTpInfoFromLocalTp.

private void getTpInfoFromLocalTp(Map<String, Object> tpInfo, Optional<Pnf> optLocalPnf) {
    if (optLocalPnf.isPresent()) {
        Pnf localPnf = optLocalPnf.get();
        for (Relationship rel : localPnf.getRelationshipList().getRelationship()) {
            if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) {
                String[] networkRef = rel.getRelatedLink().substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-");
                if (networkRef.length == 6) {
                    tpInfo.put("local-access-provider-id", networkRef[1]);
                    tpInfo.put("local-access-client-id", networkRef[3]);
                    tpInfo.put("local-access-topology-id", networkRef[5]);
                }
            }
        }
    }
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship) Pnf(org.onap.aai.domain.yang.Pnf)

Example 5 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class ServicePluginFactory method selectLogicalLink.

private LogicalLink selectLogicalLink(List<LogicalLink> logicalLinks, String svcName) {
    Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst();
    if (customType.isPresent()) {
        String[] allowedList = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local").split(",");
        for (String localTp : allowedList) {
            for (LogicalLink link : logicalLinks) {
                for (Relationship relationship : link.getRelationshipList().getRelationship()) {
                    if (relationship.getRelatedTo().equals("p-interface") && relationship.getRelatedLink().contains("-ltpId-" + localTp) && link.getOperationalStatus().equalsIgnoreCase("up")) {
                        logger.info("linkname:{} is matching with allowed list", link.getLinkName());
                        return link;
                    }
                }
            }
        }
        logger.error("There is no matching logical link for allowed list :{}", Arrays.toString(allowedList));
        return null;
    } else {
        logger.info("link customization is not required");
        return logicalLinks.get(0);
    }
}
Also used : LogicalLink(org.onap.aai.domain.yang.LogicalLink) Relationship(org.onap.aai.domain.yang.Relationship)

Aggregations

Relationship (org.onap.aai.domain.yang.Relationship)26 Test (org.junit.Test)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)6 ArrayList (java.util.ArrayList)4 VfModule (org.onap.aai.domain.yang.VfModule)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)4 Server (org.openstack4j.model.compute.Server)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IOException (java.io.IOException)2 List (java.util.List)2 Pair (org.javatuples.Pair)2 Ignore (org.junit.Ignore)2