use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService in project netvirt by opendaylight.
the class AlivenessMonitorUtils method stopArpMonitoring.
public static void stopArpMonitoring(AlivenessMonitorService alivenessMonitorService, Long monitorId) {
MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
JdkFutures.addErrorLogging(alivenessMonitorService.monitorStop(input), LOG, "Stop monitoring");
alivenessCache.remove(monitorId);
return;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService in project netvirt by opendaylight.
the class AlivenessMonitorUtils method startArpMonitoring.
public static void startArpMonitoring(MacEntry macEntry, Long arpMonitorProfileId, AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker, INeutronVpnManager neutronVpnService, IInterfaceManager interfaceManager) {
if (interfaceManager.isExternalInterface(macEntry.getInterfaceName())) {
LOG.debug("ARP monitoring is currently not supported through external interfaces," + "skipping ARP monitoring from interface {} for IP {} (last known MAC {})", macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), macEntry.getMacAddress());
return;
}
Optional<IpAddress> gatewayIpOptional = VpnUtil.getGatewayIpAddressFromInterface(macEntry.getInterfaceName(), neutronVpnService);
if (!gatewayIpOptional.isPresent()) {
LOG.error("Error while retrieving GatewayIp for interface{}", macEntry.getInterfaceName());
return;
}
final IpAddress gatewayIp = gatewayIpOptional.get();
Optional<String> gatewayMacOptional = VpnUtil.getGWMacAddressFromInterface(macEntry, gatewayIp, dataBroker);
if (!gatewayMacOptional.isPresent()) {
LOG.error("Error while retrieving GatewayMac for interface{}", macEntry.getInterfaceName());
return;
}
final PhysAddress gatewayMac = new PhysAddress(gatewayMacOptional.get());
if (arpMonitorProfileId == null || arpMonitorProfileId.equals(0L)) {
Optional<Long> profileIdOptional = allocateProfile(alivenessMonitorService, ArpConstants.FAILURE_THRESHOLD, ArpConstants.ARP_CACHE_TIMEOUT_MILLIS, ArpConstants.MONITORING_WINDOW, EtherTypes.Arp);
if (!profileIdOptional.isPresent()) {
LOG.error("Error while allocating Profile Id for alivenessMonitorService");
return;
}
arpMonitorProfileId = profileIdOptional.get();
}
IpAddress targetIp = new IpAddress(new Ipv4Address(macEntry.getIpAddress().getHostAddress()));
MonitorStartInput arpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setSource(new SourceBuilder().setEndpointType(getSourceEndPointType(macEntry.getInterfaceName(), gatewayIp, gatewayMac)).build()).setDestination(new DestinationBuilder().setEndpointType(getEndPointIpAddress(targetIp)).build()).setMode(MonitoringMode.OneOne).setProfileId(arpMonitorProfileId).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(arpMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
long monitorId;
if (rpcResult.isSuccessful()) {
monitorId = rpcResult.getResult().getMonitorId();
createOrUpdateInterfaceMonitorIdMap(monitorId, macEntry);
LOG.trace("Started ARP monitoring with id {}", monitorId);
} else {
LOG.warn("RPC Call to start monitoring returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when starting monitoring", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService in project netvirt by opendaylight.
the class AlivenessMonitorUtils method createMonitorProfile.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public static Optional<Long> createMonitorProfile(AlivenessMonitorService alivenessMonitor, MonitorProfileCreateInput monitorProfileCreateInput) {
try {
Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessMonitor.monitorProfileCreate(monitorProfileCreateInput);
RpcResult<MonitorProfileCreateOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return Optional.of(rpcResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Profile Id Id returned with Errors {}.. Trying to fetch existing profile ID", rpcResult.getErrors());
try {
Profile createProfile = monitorProfileCreateInput.getProfile();
Future<RpcResult<MonitorProfileGetOutput>> existingProfile = alivenessMonitor.monitorProfileGet(buildMonitorGetProfile(createProfile.getMonitorInterval(), createProfile.getMonitorWindow(), createProfile.getFailureThreshold(), createProfile.getProtocolType()));
RpcResult<MonitorProfileGetOutput> rpcGetResult = existingProfile.get();
if (rpcGetResult.isSuccessful()) {
return Optional.of(rpcGetResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Existing Profile Id returned with Errors {}", rpcGetResult.getErrors());
}
} catch (Exception e) {
LOG.warn("Exception when getting existing profile", e);
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when allocating profile Id", e);
}
return Optional.absent();
}
Aggregations