LinuxCommandLibrary

gnmic-set

Modify network device configuration using gNMI

TLDR

Update the value of a path

$ gnmic [[-a|--address]] [ip:port] set --update-path [path/to/directory] --update-value [value]
copy

Update the value of a path to match the contents of a JSON file
$ gnmic [[-a|--address]] [ip:port] set --update-path [path/to/directory] --update-file [path/to/file]
copy

Replace the value of a path to match the contents of a JSON file
$ gnmic [[-a|--address]] [ip:port] set --replace-path [path/to/directory] --replace-file [path/to/file]
copy

Delete the node at a given path
$ gnmic [[-a|--address]] [ip:port] set --delete [path/to/directory]
copy

SYNOPSIS

gnmic [global options] set [--prefix prefix] [--encoding enc] [--format fmt] [--update-path-prefix paths] [--replace-path-prefix paths] [--delete-path-prefix paths] [<path>[:<value>]] ...

PARAMETERS

-a, --address <addr>
    gNMI target address (host:port), repeatable

-u, --username <user>
    Username for auth

-p, --password <pass>
    Password (stdin if -)

--insecure
    Skip server TLS certificate validation

--skip-verify
    Skip client cert verification

--token <token>
    Bearer token for auth

--timeout <duration>
    RPC timeout (default 10s)

--prefix <path>
    Common path prefix for all sets

--encoding <enc>
    Payload encoding: json, proto, json-ietf (default json)

--format <fmt>
    Input format for file payloads: json, yaml, text, etc.

--update-path-prefix <paths>
    Prefixes for update-type paths, repeatable

--replace-path-prefix <paths>
    Prefixes for replace-type paths, repeatable

--delete-path-prefix <paths>
    Prefixes for delete-type paths, repeatable

--add-modifier <mods>
    JSONPath-like modifiers for update, repeatable

--replace-modifier <mods>
    Modifiers for replace, repeatable

--delete-modifier <mods>
    Modifiers for delete, repeatable

--value-prefix <str>
    Prefix string prepended to all values

--json-data-paths <paths>
    JSONPaths to extract values from input

-t, --target <name>
    Target name from targets-file

--targets-file <file>
    JSON/YAML file with multiple targets

DESCRIPTION

gnmic set is a subcommand of the gnmic tool, an open-source gNMI client for interacting with network devices supporting the gRPC Network Management Interface (gNMI). It issues the gNMI SetRequest RPC to update, replace, or delete configuration paths on targets.

Paths are specified positionally as <path>[:<value>], where paths follow YANG modeling (e.g., /interfaces/interface[name=eth0]/config/enabled:true). Multiple paths can be set in one invocation. Values support scalar types, JSON, or proto encodings.

Key features include:
Update: Merges values into existing config.
Replace: Overwrites entire paths.
Delete: Removes paths.
Modifiers and prefixes allow bulk operations from files (JSON, YAML, etc.) via --format and --prefix. Global options handle targets, auth, TLS. Useful for automation in SDN, telemetry pipelines.

Requires targets with gNMI server (e.g., Junos, IOS-XR, Arista). Output shows response with errors per path.

CAVEATS

Modifies production configs; test in labs first. No undo; targets must support gNMI Set. Paths must be writable leaves/containers. Large payloads may timeout.

EXAMPLES

gnmic -a 192.168.1.1:10161 set /interfaces/interface[name=eth1]/config/enabled true
gnmic set --format json-ietf --prefix /system/config config.json
gnmic -t router1 set --delete-path-prefix /interfaces/interface[name=loop0]

SET TYPES

Update: leaf-merge (default).
Replace: full overwrite.
Delete: removes path/value.

PAYLOAD SOURCES

Positional args, --file (implied stdin), or piped input with --format.

HISTORY

gnmic developed 2020+ by OpenConfig contributors (Cloud Router, Nokia); v0.1.0 Jan 2021. Active in CNCF ecosystem for telemetry/config mgmt.

SEE ALSO

gnmic-get(1), gnmic-sub(1), gnmic-cap(1), gnmic(1)

Copied to clipboard