@node-net/netconf/operations/partial-lock
RFC 5717 partial lock: lock only the parts of running you are about to change, so other sessions can keep working on the rest.
import { partialLock } from '@node-net/netconf/operations/partial-lock';
const client = await connect({ transport, extensions: [partialLock] });
await using lock = await client.ops.partialLock.lock([
client.content.toXPath('/ietf-interfaces:interfaces/interface[name="eth0"]'),
xpath("/if:interfaces/if:interface[if:name='eth1']", { if: IF_NS }),
]);
lock.lockId; // 127
lock.lockedNodes; // what the server locked: ['/ietf-interfaces:interfaces/interface[name=\'eth0\']', …]
await client.ops.editConfig({ target: 'running', config });
// leaving the scope sends <partial-unlock>Each select is an XPath 1.0 expression that must pick out a node set. A server without :xpath only accepts instance-identifiers (absolute paths whose predicates give list keys), which is what client.content.toXPath() builds. Only the server can tell which kind a select is, so this module doesn't require :xpath.
A partial lock covers the selected nodes and everything below them, is fixed when taken, and lasts until <partial-unlock> or the end of the session. A conflict with another session's lock rejects with PartialLockDeniedError, a LockDeniedError that gives the holder's session-id. Other refusals are RpcErrors: invalid-value (app tag not-a-node-set or invalid-lock-specification), operation-failed (app tag no-matches) and access-denied.
No open-source NETCONF server implements partial lock, so this module is tested against the fake server only.
See partial-lock.