Search in sources :

Example 1 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.

the class TransportZoneListener method createDPNTepInfo.

private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
    Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
    List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
    List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
    Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
    LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
    List<Subnets> subnetsList = transportZone.getSubnets();
    if (subnetsList != null) {
        for (Subnets subnet : subnetsList) {
            IpPrefix ipPrefix = subnet.getPrefix();
            IpAddress gatewayIP = subnet.getGatewayIp();
            int vlanID = subnet.getVlanId();
            LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
            List<Vteps> vtepsList = subnet.getVteps();
            if (vtepsList != null && !vtepsList.isEmpty()) {
                for (Vteps vteps : vtepsList) {
                    BigInteger dpnID = vteps.getDpnId();
                    String port = vteps.getPortname();
                    IpAddress ipAddress = vteps.getIpAddress();
                    boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
                    String tos = vteps.getOptionTunnelTos();
                    if (tos == null) {
                        tos = itmConfig.getDefaultTunnelTos();
                    }
                    LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
                    TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
                    List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
                    if (tunnelEndPointsList != null) {
                        LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
                        tunnelEndPointsList.add(tunnelEndPoints);
                    } else {
                        LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
                        tunnelEndPointsList = new ArrayList<>();
                        tunnelEndPointsList.add(tunnelEndPoints);
                        mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
                    }
                }
            }
        }
    }
    if (!mapDPNToTunnelEndpt.isEmpty()) {
        LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
        for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
            DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
            dpnTepInfo.add(newDpnTepsInfo);
        }
    }
    return dpnTepInfo;
}
Also used : ArrayList(java.util.ArrayList) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) BigInteger(java.math.BigInteger) List(java.util.List) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 2 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.

the class ItmUtils method removeTransportZoneMembership.

public static List<TzMembership> removeTransportZoneMembership(TunnelEndPoints endPts, List<TzMembership> zones) {
    LOG.trace(" RemoveTransportZoneMembership TEPs {}, Membership to be removed {} ", endPts, zones);
    List<TzMembership> existingTzList = new ArrayList<>(endPts.getTzMembership());
    for (TzMembership membership : zones) {
        existingTzList.remove(new TzMembershipBuilder().setZoneName(membership.getZoneName()).build());
    }
    LOG.debug("Modified Membership List {}", existingTzList);
    return existingTzList;
}
Also used : ArrayList(java.util.ArrayList) TzMembershipBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembershipBuilder) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)

Example 3 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.

the class ItmExternalTunnelDeleteWorker method tunnelsDeletion.

private static void tunnelsDeletion(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> cfgdhwVteps, TransportZone originalTZone, WriteTransaction writeTransaction, DataBroker dataBroker) {
    if (cfgdDpnList != null) {
        for (DPNTEPsInfo dpn : cfgdDpnList) {
            if (dpn.getTunnelEndPoints() != null) {
                for (TunnelEndPoints srcTep : dpn.getTunnelEndPoints()) {
                    for (TzMembership zone : srcTep.getTzMembership()) {
                        deleteTunnelsInTransportZone(zone.getZoneName(), dpn, srcTep, cfgdhwVteps, dataBroker, writeTransaction);
                    }
                }
            }
        }
    }
    if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
        for (HwVtep hwTep : cfgdhwVteps) {
            LOG.trace("processing hwTep from list {}", hwTep);
            for (HwVtep hwTepRemote : cfgdhwVteps) {
                if (!hwTep.getHwIp().equals(hwTepRemote.getHwIp())) {
                    deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
                }
            }
            // do we need to check tunnel type?
            LOG.trace("subnets under tz {} are {}", originalTZone.getZoneName(), originalTZone.getSubnets());
            if (originalTZone.getSubnets() != null && !originalTZone.getSubnets().isEmpty()) {
                for (Subnets sub : originalTZone.getSubnets()) {
                    if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
                        for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
                            LOG.trace("hwtepDS exists {}", hwVtepDS);
                            // for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
                            if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
                                // dont delete tunnels with self
                                continue;
                            }
                            // TOR-TOR
                            LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
                            deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), originalTZone.getTunnelType(), writeTransaction);
                        }
                    }
                    if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
                        for (Vteps vtep : sub.getVteps()) {
                            // TOR-OVS
                            LOG.trace("deleting tor-css-tor {} and {}", hwTep, vtep);
                            String parentIf = ItmUtils.getInterfaceName(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId());
                            deleteTrunksOvsTor(dataBroker, vtep.getDpnId(), parentIf, vtep.getIpAddress(), hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), originalTZone.getTunnelType(), writeTransaction);
                        }
                    }
                }
            }
        }
    }
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 4 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.

the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.

private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
    String[] params = entityId.split(":");
    if (params.length < 2) {
        LOG.error("Not enough arguments..Exiting...");
        return null;
    } else if (params.length > 2) {
        LOG.info("Ignoring extra parameter and proceeding...");
    }
    // ToDo:- Need to add more validations
    this.tzName = params[0];
    String ipAddress = params[1];
    transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
    if (transportZone == null) {
        LOG.error("Transportzone name {} is not valid.", tzName);
        return null;
    }
    for (Subnets sub : transportZone.getSubnets()) {
        if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
            LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
        }
        for (Vteps vtep : sub.getVteps()) {
            if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
                List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
                LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
                // OfTunnels is false byDefault
                TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
                List<TunnelEndPoints> teps = new ArrayList<>();
                teps.add(tunnelEndPoints);
                return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
            }
        }
    }
    return null;
}
Also used : TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ArrayList(java.util.ArrayList) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)

Example 5 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.

the class ItmUtils method createTransportZoneMembership.

public static List<TzMembership> createTransportZoneMembership(String zoneName) {
    List<TzMembership> zones = new ArrayList<>();
    zones.add(new TzMembershipBuilder().setZoneName(zoneName).build());
    return zones;
}
Also used : ArrayList(java.util.ArrayList) TzMembershipBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembershipBuilder) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)

Aggregations

TzMembership (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)6 ArrayList (java.util.ArrayList)5 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)4 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)4 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)3 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)3 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)3 BigInteger (java.math.BigInteger)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 TzMembershipBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembershipBuilder)2 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)2 ItmTepsNotHostedMoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedMoveWorker)1 ItmTepsNotHostedRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedRemoveWorker)1 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)1