Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

0

Sending end user parameters to the controller

asked 2017-10-06 14:33:48 -0700

Dear All, I would like to send end user parameter such as buffer level to the controller so that the controller can decide when to apply the routing algorithm. Kind regards,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-10-07 05:35:20 -0700

VincentJahjah gravatar image

You can make getters and setters via RPC in the yang files of your projects:

rpc set-polling-frequency {
    description "Sets the amount of seconds between each poll instance";
    input {
        leaf nb-of-seconds {
            type uint32;
            default "20";
            description "Number of seconds between each poll instance";
        }
    }
}

rpc get-polling-frequency {
    description "Gets the amount of seconds between each poll instance";
    output {
        leaf nb-of-seconds {
            type uint32;
            default "20";
            description "Number of seconds between each poll instance";
        }
    }
}

And in your code:

... implements [PluginName]Service ...

@Override
public Future<RpcResult<Void>> setPollingFrequency(SetPollingFrequencyInput input) {
    if (input == null || input.getNbOfSeconds() == null) {
        return Futures.immediateFuture(RpcResultBuilder.<Void> failed().withError(
               ErrorType.APPLICATION, "oops").build());
    }
    pollingFrequency.set(input.getNbOfSeconds());
    return Futures.immediateFuture(RpcResultBuilder.<Void> success().build());
}

@Override
public Future<RpcResult<GetPollingStartThresholdOutput>> getPollingStartThreshold() {
    BigInteger value = BigInteger.valueOf(pollingStartThreshold.get());
    GetPollingStartThresholdOutput output = new GetPollingStartThresholdOutputBuilder()
                                                .setNbOfBytes(value).build();
    return Futures.immediateFuture(RpcResultBuilder.success(output).build());
}

Afterwards you will be able to make REST requests (e.g. via YangMan), or RPC-calls between your plugins. An added bonus is that they are easy to unit test.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2017-10-06 14:33:48 -0700

Seen: 13 times

Last updated: Oct 07