Transactions
set and remove each make one change and commit it. To make several changes as one, so they all apply or none do, open a transaction. It is the library's configure(), at the prompt.
Queue, then apply
begin opens a transaction. Until it's applied, set and remove queue their changes and send nothing, and the prompt shows how many are queued: nnc lab [tx 2]>. changes lists them, and apply sends them all in one edit, through the device's workflow:
nnc lab> begin
nnc lab> set /ietf-system:system/location rack-1
nnc lab> set /ietf-system:system/contact noc@example.net
nnc lab> changes
nnc lab> applynnc lab> changes
1 set /ietf-system:system/location "rack-1"
2 set /ietf-system:system/contact "noc@example.net"
nnc lab [tx 2]> apply
lock running: ok
lock candidate: ok
discard-changes candidate: ok
edit-config candidate: ok
validate candidate: ok
commit candidate: ok
unlock candidate: ok
unlock running: ok
okabandon drops the queued changes without sending anything:
nnc lab> begin
nnc lab> remove /ietf-system:system/location
nnc lab> abandonTwo changes to the same node in one transaction are refused as you queue the second, since the order they'd apply in isn't defined:
nnc lab [tx 1]> set /ietf-system:system/location rack-2
set: Two edits target the same node: /ietf-system:system/ietf-system:location; nothing was sentWhen apply fails
If the device refuses any change, none of them apply. apply says which step failed, discards what reached the candidate, and releases the locks. The transaction stays open with its changes, so you can see what was sent; abandon it and start again:
nnc lab [tx 2]> apply
lock running: ok
lock candidate: ok
discard-changes candidate: ok
discard-changes candidate: ok
unlock candidate: ok
unlock running: ok
apply: failed at edit-config; the changes were discarded and the locks released
rpc-error: invalid-value
type application
severity error
path /ietf-system:system/ietf-system:hostname
message length 0 is outside the allowed lengths 1..253
nnc lab [tx 2]> abandonA device the session can't lock, because another session holds the lock, fails at lock, naming the session that holds it.
Confirm or revert
apply --confirmed makes the commit a confirmed commit: the device rolls the changes back by itself unless you confirm them in time. revert rolls them back now. The prompt counts down meanwhile, nnc lab [confirm 1:59]>, and so does status:
nnc lab> begin
nnc lab> set /ietf-system:system/location rack-3
nnc lab> apply --confirmed --confirm-timeout 120
nnc lab> status
nnc lab> confirmnnc lab> begin
nnc lab> set /ietf-system:system/location rack-4
nnc lab> apply --confirmed --confirm-timeout 120
nnc lab> revert
nnc lab> value /ietf-system:system/locationIf the time runs out first, nnc says the device rolled the changes back.
Next
- Notifications: see each commit as a
netconf-config-changeevent - Paths: the
setandremovecommands on their own