Search in sources :

Example 1 with LogicalLinks

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

the class ServicePluginFactory method getTPsfromAAI.

// This method returns Local and remote TPs information from AAI
public Map getTPsfromAAI(String serviceName) {
    Map<String, Object> tpInfo = new HashMap<>();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLinks());
    AAIResourcesClient client = new AAIResourcesClient();
    Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri);
    if (result.isPresent()) {
        LogicalLinks links = result.get();
        LogicalLink link = selectLogicalLink(links.getLogicalLink(), serviceName);
        if (link != null) {
            boolean isRemoteLink = false;
            logger.info("processing link :{}", link.getLinkName());
            AAIResultWrapper wrapper = new AAIResultWrapper(link);
            Optional<Relationships> optRelationships = wrapper.getRelationships();
            List<AAIResourceUri> pInterfaces = new ArrayList<>();
            if (optRelationships.isPresent()) {
                Relationships relationships = optRelationships.get();
                if (!relationships.getRelatedUris(Types.EXT_AAI_NETWORK).isEmpty()) {
                    isRemoteLink = true;
                }
                pInterfaces.addAll(relationships.getRelatedUris(Types.P_INTERFACE));
                if (isRemoteLink) {
                    // find remote p interface
                    AAIResourceUri localTP = null;
                    AAIResourceUri remoteTP = null;
                    AAIResourceUri pInterface0 = pInterfaces.get(0);
                    if (isRemotePInterface(client, pInterface0)) {
                        remoteTP = pInterfaces.get(0);
                        localTP = pInterfaces.get(1);
                    } else {
                        localTP = pInterfaces.get(0);
                        remoteTP = pInterfaces.get(1);
                    }
                    tpInfo = getTPInfo(client, localTP, remoteTP);
                }
            }
        }
    }
    return tpInfo;
}
Also used : HashMap(java.util.HashMap) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) LogicalLink(org.onap.aai.domain.yang.LogicalLink) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) LogicalLinks(org.onap.aai.domain.yang.LogicalLinks) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LogicalLink (org.onap.aai.domain.yang.LogicalLink)1 LogicalLinks (org.onap.aai.domain.yang.LogicalLinks)1 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1