Search in sources :

Example 6 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)

Example 7 with Relationship

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

the class ServicePluginFactory method getTpInfoFromRemoteTp.

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

Example 8 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 9 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 10 with Relationship

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

the class AaiConnectionTest method testRelatedToProperty.

@Test
public void testRelatedToProperty() {
    // given
    final Relationship relationship = new Relationship();
    final RelatedToProperty property = new RelatedToProperty();
    property.setPropertyKey(KEY);
    property.setPropertyValue(VALUE);
    relationship.getRelatedToProperty().add(property);
    // when
    final String value = AaiConnection.getRelatedToProperty(relationship, KEY);
    // then
    assertEquals(VALUE, value);
}
Also used : RelatedToProperty(org.onap.aai.domain.yang.RelatedToProperty) Relationship(org.onap.aai.domain.yang.Relationship) Test(org.junit.Test)

Aggregations

Relationship (org.onap.aai.domain.yang.Relationship)28 Test (org.junit.Test)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)6 VfModule (org.onap.aai.domain.yang.VfModule)5 ArrayList (java.util.ArrayList)4 GenericVnf (org.onap.aai.domain.yang.GenericVnf)4 RelationshipData (org.onap.aai.domain.yang.RelationshipData)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