DatastoreAccess: add support for generic user-defined RPCs
I was lazy and in the NETCONF backend, the fillMap patch does not check
for actual string prefix match, it just optimistically trims the RPC
prefix. I think this is safe (definitely in the "won't crash" department
due to use of std::string::substr(), but also in the "won't produce
garbage" context because libyang is expected to validate everything).
In the sysrepo backend, I had to introduce some duplication into that
visitor which converts from our data types to sysrepo. It tirns out that
sysrepo::Session::set_item requires a separate S_Val, whereas in context
of handling an RPC's output, we have a Vals_Holder which, after
reallocation, becomes a Vals instance, and that one does not support
replacing the individual Val instances by "something" -- one has to call
a Val::set, and these methods are different from Val::Val constructors.
I'm explicitly testing for lists and containers because the
documentation looked a bit scary -- I understood it in a way which make
me spend extra effort to make sure that all that has to be created gets
created.
Change-Id: I717af71d69b209c444e1c5fe6d8ec2c2fcbdde8b
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index 498446e..d993781 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -83,4 +83,48 @@
container lol {
uses upAndDown;
}
+
+ grouping targets_def {
+ list targets {
+ key 'city';
+ leaf city {
+ type string;
+ }
+ }
+ }
+
+ rpc launch-nukes {
+ input {
+ container payload {
+ leaf kilotons {
+ type uint64;
+ mandatory true;
+ units "kilotons";
+ }
+ }
+ leaf description {
+ type string;
+ }
+ container cities {
+ presence true;
+ uses targets_def;
+ }
+ }
+ output {
+ leaf blast-radius {
+ type uint32;
+ units "m";
+ }
+ leaf actual-yield {
+ type uint64;
+ units "kilotons";
+ }
+ container damaged-places {
+ presence true;
+ uses targets_def;
+ }
+ }
+ }
+
+ rpc noop {}
}