Search in sources :

Example 21 with TransportZones

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.

the class TunnelMonitorChangeListener method update.

@Override
protected void update(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModificationBefore, TunnelMonitorParams dataObjectModificationAfter) {
    LOG.debug("update TunnelMonitorChangeListener called with {}", dataObjectModificationAfter.isEnabled());
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolBefore = dataObjectModificationBefore.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolAfter = dataObjectModificationAfter.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    if (monitorProtocolAfter != null) {
        monitorProtocol = dataObjectModificationAfter.getMonitorProtocol();
    }
    if (monitorProtocolBefore != null && monitorProtocolAfter != null) {
        LOG.debug("TunnelMonitorChangeListener Update : Existing_MonitorProtocol {}, New_MonitorProtocol {} ", monitorProtocolBefore.getName(), monitorProtocolAfter.getName());
        if (!monitorProtocolAfter.getName().equalsIgnoreCase(monitorProtocolBefore.getName())) {
            LOG.error("Updation of monitor protocol not allowed");
        }
    }
    if (transportZonesOptional.isPresent()) {
        TransportZones tzones = transportZonesOptional.get();
        for (TransportZone tzone : tzones.getTransportZone()) {
            LOG.debug("Update - TunnelMonitorToggleWorker with tzone = {}, Enable = {}, MonitorProtocol = {}", tzone.getZoneName(), dataObjectModificationAfter.isEnabled(), monitorProtocol);
            ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), dataObjectModificationAfter.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)

Example 22 with TransportZones

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.

the class TunnelMonitorIntervalListener method add.

@Override
protected void add(InstanceIdentifier<TunnelMonitorInterval> key, TunnelMonitorInterval dataObjectModification) {
    LOG.debug("Add TunnelMonitorIntervalListener called with {}", dataObjectModification.getInterval());
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    if (transportZonesOptional.isPresent()) {
        TransportZones tzones = transportZonesOptional.get();
        for (TransportZone tzone : tzones.getTransportZone()) {
            LOG.debug("Add:Calling TunnelMonitorIntervalWorker with tzone = {} and {}", tzone.getZoneName(), dataObjectModification.getInterval());
            ItmMonitorIntervalWorker intervalWorker = new ItmMonitorIntervalWorker(tzone.getZoneName(), dataObjectModification.getInterval(), broker);
            // conversion to milliseconds done while writing to i/f-mgr config DS
            jobCoordinator.enqueueJob(tzone.getZoneName(), intervalWorker);
        }
    }
}
Also used : TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) ItmMonitorIntervalWorker(org.opendaylight.genius.itm.confighelpers.ItmMonitorIntervalWorker) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 23 with TransportZones

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.

the class TepCommandHelper method showTeps.

@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showTeps(boolean monitorEnabled, int monitorInterval, CommandSession session) throws TepException {
    boolean flag = false;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (transportZonesOptional.isPresent()) {
        TransportZones transportZones = transportZonesOptional.get();
        if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
            handleError("No teps configured", session);
            return;
        }
        List<String> result = new ArrayList<>();
        result.add(String.format("Tunnel Monitoring (for VXLAN tunnels): %s", monitorEnabled ? "On" : "Off"));
        result.add(String.format("Tunnel Monitoring Interval (for VXLAN tunnels): %d", monitorInterval));
        result.add(System.lineSeparator());
        result.add(String.format("%-16s  %-16s  %-16s  %-12s  %-12s %-12s %-16s %-12s", "TransportZone", "TunnelType", "SubnetMask", "GatewayIP", "VlanID", "DpnID", "IPAddress", "PortName"));
        result.add("---------------------------------------------------------------------------------------------" + "---------------------------------");
        for (TransportZone tz : transportZones.getTransportZone()) {
            if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
                LOG.error("Transport Zone {} has no subnets", tz.getZoneName());
                continue;
            }
            for (Subnets sub : tz.getSubnets()) {
                if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
                    LOG.error("Transport Zone {} subnet {} has no vteps", tz.getZoneName(), sub.getPrefix());
                    continue;
                }
                for (Vteps vtep : sub.getVteps()) {
                    flag = true;
                    String strTunnelType;
                    if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
                        strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
                    } else {
                        strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
                    }
                    result.add(String.format("%-16s  %-16s  %-16s  %-12s  %-12s %-12s %-16s %-12s", tz.getZoneName(), strTunnelType, new String(sub.getPrefix().getValue()), new String(sub.getGatewayIp().getValue()), sub.getVlanId().toString(), vtep.getDpnId().toString(), new String(vtep.getIpAddress().getValue()), vtep.getPortname()));
                }
            }
        }
        if (session != null) {
            if (flag) {
                for (String print : result) {
                    System.out.println(print);
                }
            } else {
                System.out.println("No teps to display");
            }
        }
    } else if (session != null) {
        System.out.println("No teps configured");
    }
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) ArrayList(java.util.ArrayList) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) 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 24 with TransportZones

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.

the class TepCommandHelper method getAllTransportZonesAsMap.

/**
 * Gets all transport zones as map.
 *
 * @return all transport zones as map
 */
private Map<String, TransportZone> getAllTransportZonesAsMap() {
    TransportZones allTransportZones = getAllTransportZones();
    Map<String, TransportZone> transportZoneMap = new HashMap<>();
    if (null != allTransportZones) {
        for (TransportZone tzone : ItmUtils.emptyIfNull(allTransportZones.getTransportZone())) {
            transportZoneMap.put(tzone.getZoneName(), tzone);
        }
    }
    return transportZoneMap;
}
Also used : HashMap(java.util.HashMap) 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 25 with TransportZones

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

Aggregations

TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)20 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)18 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)11 TransportZonesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder)9 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)8 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)8 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)7 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)7 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)5 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)5 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)5 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4