Skip to content

Add openconfig-snmp YANG model for SNMP configuration and monitoring#1486

Open
nleiva wants to merge 5 commits into
openconfig:masterfrom
nleiva:master
Open

Add openconfig-snmp YANG model for SNMP configuration and monitoring#1486
nleiva wants to merge 5 commits into
openconfig:masterfrom
nleiva:master

Conversation

@nleiva
Copy link
Copy Markdown
Contributor

@nleiva nleiva commented May 5, 2026

Change Scope

This PR adds a new YANG module openconfig-snmp under release/models/system/
for managing SNMP services on network devices. The model covers community-based
SNMPv1/v2c configuration including:

  • Global SNMP settings (contact, location)
  • Community definitions with access modes (read-only, read-write)
  • Client prefix restrictions per community
  • Trap/notification receivers
  • Notification event filtering (authentication, line-status, etc.)

SNMPv3 is explicitly out of scope for this module.

The module is imported by openconfig-system.yang under the system hierarchy.

Platform Implementations

Tree View

module: openconfig-system
  +--rw system
     ...
     +--rw snmp
        +--rw config
        |  +--rw contact?    string
        |  +--rw location?   string
        +--ro state
        |  +--ro contact?    string
        |  +--ro location?   string
        +--rw communities
        |  +--rw community* [name]
        |     +--rw name       -> ../config/name
        |     +--rw config
        |     |  +--rw name?          string
        |     |  +--rw access-mode?   snmp-access-mode
        |     |  +--rw version?       snmp-version
        |     |  +--rw access-list?   -> /oc-acl:acl/acl-sets/acl-set/config/name
        |     +--ro state
        |     |  +--ro name?          string
        |     |  +--ro access-mode?   snmp-access-mode
        |     |  +--ro version?       snmp-version
        |     |  +--ro access-list?   -> /oc-acl:acl/acl-sets/acl-set/config/name
        |     +--rw clients
        |        +--rw client* [prefix]
        |           +--rw prefix    -> ../config/prefix
        |           +--rw config
        |           |  +--rw prefix?   oc-inet:ip-prefix
        |           +--ro state
        |              +--ro prefix?   oc-inet:ip-prefix
        +--rw notifications
           +--rw config
           |  +--rw event-type*   identityref
           +--ro state
           |  +--ro event-type*   identityref
           +--rw receivers
              +--rw receiver* [name]
                 +--rw name      -> ../config/name
                 +--rw config
                 |  +--rw name?         string
                 |  +--rw address?      oc-inet:ip-address
                 |  +--rw port?         inet:port-number
                 |  +--rw version?      snmp-version
                 |  +--rw community?    string
                 |  +--rw event-type*   identityref
                 +--ro state
                    +--ro name?                    string
                    +--ro address?                 oc-inet:ip-address
                    +--ro port?                    inet:port-number
                    +--ro version?                 snmp-version
                    +--ro community?               string
                    +--ro event-type*              identityref
                    +--ro notifications-sent?      yang:counter64
                    +--ro notifications-dropped?   yang:counter64

@nleiva nleiva requested a review from a team as a code owner May 5, 2026 13:22
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the openconfig-snmp module for community-based SNMP configuration and state, integrating it into the system model. Feedback identifies that the snmp-top grouping is not yet instantiated in the system container and that the access-list reference is ambiguous because it lacks the ACL type required for the composite key. Suggestions were also made to use oc-inet:port-number with a default value for notification ports and to add must statements to prevent combining the 'ALL' event type with specific identities.

Comment thread release/models/system/openconfig-system.yang
Comment thread release/models/system/openconfig-snmp.yang
Comment on lines +323 to +337
leaf-list event-type {
type identityref {
base SNMP_NOTIFICATION_EVENT;
}
description
"Event types enabled for this specific receiver.
If empty, the receiver inherits the globally
configured event-type list under
notifications/config. If both are empty, no
notifications are sent. If the global list
contains ALL, all event types are sent unless
this receiver-level list restricts them to a
subset.";
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description states that the ALL identity should not be combined with other specific event types. This constraint should be enforced with a must statement to prevent invalid configurations.

    leaf-list event-type {
      type identityref {
        base SNMP_NOTIFICATION_EVENT;
      }
      must "not(count(.) > 1 and . = 'oc-snmp:ALL')" {
        error-message "Specific event types cannot be combined with ALL";
      }
      description
        "Event types enabled for this specific receiver.
        If empty, the receiver inherits the globally
        configured event-type list under
        notifications/config. If both are empty, no
        notifications are sent. If the global list
        contains ALL, all event types are sent unless
        this receiver-level list restricts them to a
        subset.";
    }

Comment on lines +399 to +412
leaf-list event-type {
type identityref {
base SNMP_NOTIFICATION_EVENT;
}
description
"Globally enabled notification event types.
This list provides a default set of events for
all receivers. Individual receivers may override
this by specifying their own event-type list.
If ALL is included, all event types are enabled
globally; specific identities should not be
combined with ALL.";
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the receiver-level configuration, the global event-type list should also enforce the exclusivity of the ALL identity using a must statement.

    leaf-list event-type {
      type identityref {
        base SNMP_NOTIFICATION_EVENT;
      }
      must "not(count(.) > 1 and . = 'oc-snmp:ALL')" {
        error-message "Specific event types cannot be combined with ALL";
      }
      description
        "Globally enabled notification event types.
        This list provides a default set of events for
        all receivers. Individual receivers may override
        this by specifying their own event-type list.
        If ALL is included, all event types are enabled
        globally; specific identities should not be
        combined with ALL.";
    }

Comment thread release/models/system/openconfig-snmp.yang
nleiva and others added 3 commits May 5, 2026 09:34
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ElodinLaarz
Copy link
Copy Markdown
Contributor

/gcbrun

@OpenConfigBot
Copy link
Copy Markdown

OpenConfigBot commented May 5, 2026

No major YANG version changes in commit 84d2588

Comment thread release/models/system/openconfig-snmp.yang Outdated
Comment thread release/models/system/openconfig-snmp.yang Outdated
Comment thread release/models/system/openconfig-snmp.yang
Comment thread release/models/system/openconfig-snmp.yang
@dplore
Copy link
Copy Markdown
Member

dplore commented May 12, 2026

/gcbrun

@dplore dplore moved this to Ready to discuss in OC Operator Review May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready to discuss

Development

Successfully merging this pull request may close these issues.

5 participants