Skip to content

Introduction

Introduction#

gnmic supports dynamic loading of gNMI targets from external systems. This feature allows adding and deleting gNMI targets without the need to restart gnmic.

Depending on the discovery method, gnmic will either:

  • Subscribe to changes on the remote system,
  • Or poll the defined targets from the remote systems.

When a change is detected, the new targets are added and the corresponding subscriptions are immediately established. The removed targets are deleted together with their subscriptions.

Actions can be run on target discovery (on-add or on-delete), this can be useful to add initial configurations to target ahead of gNMI subscriptions or run checks before subscribing. In the case of on-add actions,

Notes

  1. Only one discovery type is supported at a time.

  2. Target updates are not supported, delete and re-add is the way to update a target configuration.

Discovery types#

Four types of target discovery methods are supported:

File Loader#

Watches changes to a local file containing gNMI targets definitions.

Consul Server Loader#

Subscribes to Consul KV key prefix changes, the keys and their value represent a target configuration fields.

Docker Engine Loader#

Polls containers from a Docker Engine host matching some predefined criteria (docker filters).

HTTP Loader#

Queries an HTTP endpoint periodically, expected a well formatted JSON dict of targets configurations.

Running actions on discovery#

All actions support fields on-add and on-delete which take a list of predefined action names that will be run sequentially on target discovery or deletion.

The below configuration example defines 3 actions configure_interfaces, configure_subinterfaces and configure_network_instance which will run when the docker loader discovers a target with label clab-node-kind=srl

loader:
  type: docker
  filters:
    - containers:
      - label: clab-node-kind=srl
      config:
        skip-verify: true
        username: admin
        password: NokiaSrl1!
  on-add:
    - configure_interfaces
    - configure_subinterfaces
    - configure_network_instances

actions:
  configure_interfaces:
    name: configure_interfaces
    type: gnmi
    target: '{{ .Input }}'
    rpc: set
    encoding: json_ietf
    debug: true
    paths:
      - /interface[name=ethernet-1/1]/admin-state
      - /interface[name=ethernet-1/2]/admin-state 
    values:
      - enable
      - enable
  configure_subinterfaces:
    name: configure_subinterfaces
    type: gnmi
    target: '{{ .Input }}'
    rpc: set
    encoding: json_ietf
    debug: true
    paths:
      - /interface[name=ethernet-1/1]/subinterface[index=0]/admin-state
      - /interface[name=ethernet-1/2]/subinterface[index=0]/admin-state 
    values:
      - enable
      - enable
  configure_network_instances:
    name: configure_network_instances
    type: gnmi
    target: '{{ .Input }}'
    rpc: set
    encoding: json_ietf
    debug: true
    paths:
      - /network-instance[name=default]/admin-state
      - /network-instance[name=default]/interface
      - /network-instance[name=default]/interface
    values:
      - enable
      - '{"name": "ethernet-1/1.0"}'
      - '{"name": "ethernet-1/2.0"}'