Search in sources :

Example 56 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class TransportZoneListener method createhWVteps.

private List<HwVtep> createhWVteps(TransportZone transportZone) {
    List<HwVtep> hwVtepsList = new ArrayList<>();
    String zoneName = transportZone.getZoneName();
    Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
    LOG.trace("Transport Zone_name: {}", zoneName);
    @Nullable Map<DeviceVtepsKey, DeviceVteps> deviceVtepsList = transportZone.getDeviceVteps();
    if (deviceVtepsList != null) {
        for (DeviceVteps vteps : deviceVtepsList.values()) {
            String topologyId = vteps.getTopologyId();
            String nodeId = vteps.getNodeId();
            IpAddress ipAddress = vteps.getIpAddress();
            LOG.trace("topo-id: {}, node-id: {}, ipAddress: {}", topologyId, nodeId, ipAddress);
            HwVtep hwVtep = ItmUtils.createHwVtepObject(topologyId, nodeId, ipAddress, tunnelType, transportZone);
            LOG.trace("Adding new HwVtep {} info ", hwVtep.getHwIp());
            hwVtepsList.add(hwVtep);
        }
    }
    LOG.trace("returning hwvteplist {}", hwVtepsList);
    return hwVtepsList;
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps) ArrayList(java.util.ArrayList) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 57 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class TransportZoneListener method remove.

@Override
public void remove(@NonNull InstanceIdentifier<TransportZone> instanceIdentifier, @NonNull TransportZone transportZone) {
    LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
    boolean allowTunnelDeletion;
    if (interfaceManager.isItmOfTunnelsEnabled()) {
        Map<OfDpnTepKey, OfDpnTep> dpnTepMap = createOfTepInfo(transportZone);
        if (!dpnTepMap.isEmpty()) {
            jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmOfPortRemoveWorker(dpnTepMap, itmOfTunnelDeleteWorker));
        } else {
            EVENT_LOGGER.debug("DPN List in TZ is empty");
        }
    } else {
        // due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
        if (ITMConstants.DEFAULT_TRANSPORT_ZONE.equalsIgnoreCase(transportZone.getZoneName())) {
            // Get TunnelTypeBase object for tunnel-type configured in config file
            Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
            if (!itmConfig.isDefTzEnabled() || !Objects.equals(transportZone.getTunnelType(), 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
            EVENT_LOGGER.debug("ITM-Transportzone,TunnelDeletion {}", transportZone.getZoneName());
            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, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
                if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
                    Map<UnknownVtepsKey, UnknownVteps> unknownVteps = convertVtepListToUnknownVtepList(transportZone.getVteps());
                    LOG.trace("Moving Transport Zone {} to tepsInNotHostedTransportZone Oper Ds.", transportZone.getZoneName());
                    jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepsNotHostedAddWorker(unknownVteps, transportZone.getZoneName(), dataBroker, txRunner));
                }
            }
        }
    }
}
Also used : OfDpnTepKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey) ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) OfDpnTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep) ItmTepsNotHostedAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedAddWorker) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) ItmOfPortRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmOfPortRemoveWorker) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 58 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport 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);
    EVENT_LOGGER.debug("ITM-Transportzone,ADD {}", transportZone.getZoneName());
    if (interfaceManager.isItmOfTunnelsEnabled()) {
        Map<OfDpnTepKey, OfDpnTep> dpnTepMap = createOfTepInfo(transportZone);
        if (!dpnTepMap.isEmpty()) {
            jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmOfPortAddWorker(dpnTepMap, itmOfTunnelAddWorker));
        } else {
            EVENT_LOGGER.debug("DPN List in TZ is empty");
        }
    } else {
        List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
        // avoiding adding duplicates from nothosted to new dpnlist.
        List<DPNTEPsInfo> duplicateFound = new ArrayList<>();
        List<DPNTEPsInfo> notHostedDpnList = getDPNTepInfoFromNotHosted(transportZone, opDpnList);
        for (DPNTEPsInfo notHostedDPN : notHostedDpnList) {
            for (DPNTEPsInfo newlyAddedDPN : opDpnList) {
                if (newlyAddedDPN.getDPNID().compareTo(notHostedDPN.getDPNID()) == 0 || newlyAddedDPN.getTunnelEndPoints().get(0).getIpAddress().equals(notHostedDPN.getTunnelEndPoints().get(0).getIpAddress())) {
                    duplicateFound.add(notHostedDPN);
                }
            }
        }
        notHostedDpnList.removeAll(duplicateFound);
        opDpnList.addAll(notHostedDpnList);
        List<HwVtep> hwVtepList = createhWVteps(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, itmInternalTunnelAddWorker, externalTunnelAddWorker));
        }
    }
}
Also used : ItmOfPortAddWorker(org.opendaylight.genius.itm.confighelpers.ItmOfPortAddWorker) OfDpnTepKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey) ArrayList(java.util.ArrayList) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) OfDpnTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 59 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class TransportZoneListener method update.

@Override
public void update(@NonNull InstanceIdentifier<TransportZone> instanceIdentifier, @NonNull TransportZone originalTransportZone, @NonNull TransportZone updatedTransportZone) {
    LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone, updatedTransportZone);
    EVENT_LOGGER.debug("ITM-Transportzone,UPDATE {}", updatedTransportZone.getZoneName());
    if (interfaceManager.isItmOfTunnelsEnabled()) {
        updateTransportZone(originalTransportZone, updatedTransportZone);
    } else {
        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());
        boolean equalLists = newDpnTepsList.size() == oldDpnTepsList.size() && newDpnTepsList.containsAll(oldDpnTepsList);
        LOG.trace("Is List Duplicate {} ", equalLists);
        if (!newDpnTepsList.isEmpty() && !equalLists) {
            LOG.trace("Adding TEPs ");
            jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager, itmInternalTunnelAddWorker, externalTunnelAddWorker));
        }
        if (!oldDpnTepsList.isEmpty() && !equalLists) {
            LOG.trace("Removing TEPs ");
            jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
        }
        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, itmInternalTunnelAddWorker, externalTunnelAddWorker));
        }
        if (!oldHwList.isEmpty()) {
            LOG.trace("Removing HW TEPs ");
            jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
        }
    }
}
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 60 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class ItmUtils method deleteTransportZoneFromConfigDS.

/**
 * Deletes the transport zone from Configuration datastore.
 *
 * @param tzName     transport zone name
 * @param dataBroker data broker handle to perform operations on datastore
 */
public static void deleteTransportZoneFromConfigDS(String tzName, DataBroker dataBroker) {
    // check whether transport-zone exists in config DS.
    TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
    if (transportZoneFromConfigDS != null) {
        // it exists, delete default-TZ now
        InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
        LOG.debug("Removing {} transport-zone from config DS.", tzName);
        try {
            SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
        } catch (TransactionCommitFailedException e) {
            LOG.error("deleteTransportZoneFromConfigDS failed. {} could not be deleted.", tzName, e);
        }
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

ArrayList (java.util.ArrayList)24 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)24 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)24 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)21 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)20 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)16 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)16 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)15 List (java.util.List)13 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey)13 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)12 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Map (java.util.Map)11 Test (org.junit.Test)11 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)11 Optional (java.util.Optional)10 Inject (javax.inject.Inject)10