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

Revision history [back]

click to hide/show revision 1
initial version

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.