Search in sources :

Example 61 with TransportZone

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

the class TepCommandHelper method deleteOnCommit.

@SuppressWarnings("checkstyle:IllegalCatch")
public <T extends DataObject> void deleteOnCommit() {
    List<InstanceIdentifier<T>> vtepPaths = new ArrayList<>();
    List<InstanceIdentifier<T>> subnetPaths = new ArrayList<>();
    List<InstanceIdentifier<T>> tzPaths = new ArrayList<>();
    List<Subnets> subDelList = new ArrayList<>();
    List<TransportZone> tzDelList = new ArrayList<>();
    List<Vteps> vtepDelList = new ArrayList<>();
    List<InstanceIdentifier<T>> allPaths = new ArrayList<>();
    try {
        if (vtepDelCommitList != null && !vtepDelCommitList.isEmpty()) {
            InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
            Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
            if (transportZonesOptional.isPresent()) {
                TransportZones transportZones = transportZonesOptional.get();
                for (TransportZone tz : transportZones.getTransportZone()) {
                    if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
                        continue;
                    }
                    for (Subnets sub : tz.getSubnets()) {
                        vtepDelList.addAll(vtepDelCommitList);
                        for (Vteps vtep : vtepDelList) {
                            InstanceIdentifier<T> vpath = (InstanceIdentifier<T>) InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, tz.getKey()).child(Subnets.class, sub.getKey()).child(Vteps.class, vtep.getKey()).build();
                            if (sub.getVteps().remove(vtep)) {
                                vtepPaths.add(vpath);
                                if (sub.getVteps().size() == 0 || sub.getVteps() == null) {
                                    subDelList.add(sub);
                                }
                            }
                        }
                    }
                }
                for (TransportZone tz : transportZones.getTransportZone()) {
                    if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
                        continue;
                    }
                    for (Subnets sub : subDelList) {
                        if (tz.getSubnets().remove(sub)) {
                            InstanceIdentifier<T> spath = (InstanceIdentifier<T>) InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, tz.getKey()).child(Subnets.class, sub.getKey()).build();
                            subnetPaths.add(spath);
                            if (tz.getSubnets() == null || tz.getSubnets().size() == 0) {
                                tzDelList.add(tz);
                            }
                        }
                    }
                }
                for (TransportZone tz : tzDelList) {
                    if (transportZones.getTransportZone().remove(tz)) {
                        InstanceIdentifier<T> tpath = (InstanceIdentifier<T>) InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, tz.getKey()).build();
                        tzPaths.add(tpath);
                        if (transportZones.getTransportZone() == null || transportZones.getTransportZone().size() == 0) {
                            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.delete(LogicalDatastoreType.CONFIGURATION, path)), LOG, "Error deleting {}", path);
                            return;
                        }
                    }
                }
                allPaths.addAll(vtepPaths);
                allPaths.addAll(subnetPaths);
                allPaths.addAll(tzPaths);
                ItmUtils.asyncBulkRemove(dataBroker, LogicalDatastoreType.CONFIGURATION, allPaths, ItmUtils.DEFAULT_CALLBACK);
            }
            vtepPaths.clear();
            subnetPaths.clear();
            tzPaths.clear();
            allPaths.clear();
            vtepDelCommitList.clear();
        }
    } catch (RuntimeException e) {
        LOG.error("Unexpected error", e);
    }
}
Also used : VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) LoggerFactory(org.slf4j.LoggerFactory) TepTypeInternal(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeInternal) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) CommandSession(org.apache.felix.service.command.CommandSession) StringUtils(org.apache.commons.lang3.StringUtils) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) PreDestroy(javax.annotation.PreDestroy) DataStoreCache(org.opendaylight.genius.utils.cache.DataStoreCache) TunnelMonitoringTypeLldp(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeLldp) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Optional(com.google.common.base.Optional) Map(java.util.Map) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) BigInteger(java.math.BigInteger) TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ItmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Collection(java.util.Collection) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) Entry(java.util.Map.Entry) PostConstruct(javax.annotation.PostConstruct) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) TunnelMonitoringTypeBfd(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBfd) Inject(javax.inject.Inject) TunnelMonitorIntervalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) TunnelMonitoringTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase) TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) TunnelMonitorParams(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParams) Logger(org.slf4j.Logger) TunnelMonitorInterval(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorInterval) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ITMConstants(org.opendaylight.genius.itm.globals.ITMConstants) Preconditions(com.google.common.base.Preconditions) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Collections(java.util.Collections) ItmUtils(org.opendaylight.genius.itm.impl.ItmUtils) SubnetUtils(org.apache.commons.net.util.SubnetUtils) IpAddressBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder) ArrayList(java.util.ArrayList) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) 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) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)

Example 62 with TransportZone

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

the class TepCommandHelper method configureTunnelType.

public void configureTunnelType(String transportZoneName, String tunnelType) {
    LOG.debug("configureTunnelType {} for transportZone {}", tunnelType, transportZoneName);
    TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker);
    Class<? extends TunnelTypeBase> tunType;
    validateTunnelType(transportZoneName, tunnelType, transportZoneFromConfigDS);
    if (transportZoneFromConfigDS != null) {
        if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
            LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.", transportZoneName, tunnelType);
            return;
        } else {
            tunnelType = StringUtils.upperCase(tunnelType);
            tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
            if (transportZoneFromConfigDS.getTunnelType().equals(tunType)) {
                // controller restart, then nothing to do now. Just return.
                return;
            }
        }
    }
    // get tunnel-type
    tunnelType = StringUtils.upperCase(tunnelType);
    tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
    TransportZones transportZones = null;
    List<TransportZone> tzList = null;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> tzones = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    TransportZone tzone = new TransportZoneBuilder().setKey(new TransportZoneKey(transportZoneName)).setTunnelType(tunType).build();
    if (tzones.isPresent()) {
        tzList = tzones.get().getTransportZone();
        if (tzList == null || tzList.isEmpty()) {
            tzList = new ArrayList<>();
        }
    } else {
        tzList = new ArrayList<>();
    }
    tzList.add(tzone);
    transportZones = new TransportZonesBuilder().setTransportZone(tzList).build();
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, path, transportZones, dataBroker);
}
Also used : TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) 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) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 63 with TransportZone

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

the class TepCommandHelper method deleteVtep.

@SuppressWarnings("checkstyle:IllegalCatch")
public void deleteVtep(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask, String gatewayIp, String transportZone, CommandSession session) throws TepException {
    IpAddress ipAddressObj = null;
    IpAddress gatewayIpObj = null;
    IpPrefix subnetMaskObj = null;
    final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
    try {
        ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
        gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
        if (!("null".equals(gatewayIp)) || ("0.0.0.0".equals(gatewayIp)) && (gatewayIp != null)) {
            gatewayIpObj = IpAddressBuilder.getDefaultInstance(gatewayIp);
        } else {
            LOG.debug("gateway is null");
            gatewayIp = null;
        }
    } catch (RuntimeException e) {
        handleError("Invalid IpAddress. Expected: 1.0.0.0 to 254.255.255.255", session);
        return;
    }
    try {
        subnetMaskObj = IpPrefixBuilder.getDefaultInstance(subnetMask);
    } catch (Exception e) {
        handleError("Invalid Subnet Mask. Expected: 0.0.0.0/0 to 255.255.255.255/32", session);
        return;
    }
    if (!validateIPs(ipAddress, subnetMask, gatewayIp)) {
        handleError("IpAddress and gateWayIp should belong to the subnet provided", session);
        return;
    }
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    Vteps vtepCli = null;
    Subnets subCli = null;
    InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(Vteps.class, vtepkey).build();
    // check if present in tzones and delete from cache
    boolean existsInCache = isInCache(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp, transportZone, session);
    if (!existsInCache) {
        Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
        if (vtepOptional.isPresent()) {
            vtepCli = vtepOptional.get();
            if (vtepCli.getIpAddress().equals(ipAddressObj)) {
                InstanceIdentifier<Subnets> spath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).build();
                Optional<Subnets> subOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, spath, dataBroker);
                if (subOptional.isPresent()) {
                    subCli = subOptional.get();
                    if (subCli.getGatewayIp().equals(gatewayIpObj) && subCli.getVlanId().equals(vlanId)) {
                        vtepDelCommitList.add(vtepCli);
                    } else if (session != null) {
                        session.getConsole().println("vtep with this vlan or gateway doesnt exist");
                    }
                }
            } else if (session != null) {
                session.getConsole().println("Vtep with this ipaddress doesnt exist");
            }
        } else if (session != null) {
            session.getConsole().println("Vtep Doesnt exist");
        }
    }
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 64 with TransportZone

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

the class ItmExternalTunnelAddWorker method tunnelsFromhWVtep.

private void tunnelsFromhWVtep(List<HwVtep> cfgdHwVteps, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
    for (HwVtep hwTep : cfgdHwVteps) {
        InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(hwTep.getTransportZone())).build();
        Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
        Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
        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()) {
                            if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
                                // dont mesh with self
                                continue;
                            }
                            LOG.trace("wire up {} and {}", hwTep, hwVtepDS);
                            if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), hwVtepDS.getIpAddress());
                            }
                            // TOR2-TOR1
                            LOG.trace("wire up {} and {}", hwVtepDS, hwTep);
                            if (!wireUp(hwTep.getTopoId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), hwTep.getHwIp());
                            }
                        }
                    }
                    if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
                        for (Vteps vtep : sub.getVteps()) {
                            if (vtep.getIpAddress().equals(hwTep.getHwIp())) {
                                continue;
                            }
                            // TOR-OVS
                            String cssID = vtep.getDpnId().toString();
                            LOG.trace("wire up {} and {}", hwTep, vtep);
                            if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), cssID, vtep.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), vtep.getIpAddress());
                            }
                            // OVS-TOR
                            LOG.trace("wire up {} and {}", vtep, hwTep);
                            boolean useOfTunnel = ItmUtils.falseIfNull(vtep.isOptionOfTunnel());
                            if (!wireUp(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId(), vtep.getIpAddress(), useOfTunnel, hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
                                LOG.debug("wireUp returned false");
                            }
                        }
                    }
                }
            }
        }
    }
}
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) 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) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) 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 65 with TransportZone

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

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