Search in sources :

Example 1 with CreateTerminatingServiceActionsInput

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

the class ItmManagerRpcService method createTerminatingServiceActions.

@Override
public Future<RpcResult<java.lang.Void>> createTerminatingServiceActions(final CreateTerminatingServiceActionsInput input) {
    LOG.info("create terminatingServiceAction on DpnId = {} for service id {} and instructions {}", input.getDpnId(), input.getServiceId(), input.getInstruction());
    final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
    int serviceId = input.getServiceId();
    final List<MatchInfo> mkMatches = getTunnelMatchesForServiceId(serviceId);
    Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, serviceId), 5, String.format("%s:%d", "ITM Flow Entry ", serviceId), 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(serviceId)), mkMatches, input.getInstruction());
    ListenableFuture<Void> installFlowResult = mdsalManager.installFlow(input.getDpnId(), terminatingServiceTableFlow);
    Futures.addCallback(installFlowResult, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void voidInstance) {
            result.set(RpcResultBuilder.<Void>success().build());
        }

        @Override
        public void onFailure(Throwable error) {
            String msg = String.format("Unable to install terminating service flow for %s", input.getDpnId());
            LOG.error("create terminating service actions failed. {}", msg, error);
            result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
        }
    }, MoreExecutors.directExecutor());
    // result.set(RpcResultBuilder.<Void>success().build());
    return result;
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1