How to move a list entry after another list entry ?
I’ve following yang model. Where I need to move a entry in “rule” list after another “rule” entry within same sipAdaptor Profile ex:
move
/PROFILES:profiles/signaling/sipAdaptorProfile{smm}/rule{1}
after
/PROFILES:profiles/signaling/sipAdaptorProfile{smm}/rule{3}
module sipAdaptor {
augment "/PROFILES:profiles/PROFILES:signaling" {
list sipAdaptorProfile {
key name;
tailf:sort-order snmp;
leaf name {
type string;
tailf:info "
The name of Adaptor Profile.
";
}
list rule {
key ruleIndex;
min-elements 1;
tailf:sort-order snmp;
leaf ruleIndex {
type uint16;
}
list criterion {
key criterionIndex;
min-elements 1;
tailf:sort-order snmp;
leaf criterionIndex {
type uint16;
}
container message {
leaf messageTypes {
type string;
}
}
}
list action {
key actionIndex;
min-elements 1;
leaf actionIndex {
type uint16;
}
leaf operation {
type string;
}
}
}
}
}
}
First, in order to be able to move list entries around, you need your list to be user-ordered; and so that you can make the list rule user-ordered, it must not be tailf:sort-order snmp. So let’s suppose the list rule looks like this:
list rule {
key ruleIndex;
min-elements 1;
ordered-by user;
leaf ruleIndex {
type uint16;
}
...
}
With this, you can move rule entries around.
As for the actual command, the utility confd_cmd is somewhat limited; you can move entries to first or last positions, but not before X or after X, at least not unless your list has single string-typed key. I’m not sure if this is a bug or a (over)simplification, in either case, if first and last are not enough, you need to use other tools, or take the source of confd_cmd (available in $CONFD_DIR/src/confd/tools) and modify it to satisfy tour needs.
In description maapi_move_ordered() is specifically mentioned for ordered-by user statement.
Should I assume maapi_move() can be used for tailf:sort-order snmp;
maapi_move is kind of a misnomer, it should perhaps be named maapi_rename. It does not (directly) change order of entries, it changes key values of an entry, i.e. renames it. So it indeed applies to any kind of list (user-ordered or not), but it does something else than what you asked for.