use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.
the class IpMonitoringHandler method add.
@Override
public void add(InstanceIdentifier<LearntVpnVipToPort> identifier, LearntVpnVipToPort value) {
runOnlyInOwnerNode("IpMonitoringHandler: add event", () -> {
try {
InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
if (value.getMacAddress() == null) {
LOG.warn("The mac address received is null for VpnPortipToPort {}, ignoring the DTCN", value);
return;
}
MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
String vpnName = value.getVpnName();
MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, value.getPortName(), value.getCreationTime());
Optional<Uint32> monitorProfileId = getMonitorProfileId(value.getPortFixedip());
if (monitorProfileId.isPresent()) {
jobCoordinator.enqueueJob(VpnUtil.buildIpMonitorJobKey(srcInetAddr.toString(), vpnName), new IpMonitorStartTask(macEntry, monitorProfileId.get().toJava(), alivenessMonitorUtils));
}
} catch (UnknownHostException e) {
LOG.error("Error in deserializing packet {} with exception", value, e);
}
});
}
use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.
the class IpMonitorEventListener method onMonitorEvent.
@Override
public void onMonitorEvent(MonitorEvent notification) {
Long monitorId = notification.getEventData().getMonitorId().toJava();
MacEntry macEntry = AlivenessMonitorUtils.getMacEntryFromMonitorId(monitorId);
if (macEntry == null) {
LOG.debug("No MacEntry found associated with the monitor Id {}", monitorId);
return;
}
LivenessState livenessState = notification.getEventData().getMonitorState();
if (livenessState.equals(LivenessState.Down)) {
String vpnName = macEntry.getVpnName();
String learntIp = macEntry.getIpAddress().getHostAddress();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && macEntry.getCreatedTime().equals(vpnVipToPort.getCreationTime())) {
String jobKey = VpnUtil.buildIpMonitorJobKey(macEntry.getIpAddress().getHostAddress(), macEntry.getVpnName());
jobCoordinator.enqueueJob(jobKey, new IpMonitorStopTask(macEntry, dataBroker, Boolean.TRUE, vpnUtil, alivenessMonitorUtils));
}
}
}
use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.
the class IpMonitorStopTask method call.
@Override
public List<ListenableFuture<Void>> call() {
final List<ListenableFuture<Void>> futures = new ArrayList<>();
java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
if (monitorIdOptional.isPresent()) {
alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
} else {
LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
}
String learntIp = macEntry.getIpAddress().getHostAddress();
if (this.isRemoveMipAdjAndLearntIp) {
String vpnName = macEntry.getVpnName();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
return futures;
}
vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
} else {
// Delete only MIP adjacency
vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
}
return futures;
}
use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.
the class IpMonitoringHandler method remove.
@Override
public void remove(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort value) {
runOnlyInOwnerNode("IpMonitoringHandler: remove event", () -> {
try {
InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
if (value.getMacAddress() == null) {
LOG.warn("The mac address received is null for LearntVpnVipToPort {}, ignoring the DTCN", value);
return;
}
String vpnName = value.getVpnName();
String learntIp = srcInetAddr.getHostAddress();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && !vpnVipToPort.getCreationTime().equals(value.getCreationTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
return;
}
MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
String interfaceName = value.getPortName();
MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, interfaceName, value.getCreationTime());
jobCoordinator.enqueueJob(VpnUtil.buildIpMonitorJobKey(srcInetAddr.toString(), vpnName), new IpMonitorStopTask(macEntry, dataBroker, Boolean.FALSE, vpnUtil, alivenessMonitorUtils));
} catch (UnknownHostException e) {
LOG.error("Error in deserializing packet {} with exception", value, e);
}
});
}
Aggregations