Search in sources :

Example 1 with GetDpnEndpointIpsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput in project genius by opendaylight.

the class ItmManagerRpcService method getDpnEndpointIps.

@Override
public Future<RpcResult<GetDpnEndpointIpsOutput>> getDpnEndpointIps(GetDpnEndpointIpsInput input) {
    BigInteger srcDpn = input.getSourceDpid();
    RpcResultBuilder<GetDpnEndpointIpsOutput> resultBld = RpcResultBuilder.failed();
    InstanceIdentifier<DPNTEPsInfo> tunnelInfoId = InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(srcDpn)).build();
    Optional<DPNTEPsInfo> tunnelInfo = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tunnelInfoId, dataBroker);
    if (!tunnelInfo.isPresent()) {
        LOG.error("tunnelInfo is not present");
        return Futures.immediateFuture(resultBld.build());
    }
    List<TunnelEndPoints> tunnelEndPointList = tunnelInfo.get().getTunnelEndPoints();
    if (tunnelEndPointList == null || tunnelEndPointList.isEmpty()) {
        LOG.error("tunnelEndPointList is null or empty");
        return Futures.immediateFuture(resultBld.build());
    }
    List<IpAddress> nexthopIpList = new ArrayList<>();
    tunnelEndPointList.forEach(tunnelEndPoint -> nexthopIpList.add(tunnelEndPoint.getIpAddress()));
    GetDpnEndpointIpsOutputBuilder output = new GetDpnEndpointIpsOutputBuilder().setNexthopipList(nexthopIpList);
    resultBld = RpcResultBuilder.success();
    resultBld.withResult(output.build());
    return Futures.immediateFuture(resultBld.build());
}
Also used : ArrayList(java.util.ArrayList) GetDpnEndpointIpsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) GetDpnEndpointIpsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 2 with GetDpnEndpointIpsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput in project netvirt by opendaylight.

the class EvpnUtils method getEndpointIpAddressForDPN.

public String getEndpointIpAddressForDPN(BigInteger dpnId) {
    Future<RpcResult<GetDpnEndpointIpsOutput>> result = itmRpcService.getDpnEndpointIps(new GetDpnEndpointIpsInputBuilder().setSourceDpid(dpnId).build());
    RpcResult<GetDpnEndpointIpsOutput> rpcResult = null;
    try {
        rpcResult = result.get();
    } catch (InterruptedException e) {
        LOG.error("getnextHopIpFromRpcOutput : InterruptedException for dpnid {}", dpnId, e);
        return null;
    } catch (ExecutionException e) {
        LOG.error("getnextHopIpFromRpcOutput : ExecutionException for dpnid {}", dpnId, e);
        return null;
    }
    if (!rpcResult.isSuccessful()) {
        LOG.warn("RPC Call to getDpnEndpointIps returned with Errors {}", rpcResult.getErrors());
        return null;
    }
    List<IpAddress> nexthopIpList = rpcResult.getResult().getNexthopipList();
    return nexthopIpList.get(0).getIpv4Address().getValue();
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) GetDpnEndpointIpsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsInputBuilder) GetDpnEndpointIpsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 GetDpnEndpointIpsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)1 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)1 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)1 GetDpnEndpointIpsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsInputBuilder)1 GetDpnEndpointIpsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1