Search in sources :

Example 16 with DPNTEPsInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.

the class TransportZoneListener method createDPNTepInfoFromNotHosted.

private List<DPNTEPsInfo> createDPNTepInfoFromNotHosted(TransportZone tzNew) {
    Map<BigInteger, List<TunnelEndPoints>> mapNotHostedDPNToTunnelEndpt = new ConcurrentHashMap<>();
    List<DPNTEPsInfo> notHostedDpnTepInfo = new ArrayList<>();
    String newZoneName = tzNew.getZoneName();
    List<TzMembership> zones = ItmUtils.createTransportZoneMembership(newZoneName);
    Class<? extends TunnelTypeBase> tunnelType = tzNew.getTunnelType();
    TepsInNotHostedTransportZone tepsInNotHostedTransportZone = getNotHostedTransportZone(newZoneName).get();
    if (tepsInNotHostedTransportZone == null) {
        return notHostedDpnTepInfo;
    }
    List<UnknownVteps> unVtepsLst = tepsInNotHostedTransportZone.getUnknownVteps();
    List<Vteps> vtepsList = new ArrayList<>();
    if (unVtepsLst != null && !unVtepsLst.isEmpty()) {
        for (UnknownVteps vteps : unVtepsLst) {
            BigInteger dpnID = vteps.getDpnId();
            String port = ITMConstants.DUMMY_PORT;
            int vlanID = ITMConstants.DUMMY_VLANID;
            IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
            IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
            IpAddress ipAddress = vteps.getIpAddress();
            boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOfTunnel());
            String tos = vteps.getOptionTunnelTos();
            if (tos == null) {
                tos = itmConfig.getDefaultTunnelTos();
            }
            TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
            List<TunnelEndPoints> tunnelEndPointsList = mapNotHostedDPNToTunnelEndpt.get(dpnID);
            if (tunnelEndPointsList != null) {
                tunnelEndPointsList.add(tunnelEndPoints);
            } else {
                tunnelEndPointsList = new ArrayList<>();
                tunnelEndPointsList.add(tunnelEndPoints);
                mapNotHostedDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
            }
            Vteps newVtep = createVtepFromUnKnownVteps(dpnID, ipAddress, ITMConstants.DUMMY_PORT);
            vtepsList.add(newVtep);
            // Enqueue 'remove TEP from TepsNotHosted list' operation
            // into DataStoreJobCoordinator
            ItmTepsNotHostedRemoveWorker removeWorker = new ItmTepsNotHostedRemoveWorker(newZoneName, ipAddress, dpnID, dataBroker);
            jobCoordinator.enqueueJob(newZoneName, removeWorker);
        }
    }
    // Enqueue 'add TEP received from southbound OVSDB into ITM config DS' operation
    // into DataStoreJobCoordinator
    ItmTepsNotHostedMoveWorker moveWorker = new ItmTepsNotHostedMoveWorker(vtepsList, newZoneName, dataBroker);
    jobCoordinator.enqueueJob(newZoneName, moveWorker);
    if (mapNotHostedDPNToTunnelEndpt.size() > 0) {
        for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapNotHostedDPNToTunnelEndpt.entrySet()) {
            DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
            notHostedDpnTepInfo.add(newDpnTepsInfo);
        }
    }
    return notHostedDpnTepInfo;
}
Also used : ItmTepsNotHostedMoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedMoveWorker) ArrayList(java.util.ArrayList) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) 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) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) List(java.util.List) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepsNotHostedRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedRemoveWorker) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership) 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 17 with DPNTEPsInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.

the class TransportZoneListener method add.

@Override
public void add(@Nonnull TransportZone transportZone) {
    LOG.debug("Received Transport Zone Add Event: {}", transportZone);
    List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
    List<HwVtep> hwVtepList = createhWVteps(transportZone);
    opDpnList.addAll(getDPNTepInfoFromNotHosted(transportZone));
    LOG.trace("Add: Operational dpnTepInfo - Before invoking ItmManager {}", opDpnList);
    if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
        LOG.trace("Add: Invoking ItmManager with DPN List {} ", opDpnList);
        LOG.trace("Add: Invoking ItmManager with hwVtep List {} ", hwVtepList);
        jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
    }
}
Also used : HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 18 with DPNTEPsInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.

the class TransportZoneListener method update.

@Override
public void update(@Nonnull TransportZone originalTransportZone, @Nonnull TransportZone updatedTransportZone) {
    LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone, updatedTransportZone);
    List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
    List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
    List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
    oldDpnTepsListcopy.addAll(oldDpnTepsList);
    LOG.trace("oldcopy0 {}", oldDpnTepsListcopy);
    List<DPNTEPsInfo> newDpnTepsListcopy = new ArrayList<>();
    newDpnTepsListcopy.addAll(newDpnTepsList);
    LOG.trace("newcopy0 {}", newDpnTepsListcopy);
    oldDpnTepsList.removeAll(newDpnTepsListcopy);
    newDpnTepsList.removeAll(oldDpnTepsListcopy);
    LOG.trace("oldDpnTepsList {}", oldDpnTepsList);
    LOG.trace("newDpnTepsList {}", newDpnTepsList);
    LOG.trace("oldcopy {}", oldDpnTepsListcopy);
    LOG.trace("newcopy {}", newDpnTepsListcopy);
    LOG.trace("oldcopy Size {}", oldDpnTepsList.size());
    LOG.trace("newcopy Size {}", newDpnTepsList.size());
    if (!newDpnTepsList.isEmpty()) {
        LOG.trace("Adding TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
    }
    if (!oldDpnTepsList.isEmpty()) {
        LOG.trace("Removing TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
    }
    List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
    List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
    List<HwVtep> oldHwListcopy = new ArrayList<>();
    oldHwListcopy.addAll(oldHwList);
    LOG.trace("oldHwListcopy0 {}", oldHwListcopy);
    List<HwVtep> newHwListcopy = new ArrayList<>();
    newHwListcopy.addAll(newHwList);
    LOG.trace("newHwListcopy0 {}", newHwListcopy);
    oldHwList.removeAll(newHwListcopy);
    newHwList.removeAll(oldHwListcopy);
    LOG.trace("oldHwList {}", oldHwList);
    LOG.trace("newHwList {}", newHwList);
    LOG.trace("oldHwListcopy {}", oldHwListcopy);
    LOG.trace("newHwListcopy {}", newHwListcopy);
    if (!newHwList.isEmpty()) {
        LOG.trace("Adding HW TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(Collections.emptyList(), newHwList, dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
    }
    if (!oldHwList.isEmpty()) {
        LOG.trace("Removing HW TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) ArrayList(java.util.ArrayList) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 19 with DPNTEPsInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.

the class ItmExternalTunnelDeleteWorker method deleteTunnelsInTransportZone.

private static void deleteTunnelsInTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints srcTep, List<HwVtep> cfgdhwVteps, DataBroker dataBroker, WriteTransaction writeTransaction) {
    InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).build();
    Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
    if (transportZoneOptional.isPresent()) {
        TransportZone tzone = transportZoneOptional.get();
        // do we need to check tunnel type?
        if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
            for (Subnets sub : tzone.getSubnets()) {
                if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
                    for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
                        // OVS-TOR-OVS
                        deleteTrunksOvsTor(dataBroker, dpn.getDPNID(), srcTep.getInterfaceName(), srcTep.getIpAddress(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), tzone.getTunnelType(), writeTransaction);
                    }
                }
            }
        }
        if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
            for (HwVtep hwVtep : cfgdhwVteps) {
                deleteTrunksOvsTor(dataBroker, dpn.getDPNID(), srcTep.getInterfaceName(), srcTep.getIpAddress(), hwVtep.getTopoId(), hwVtep.getNodeId(), hwVtep.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
            }
        }
    }
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 20 with DPNTEPsInfo

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.

the class ItmExternalTunnelDeleteWorker method deleteTunnels.

public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, Collection<DPNTEPsInfo> dpnTepsList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
    LOG.trace(" Delete Tunnels towards DC Gateway with Ip  {}", extIp);
    if (dpnTepsList == null || dpnTepsList.isEmpty()) {
        LOG.debug("no vtep to delete");
        return Collections.emptyList();
    }
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    for (DPNTEPsInfo teps : dpnTepsList) {
        TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
        String interfaceName = firstEndPt.getInterfaceName();
        String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
        InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
        writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
        ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
        InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
        writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, path);
        LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
        ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
        // Release the Ids for the trunk interface Name
        ItmUtils.releaseIdForTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
    }
    return Collections.singletonList(writeTransaction.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) 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) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Aggregations

DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)18 ArrayList (java.util.ArrayList)11 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)11 BigInteger (java.math.BigInteger)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)5 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 TzMembership (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)4 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)4 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)3 ItmTepAddWorker (org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)3 ItmTepRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker)3 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)3 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)3 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)3 DcGatewayIp (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp)3 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)3 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2