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);
}
}
}
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);
}
}
}
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");
}
}
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;
}
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);
}
}
Aggregations