Search in sources :

Example 6 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result 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 7 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class StatisticsImpl method getNodeCounters.

@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Future<RpcResult<GetNodeCountersOutput>> getNodeCounters(GetNodeCountersInput input) {
    BigInteger dpId = input.getNodeId();
    LOG.trace("getting node counters for node {}", dpId);
    GetNodeCountersOutputBuilder gncob = new GetNodeCountersOutputBuilder();
    List<CounterResult> counterResults = new ArrayList<>();
    try {
        if (!getNodeResult(counterResults, dpId)) {
            StatisticsPluginImplCounters.failed_getting_node_counters.inc();
            return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
        }
    } catch (RuntimeException e) {
        LOG.warn("failed to get counter result for node {}", dpId, e);
        return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
    }
    gncob.setCounterResult(counterResults);
    return RpcResultBuilder.success(gncob.build()).buildFuture();
}
Also used : GetNodeCountersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeCountersOutput) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) GetNodeCountersOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeCountersOutputBuilder) CounterResult(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult)

Example 8 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class StatisticsImpl method createIdPool.

private void createIdPool() {
    if (checkPoolExists()) {
        return;
    }
    CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(CountersServiceUtils.COUNTERS_PULL_NAME).setLow(CountersServiceUtils.COUNTERS_PULL_START).setHigh(CountersServiceUtils.COUNTERS_PULL_START + CountersServiceUtils.COUNTERS_PULL_END).build();
    Future<RpcResult<Void>> result = idManagerService.createIdPool(createPool);
    Futures.addCallback(JdkFutureAdapters.listenInPoolThread(result), new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onFailure(Throwable error) {
            LOG.error("Failed to create idPool for Aliveness Monitor Service", error);
        }

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> rpcResult) {
            if (rpcResult.isSuccessful()) {
                LOG.debug("Created IdPool for tap");
            } else {
                LOG.error("RPC to create Idpool failed {}", rpcResult.getErrors());
            }
        }
    }, MoreExecutors.directExecutor());
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)

Example 9 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class StatisticsImpl method getNodeConnectorCounters.

@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Future<RpcResult<GetNodeConnectorCountersOutput>> getNodeConnectorCounters(GetNodeConnectorCountersInput input) {
    String portId = input.getPortId();
    LOG.trace("getting port counters of port {}", portId);
    Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(db, portId);
    if (interfaceState == null) {
        LOG.warn("trying to get counters for non exist port {}", portId);
        return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
    }
    BigInteger dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
    if (interfaceState.getLowerLayerIf() == null || interfaceState.getLowerLayerIf().isEmpty()) {
        LOG.warn("Lower layer if wasn't found for port {}", portId);
        return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
    }
    String portNumber = interfaceState.getLowerLayerIf().get(0);
    portNumber = portNumber.split(":")[2];
    List<CounterResult> counterResults = new ArrayList<>();
    try {
        if (!getNodeConnectorResult(counterResults, dpId, portNumber)) {
            StatisticsPluginImplCounters.failed_getting_node_connector_counters.inc();
            return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get port counters").buildFuture();
        }
    } catch (RuntimeException e) {
        LOG.warn("failed to get counter result for port {}", portId, e);
    }
    GetNodeConnectorCountersOutputBuilder gpcob = new GetNodeConnectorCountersOutputBuilder();
    gpcob.setCounterResult(counterResults);
    return RpcResultBuilder.success(gpcob.build()).buildFuture();
}
Also used : ArrayList(java.util.ArrayList) GetNodeConnectorCountersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutput) BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) CounterResult(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult) GetNodeConnectorCountersOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutputBuilder)

Example 10 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class StatisticsImpl method releaseId.

private void releaseId(String idKey) {
    ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(CountersServiceUtils.COUNTERS_PULL_NAME).setIdKey(idKey).build();
    try {
        Future<RpcResult<Void>> result = idManagerService.releaseId(idInput);
        RpcResult<Void> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.warn("RPC Call to release Id with Key {} returned with Errors {}", idKey, rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when releasing Id for key {}", idKey, e);
    }
}
Also used : ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Test (org.junit.Test)348 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)174 ByteBuf (io.netty.buffer.ByteBuf)97 ArrayList (java.util.ArrayList)94 ExecutionException (java.util.concurrent.ExecutionException)92 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)46 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)33 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)33 List (java.util.List)31 BigInteger (java.math.BigInteger)29 Collections (java.util.Collections)26 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)24 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)24 Nonnull (javax.annotation.Nonnull)23 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)22 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)22 RpcError (org.opendaylight.yangtools.yang.common.RpcError)22