Search in sources :

Example 1 with ItmTepRemoveWorker

use of org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker in project genius by opendaylight.

the class TransportZoneListener method remove.

@Override
public void remove(@Nonnull TransportZone transportZone) {
    LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
    boolean allowTunnelDeletion;
    // due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
    if (transportZone.getZoneName().equalsIgnoreCase(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
        // Get TunnelTypeBase object for tunnel-type configured in config file
        Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
        if (!itmConfig.isDefTzEnabled() || !transportZone.getTunnelType().equals(tunType)) {
            allowTunnelDeletion = true;
        } else {
            // this is case when def-tz removal request is from Northbound.
            allowTunnelDeletion = false;
            LOG.error("Deletion of {} is an incorrect usage", ITMConstants.DEFAULT_TRANSPORT_ZONE);
        }
    } else {
        allowTunnelDeletion = true;
    }
    if (allowTunnelDeletion) {
        // TODO : DPList code can be refactor with new specific class
        // which implement TransportZoneValidator
        List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
        List<HwVtep> hwVtepList = createhWVteps(transportZone);
        LOG.trace("Delete: Invoking deleteTunnels in ItmManager with DpnList {}", opDpnList);
        if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
            LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
            jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 2 with ItmTepRemoveWorker

use of org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker in project genius by opendaylight.

the class ItmTepInstanceRecoveryHandler method recoverTep.

private void recoverTep(String entityId) throws InterruptedException {
    List<DPNTEPsInfo> tepsToRecover = new ArrayList<>();
    DPNTEPsInfo dpnTepsToRecover = extractDPNTepsInfo(entityId);
    if (dpnTepsToRecover == null) {
        LOG.error("Please Enter appropriate arguments for Tep Recovery.");
        return;
    } else {
        tepsToRecover.add(dpnTepsToRecover);
        // Delete the transportZone and re create it
        // Get the transport zone from the transport zone name
        TransportZone oldTz = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (oldTz != null) {
            ItmTepRemoveWorker tepRemoveWorker = new ItmTepRemoveWorker(tepsToRecover, null, oldTz, dataBroker, imdsalApiManager, itmInternalTunnelDeleteWorker, dpntePsInfoCache);
            LOG.trace("Deleting transportzone {}", tzName);
            jobCoordinator.enqueueJob(tzName, tepRemoveWorker);
            ItmTepAddWorker tepAddWorker = new ItmTepAddWorker(tepsToRecover, null, dataBroker, imdsalApiManager, itmConfig, itmInternalTunnelAddWorker, itmExternalTunnelAddWorker, dpntePsInfoCache);
            LOG.trace("Re-creating transportzone {}", tzName);
            jobCoordinator.enqueueJob(tzName, tepAddWorker);
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) ArrayList(java.util.ArrayList) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 3 with ItmTepRemoveWorker

use of org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker 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)

Aggregations

ItmTepRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker)3 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)3 ArrayList (java.util.ArrayList)2 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 ItmTepAddWorker (org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)2 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)1