Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

NETCONF Event Notifications

SUMMARY NETCONF clients can subscribe to event notifications in NETCONF sessions on supported devices that have the NETCONF event notification service enabled.

NETCONF Event Notifications Overview

Certain devices running Junos OS Evolved support NETCONF event notifications, an asynchronous event notification service between a NETCONF server and a NETCONF client. When the notification service is enabled, the NETCONF server sends event notifications, asynchronously as the events occur, to all NETCONF clients that subscribe to the notification service. Clients can subscribe to NETCONF notifications to receive alerts for events that might impact device operations or management activities.

The NETCONF server sends notifications for the following types of events:

  • netconf-session-start—Event that indicates when a NETCONF session starts and identifies the user who started the session.
  • netconf-session-end—Event that indicates when a NETCONF session ends and identifies the user who owned the session and the reason that the session was terminated.
  • netconf-config-change—Event that indicates when a management session commits changes to the active configuration and provides a summary of the changes.

You can enable the NETCONF event notification service on supported devices. See How to Enable and Subscribe to NETCONF Event Notifications for instructions.

After you enable NETCONF event notifications, the NETCONF server advertises the notification capability in the capabilities exchange.

To subscribe to the notification service for events on a specific device, a NETCONF client sends a <create-subscription> RPC to the NETCONF server on the device and indicates the following:

  • <stream>—The stream of events that is of interest.

    A stream is a set of event notifications that matches some forwarding criteria. A subscription is bound to a single stream for the lifetime of the subscription. The NETCONF stream is the default and only supported stream on devices running Junos OS Evolved. The NETCONF server returns an error if the subscription request is for any other stream. If you omit this parameter, the device treats the subscription request as a request for the NETCONF stream.

After a NETCONF client subscribes to event notifications, the NETCONF server sends the notifications as they occur. The notifications continue until the NETCONF session terminates.

Note:

A NETCONF client receives all event notifications by default. There is no way to restrict or limit the content of a notification based on user privileges. Because some events, for example, netconf-config-change events, can contain sensitive information, it is important to control read access to the information.

For additional information about NETCONF event notifications, see the following RFCs:

  • RFC 5277, NETCONF Event Notifications

  • RFC 6470, Network Configuration Protocol (NETCONF) Base Notifications

NETCONF Event Notification Format

NETCONF event notifications are well-formed XML documents. When the NETCONF server receives an internal event, it converts it to an appropriate XML encoding with a top-level <notification> element and an <eventTime> child element. The actual content contained in the notification depends on the event.

The following sample event notification contains a netconf-config-change event. The notification captures the event timestamp, the commit timestamp, the user who committed the configuration changes, and a summary of those changes.

The following notifications contain sample netconf-session-start and netconf-session-end events:

How to Enable and Subscribe to NETCONF Event Notifications

You must enable the NETCONF event notification service on a device before a NETCONF client can subscribe to event notifications in a NETCONF session. After the service is enabled, a NETCONF client subscribes to receive event notifications by sending a subscription request to the NETCONF server. The NETCONF server reply indicates if the request is successful. If the request is successful, the server sends asynchronous event notifications to the NETCONF client as the events occur and until the NETCONF session is terminated.

This example requires the following hardware and software:

  • Device running Junos OS Evolved Release 21.2R1 or later that supports the NETCONF event notification service. See Feature Explorer for supported devices.

To enable and subscribe to NETCONF event notifications, perform the following tasks:

Enable the NETCONF Event Notification Service

To enable a client to subscribe to event notifications in a NETCONF session:

  1. Enable the NETCONF event notification service by configuring the notification statement.
  2. (Optional) Configure the rfc-compliant statement to ensure the device is compliant with NETCONF RFC 4741.
  3. Enable notification services on the default port for applications running on the device.
  4. Commit the configuration.

Subscribe to Receive Event Notifications

After you enable the NETCONF event notification service on a device, NETCONF clients can subscribe to receive event notifications in a NETCONF session. A NETCONF client can include the following optional parameters in the subscription request:

  • <stream>—Stream of events that is of interest. The default and only acceptable value is NETCONF.

To subscribe to event notifications in a NETCONF session:

  1. Start the NETCONF session.
  2. Verify that the NETCONF event notification service is enabled on the device by confirming that the notification capability is advertised in the capabilities exchange.
  3. Issue a create-subscription request, and optionally specify the NETCONF stream.
  4. Verify that the subscription request is successful.

    The NETCONF server returns <ok/> if the request is successful or an <rpc-error> element if the subscription request cannot be completed.

    If the subscription request is successful, the NETCONF server starts sending event notifications asynchronously over the connection.

Terminate the Subscription

A NETCONF client terminates a subscription to receive event notifications by terminating either the NETCONF session or the NETCONF session’s underlying transport session.

To terminate the NETCONF session and subscription, perform one of the following actions:
  • Issue the <kill-session> operation from an external NETCONF session, and specify the session ID for the NETCONF session to end (as defined in the <session-id> element of the initial <hello> exchange).

  • Terminate the NETCONF session’s underlying transport session.