ncclient edit_config merge into the running datastore

300-435 By islever Editorial Last updated

Short answer

A Ncclient's edit_config with target='running' and default_operation='merge' sends a NETCONF edit-config merge that preserves untouched running-config nodes.

Question

Which ncclient operation merges config into running datastore?
  1. edit_config(target='running',config=cfg,default_operation='merge') Correct Answer
  2. copy_config()
  3. delete_config()
  4. discard_changes()

Key Takeaways

The ncclient edit_config() method with target='running' and default_operation='merge' performs a NETCONF edit-config merge into the running datastore, updating or adding supplied nodes while leaving unrelated configuration intact. copy_config() replaces a whole datastore, delete_config() removes a datastore, and discard_changes() only reverts candidate edits, so none of them expresses a partial merge.

Expert Analysis

Because the intended change must add or modify nodes in the running datastore without wiping untouched configuration, the decisive ncclient call is edit_config(target='running', config=cfg, default_operation='merge'), not a datastore copy, delete, or candidate rollback.

NETCONF edit-config and the merge default-operation define the required ncclient call

The normative behavior comes from RFC 6241's <edit-config> operation. That RPC loads all or part of a configuration into a target datastore, and its default-operation parameter selects how the supplied configuration data is combined with what already exists. The defined values are merge, replace, and none; merge is also the server-side default when the parameter is omitted. ncclient exposes the RPC through Manager.edit_config, whose arguments include target, config, and default_operation, so option A is the direct Python binding for the NETCONF merge operation rather than a convenience alias. The neighboring method names map to separate RPC families: copy_config invokes <copy-config>, delete_config invokes <delete-config>, and discard_changes invokes <discard-changes>. Those RPCs do not accept an operation selector because they do not perform a partial merge. copy_config is concerned with a source and destination datastore, delete_config removes a datastore, and discard_changes applies only to a candidate datastore's uncommitted edits. A qualifying answer therefore has to name both the edit-config RPC—or the ncclient method that wraps it—and the merge operation. Option A does exactly that and adds the required running target, while the other three options call RPCs whose semantics cannot express a fragment merge into running.

The running datastore and partial-update intent make copy_config and delete_config the wrong shapes

The decisive condition is that configuration must land in running as a merge, so existing nodes outside cfg must survive. copy_config is structurally unsuitable even though it can name running as a target: <copy-config> overwrites the destination datastore with the complete source datastore, so unrelated running configuration that is absent from the source disappears. That is whole-datastore replacement, not a merge of a payload. delete_config removes a datastore and has no merge behavior; NETCONF's <delete-config> target is a startup or candidate datastore, not the active running configuration. discard_changes is narrower still: it reverts uncommitted edits in a candidate datastore and does nothing to the running configuration. Only edit_config accepts a configuration fragment together with an operation selector, and default_operation='merge' tells the device to add missing nodes and update matching ones while leaving the rest alone. The target='running' argument applies that result directly to the active datastore instead of a candidate that would need a later commit. Remove either part—the running target or the merge instruction—and the call no longer satisfies the stated behavior. Option A keeps both pieces in a single ncclient invocation, which is why it is the only option whose semantics match a partial merge into running.

Partial edit-config merge versus copy_config whole-datastore replacement

The distinction that matters is between editing selected configuration data and replacing an entire datastore. With edit_config(..., default_operation='merge'), the config=cfg payload is treated as nodes to merge: a matching container has its children merged recursively, a matching list entry is identified by its key values and updated rather than duplicated, and a matching leaf receives the supplied value. Nodes absent from cfg are untouched, and nodes that do not yet exist are created. With default-operation='replace', the data in the payload replaces the corresponding configuration in the target, which is a different operation even though it still travels through <edit-config>. With copy_config, the boundary is coarser still: the whole target datastore is replaced by the source datastore, so the payload is not a fragment at all. delete_config and discard_changes sit outside this family—one removes a datastore, the other rolls back candidate edits. The practical test is whether unspecified nodes must survive. If they must, a merge is required, and only option A expresses a merge against running; the other options either replace at datastore scope, delete, or abandon candidate changes.

Where the merge takes effect in the NETCONF edit-config RPC lifecycle

The merge takes effect when ncclient serializes edit_config(target='running', config=cfg, default_operation='merge') into an <edit-config> RPC. The client places <target><running/></target> and <default-operation>merge</default-operation> in the message and sends it over the established NETCONF session. On the device, the NETCONF server parses the payload, applies the merge algorithm to the running configuration datastore, and returns <ok> or an <rpc-error>. Because the target is running, there is no candidate commit step between the RPC and the active configuration; the merge becomes part of running as the request is handled. If the same payload were sent to a candidate datastore, the edit would remain provisional until a commit, which is why the datastore argument is as important as the operation name. copy_config would take effect as a datastore-level overwrite rather than a node-level merge, and discard_changes would only undo candidate edits. The merge instruction is therefore consumed server-side during edit-config processing; it is not a client-side diff or a local ncclient transformation. That server-side placement is what makes the result authoritative and what distinguishes option A from the other calls.

Official Reference

Exam Strategy

When an ncclient question names a datastore and an intent verb such as merge, map the verb to the NETCONF operation first: edit-config handles merge or replace, copy-config overwrites a whole datastore, delete-config removes one, and discard-changes only applies to a candidate. Read the parameter list for target='running' and default_operation='merge', because ncclient method names and XML operations are not one-to-one. Eliminate any option that cannot target the running datastore or cannot express partial payload semantics before comparing syntax.

Practice All 300-435 Questions

Access 150 questions with complete answers and detailed explanations.

View Full 300-435 Practice Test →

← Back to 300-435 Study Guide