Search in sources :

Example 1 with ExternalTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList in project netvirt by opendaylight.

the class VpnInstanceListener method getDcGatewayTunnelInterfaceNameList.

private List<String> getDcGatewayTunnelInterfaceNameList() {
    List<String> tunnelInterfaceNameList = new ArrayList<>();
    InstanceIdentifier<DcGatewayIpList> dcGatewayIpListInstanceIdentifier = InstanceIdentifier.create(DcGatewayIpList.class);
    Optional<DcGatewayIpList> dcGatewayIpListOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, dcGatewayIpListInstanceIdentifier);
    if (!dcGatewayIpListOptional.isPresent()) {
        LOG.info("No DC gateways configured.");
        return tunnelInterfaceNameList;
    }
    List<DcGatewayIp> dcGatewayIps = dcGatewayIpListOptional.get().getDcGatewayIp();
    InstanceIdentifier<ExternalTunnelList> externalTunnelListId = InstanceIdentifier.create(ExternalTunnelList.class);
    Optional<ExternalTunnelList> externalTunnelListOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, externalTunnelListId);
    if (externalTunnelListOptional.isPresent()) {
        List<ExternalTunnel> externalTunnels = externalTunnelListOptional.get().getExternalTunnel();
        List<String> externalTunnelIpList = new ArrayList<>();
        for (ExternalTunnel externalTunnel : externalTunnels) {
            externalTunnelIpList.add(externalTunnel.getDestinationDevice());
        }
        List<String> dcGatewayIpList = new ArrayList<>();
        for (DcGatewayIp dcGatewayIp : dcGatewayIps) {
            dcGatewayIpList.add(dcGatewayIp.getIpAddress().getIpv4Address().toString());
        }
        // Find all externalTunnelIps present in dcGateWayIpList
        List<String> externalTunnelIpsInDcGatewayIpList = new ArrayList<>();
        for (String externalTunnelIp : externalTunnelIpList) {
            for (String dcGateWayIp : dcGatewayIpList) {
                if (externalTunnelIp.contentEquals(dcGateWayIp)) {
                    externalTunnelIpsInDcGatewayIpList.add(externalTunnelIp);
                }
            }
        }
        for (String externalTunnelIpsInDcGatewayIp : externalTunnelIpsInDcGatewayIpList) {
            for (ExternalTunnel externalTunnel : externalTunnels) {
                if (externalTunnel.getDestinationDevice().contentEquals(externalTunnelIpsInDcGatewayIp)) {
                    tunnelInterfaceNameList.add(externalTunnel.getTunnelInterfaceName());
                }
            }
        }
    }
    return tunnelInterfaceNameList;
}
Also used : ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) ArrayList(java.util.ArrayList) DcGatewayIpList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList) DcGatewayIp(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp)

Example 2 with ExternalTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList in project netvirt by opendaylight.

the class EvpnUtils method getExternalTunnelList.

public Optional<ExternalTunnelList> getExternalTunnelList() {
    InstanceIdentifier<ExternalTunnelList> externalTunnelListId = getExternaTunnelListIdentifier();
    ExternalTunnelList externalTunnelList = null;
    try {
        externalTunnelList = elanUtils.read2(LogicalDatastoreType.CONFIGURATION, externalTunnelListId).orNull();
    } catch (ReadFailedException e) {
        LOG.error("getExternalTunnelList: unable to read ExternalTunnelList, exception ", e);
    }
    return Optional.fromNullable(externalTunnelList);
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)

Aggregations

ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)2 ArrayList (java.util.ArrayList)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)1 DcGatewayIpList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList)1 DcGatewayIp (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp)1