Search in sources :

Example 6 with TransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.

the class TepCommandHelperTest method testDeleteOnCommit.

@Test
public void testDeleteOnCommit() {
    transportZoneList.add(transportZone);
    transportZoneList.add(transportZoneNew);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    optionalTransportZones = Optional.of(transportZones);
    doReturn(Futures.immediateCheckedFuture(optionalTransportZones)).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier);
    try {
        tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1, null);
    } catch (TepException e) {
        LOG.error(e.getMessage());
    }
    tepCommandHelper.deleteOnCommit();
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier);
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, vtepsIdentifier);
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, subnetsIdentifier);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, vtepsIdentifierNew);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, subnetsIdentifier);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
}
Also used : TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) Test(org.junit.Test)

Example 7 with TransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone 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 8 with TransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone 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 9 with TransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.

the class TunnelMonitorChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModification) {
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    Class<? extends TunnelMonitoringTypeBase> monitorProtocol = dataObjectModification.getMonitorProtocol();
    if (monitorProtocol == null) {
        monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
    }
    if (transportZonesOptional.isPresent()) {
        TransportZones transportZones = transportZonesOptional.get();
        for (TransportZone tzone : transportZones.getTransportZone()) {
            LOG.debug("Remove - TunnelMonitorToggleWorker with tzone = {}, Enable = {}, MonitorProtocol = {}", tzone.getZoneName(), dataObjectModification.isEnabled(), monitorProtocol);
            ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), false, monitorProtocol, broker);
            jobCoordinator.enqueueJob(tzone.getZoneName(), toggleWorker);
        }
    }
}
Also used : ItmMonitorToggleWorker(org.opendaylight.genius.itm.confighelpers.ItmMonitorToggleWorker) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 10 with TransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.

the class TunnelMonitorChangeListener method add.

@Override
protected void add(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModification) {
    LOG.debug("Add - TunnelMonitorToggleWorker with Enable = {}, MonitorProtocol = {}", dataObjectModification.isEnabled(), dataObjectModification.getMonitorProtocol());
    Class<? extends TunnelMonitoringTypeBase> monitorProtocol = dataObjectModification.getMonitorProtocol();
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    if (monitorProtocol == null) {
        monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
    }
    if (transportZonesOptional.isPresent()) {
        TransportZones tzones = transportZonesOptional.get();
        for (TransportZone tzone : tzones.getTransportZone()) {
            LOG.debug("Add: TunnelMonitorToggleWorker with tzone = {} monitoringEnabled {} and " + "monitoringProtocol {}", tzone.getZoneName(), dataObjectModification.isEnabled(), dataObjectModification.getMonitorProtocol());
            ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), dataObjectModification.isEnabled(), monitorProtocol, broker);
            jobCoordinator.enqueueJob(tzone.getZoneName(), toggleWorker);
        }
    }
}
Also used : ItmMonitorToggleWorker(org.opendaylight.genius.itm.confighelpers.ItmMonitorToggleWorker) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Aggregations

TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)42 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)27 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)26 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)21 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)19 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)18 ArrayList (java.util.ArrayList)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)16 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)16 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)14 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)13 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)12 Test (org.junit.Test)10 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)9 List (java.util.List)8 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)8 TransportZonesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder)8 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)8 VtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)8 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)7