Search in sources :

Example 1 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId 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;
}
Also used : MonitorStopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput) MonitorStopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder)

Example 2 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId 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);
    }
}
Also used : MonitorStartOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.SourceBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MonitorStartInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.DestinationBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.ConfigBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ExecutionException(java.util.concurrent.ExecutionException) MonitorStartInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInputBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 3 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project netvirt by opendaylight.

the class ArpMonitorEventListener method onMonitorEvent.

@Override
public void onMonitorEvent(MonitorEvent notification) {
    Long monitorId = notification.getEventData().getMonitorId();
    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(dataBroker, vpnName, learntIp);
        if (vpnVipToPort != null && macEntry.getCreatedTime().equals(vpnVipToPort.getCreationTime())) {
            jobCoordinator.enqueueJob(ArpMonitoringHandler.buildJobKey(macEntry.getIpAddress().getHostAddress(), macEntry.getVpnName()), new ArpMonitorStopTask(macEntry, dataBroker, alivenessManager));
        }
    }
}
Also used : LivenessState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)

Example 4 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project netvirt by opendaylight.

the class AlivenessMonitorUtils method startIpMonitoring.

void startIpMonitoring(MacEntry macEntry, Long ipMonitorProfileId) {
    if (interfaceManager.isExternalInterface(macEntry.getInterfaceName())) {
        LOG.debug("IP monitoring is currently not supported through external interfaces," + "skipping IP monitoring from interface {} for IP {} (last known MAC {})", macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), macEntry.getMacAddress());
        return;
    }
    Optional<IpAddress> gatewayIpOptional = vpnUtil.getGatewayIpAddressFromInterface(macEntry);
    if (!gatewayIpOptional.isPresent()) {
        LOG.info("Interface{} does not have an GatewayIp", macEntry.getInterfaceName());
        return;
    }
    final IpAddress gatewayIp = gatewayIpOptional.get();
    Optional<String> gatewayMacOptional = vpnUtil.getGWMacAddressFromInterface(macEntry, gatewayIp);
    if (!gatewayMacOptional.isPresent()) {
        LOG.error("Error while retrieving GatewayMac for interface{}", macEntry.getInterfaceName());
        return;
    }
    final IpAddress targetIp = IetfInetUtil.INSTANCE.ipAddressFor(macEntry.getIpAddress());
    if (ipMonitorProfileId == null || ipMonitorProfileId.equals(0L)) {
        Optional<Uint32> profileIdOptional = allocateIpMonitorProfile(targetIp);
        if (!profileIdOptional.isPresent()) {
            LOG.error("startIpMonitoring: Error while allocating Profile Id for IP={}", targetIp);
            return;
        }
        ipMonitorProfileId = profileIdOptional.get().toJava();
    }
    final PhysAddress gatewayMac = new PhysAddress(gatewayMacOptional.get());
    MonitorStartInput ipMonitorInput = 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(ipMonitorProfileId).build()).build();
    try {
        Future<RpcResult<MonitorStartOutput>> result = alivenessManager.monitorStart(ipMonitorInput);
        RpcResult<MonitorStartOutput> rpcResult = result.get();
        long monitorId;
        if (rpcResult.isSuccessful()) {
            monitorId = rpcResult.getResult().getMonitorId().toJava();
            createOrUpdateInterfaceMonitorIdMap(monitorId, macEntry);
            LOG.trace("Started IP 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);
    }
}
Also used : MonitorStartOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.SourceBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MonitorStartInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.DestinationBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.ConfigBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ExecutionException(java.util.concurrent.ExecutionException) MonitorStartInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInputBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 5 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project netvirt by opendaylight.

the class AlivenessMonitorUtils method stopIpMonitoring.

void stopIpMonitoring(Uint32 monitorId) {
    MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
    LoggingFutures.addErrorLogging(alivenessManager.monitorStop(input), LOG, "Stop monitoring");
    alivenessCache.remove(monitorId.toJava());
    return;
}
Also used : MonitorStopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput) MonitorStopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder)

Aggregations

Optional (com.google.common.base.Optional)10 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)7 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 ArrayList (java.util.ArrayList)6 ExecutionException (java.util.concurrent.ExecutionException)6 MonitorStartInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput)6 MonitorStartOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput)6 MonitorStopInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 List (java.util.List)5 FutureCallback (com.google.common.util.concurrent.FutureCallback)4 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)4 Future (java.util.concurrent.Future)4 Nonnull (javax.annotation.Nonnull)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4