Search in sources :

Example 1 with TunnelsState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState in project genius by opendaylight.

the class InterfaceStateListener method updateTunnel.

private List<ListenableFuture<Void>> updateTunnel(Interface updated) throws Exception {
    LOG.debug("Invoking ItmTunnelStateUpdateHelper for Interface {} ", updated);
    final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    StateTunnelListKey tlKey = ItmUtils.getTunnelStateKey(updated);
    LOG.trace("TunnelStateKey: {} for interface: {}", tlKey, updated.getName());
    InstanceIdentifier<StateTunnelList> stListId = ItmUtils.buildStateTunnelListId(tlKey);
    Optional<StateTunnelList> tunnelsState = tunnelStateCache.get(stListId);
    StateTunnelListBuilder stlBuilder;
    TunnelOperStatus tunnelOperStatus;
    boolean tunnelState = updated.getOperStatus().equals(Interface.OperStatus.Up);
    switch(updated.getOperStatus()) {
        case Up:
            tunnelOperStatus = TunnelOperStatus.Up;
            break;
        case Down:
            tunnelOperStatus = TunnelOperStatus.Down;
            break;
        case Unknown:
            tunnelOperStatus = TunnelOperStatus.Unknown;
            break;
        default:
            tunnelOperStatus = TunnelOperStatus.Ignore;
    }
    if (tunnelsState.isPresent()) {
        stlBuilder = new StateTunnelListBuilder(tunnelsState.get());
        stlBuilder.setTunnelState(tunnelState);
        stlBuilder.setOperState(tunnelOperStatus);
        StateTunnelList stList = stlBuilder.build();
        LOG.trace("Batching the updation of tunnel_state: {} for Id: {}", stList, stListId);
        ITMBatchingUtils.update(stListId, stList, ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    }
    return Collections.singletonList(writeTransaction.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 TunnelOperStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus)1 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)1 StateTunnelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder)1 StateTunnelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey)1