ajout partie parseurs_logs_switch

This commit is contained in:
Chevallier
2026-05-20 13:56:08 +02:00
parent fea80315ef
commit 4ee633d0e1
71 changed files with 32926 additions and 1772 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -1,21 +0,0 @@
import sys
import os
from pathlib import Path
sys.path.append(os.path.dirname(__file__))
from scripts.mermaid import NetworkAnalyzer
from scripts.parse_uplinks import UplinkReportGenerator
def main():
"""Fonction principale du programme d'analyse."""
if len(sys.argv) != 2:
print("Usage: python main.py <fichier_log_coeur>")
sys.exit(1)
coeur_log_filename = sys.argv[1]
coeur_log_filename = os.path.basename(coeur_log_filename)
UplinkReportGenerator().generate_report(coeur_log_filename)
NetworkAnalyzer(base_dir=Path(__file__).parent).analyze(coeur_log_filename)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,82 @@
module ietf-snmp {
namespace "urn:ietf:params:xml:ns:yang:ietf-snmp";
prefix snmp;
include ietf-snmp-common {
revision-date 2014-12-10;
}
include ietf-snmp-engine {
revision-date 2014-12-10;
}
include ietf-snmp-target {
revision-date 2014-12-10;
}
include ietf-snmp-notification {
revision-date 2014-12-10;
}
include ietf-snmp-proxy {
revision-date 2014-12-10;
}
include ietf-snmp-community {
revision-date 2014-12-10;
}
include ietf-snmp-usm {
revision-date 2014-12-10;
}
include ietf-snmp-tsm {
revision-date 2014-12-10;
}
include ietf-snmp-vacm {
revision-date 2014-12-10;
}
include ietf-snmp-tls {
revision-date 2014-12-10;
}
include ietf-snmp-ssh {
revision-date 2014-12-10;
}
organization
"IETF NETMOD (NETCONF Data Modeling Language) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netmod/>
WG List: <mailto:netmod@ietf.org>
WG Chair: Thomas Nadeau
<mailto:tnadeau@lucidvision.com>
WG Chair: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Editor: Martin Bjorklund
<mailto:mbj@tail-f.com>
Editor: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>";
description
"This module contains a collection of YANG definitions for
configuring SNMP engines.
Copyright (c) 2014 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 7407; see
the RFC itself for full legal notices.";
revision 2014-12-10 {
description
"Initial revision.";
reference
"RFC 7407: A YANG Data Model for SNMP Configuration";
}
}

View File

@@ -0,0 +1,211 @@
submodule openconfig-aaa-radius {
yang-version "1";
belongs-to "openconfig-aaa" {
prefix "oc-aaa";
}
// import some basic types
import openconfig-inet-types { prefix oc-inet; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-aaa-types { prefix oc-aaa-types; }
import openconfig-types { prefix oc-types; }
import openconfig-yang-types { prefix oc-yang; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
related to the RADIUS protocol for authentication,
authorization, and accounting.";
oc-ext:openconfig-version "1.1.0";
revision 2025-10-31 {
description
"Added GLOME path.";
reference "1.1.0";
}
revision "2022-07-29" {
description
"Update user role to be mandatory.";
reference "1.0.0";
}
revision "2020-07-30" {
description
"Add secret-key-hashed.";
reference "0.5.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.4.1";
}
revision "2017-09-18" {
description
"Updated to use OpenConfig types modules";
reference "0.3.0";
}
revision "2017-07-06" {
description
"Move to oc-inet types, add IETF attribution, add RADIUS
counters, changed password leaf names to indicate hashed";
reference "0.2.0";
}
revision "2017-01-29" {
description
"Initial public release";
reference "0.1.0";
}
// extension statements
// feature statements
// identity statements
identity RADIUS {
base oc-aaa-types:AAA_SERVER_TYPE;
description
"Remote Authentication Dial In User Service (RADIUS) AAA
server";
reference
"RFC 2865 - Remote Authentication Dial In User Service
(RADIUS)";
}
// typedef statements
// grouping statements
grouping aaa-radius-server-config {
description
"Configuration data for a RADIUS server";
leaf auth-port {
type oc-inet:port-number;
default 1812;
description
"Port number for authentication requests";
}
leaf acct-port {
type oc-inet:port-number;
default 1813;
description
"Port number for accounting requests";
}
leaf secret-key {
type oc-types:routing-password;
description
"The unencrypted shared key used between the authentication
server and the device.";
}
leaf secret-key-hashed {
type oc-aaa-types:crypt-password-type;
description
"The hashed shared key used between the authentication
server and the device.";
}
leaf source-address {
type oc-inet:ip-address;
description
"Source IP address to use in messages to the RADIUS server";
}
leaf retransmit-attempts {
type uint8;
description
"Number of times the system may resend a request to the
RADIUS server when it is unresponsive";
}
}
grouping aaa-radius-server-state {
description
"Operational state data for a RADIUS server";
container counters {
description
"A collection of RADIUS related state objects.";
leaf retried-access-requests {
type oc-yang:counter64;
description
"Retransmitted Access-Request messages.";
}
leaf access-accepts {
type oc-yang:counter64;
description
"Received Access-Accept messages.";
}
leaf access-rejects {
type oc-yang:counter64;
description
"Received Access-Reject messages.";
}
leaf timeout-access-requests {
type oc-yang:counter64;
description
"Access-Request messages that have timed-out,
requiring retransmission.";
}
}
}
grouping aaa-radius-server-top {
description
"Top-level grouping for RADIUS server data";
container radius {
description
"Top-level container for RADIUS server data";
container config {
description
"Configuration data for RADIUS servers";
uses aaa-radius-server-config;
}
container state {
config false;
description
"Operational state data for RADIUS servers";
uses aaa-radius-server-config;
uses aaa-radius-server-state;
}
}
}
// data definition statements
// augment statements
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,172 @@
module openconfig-aaa-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/aaa/types";
prefix "oc-aaa-types";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines shared types for data related to AAA
(authentication, authorization, accounting).";
oc-ext:openconfig-version "0.4.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.4.1";
}
revision "2018-04-12" {
description
"Add when conditions, correct identities";
reference "0.4.0";
}
revision "2017-09-18" {
description
"Updated to use OpenConfig types modules";
reference "0.3.0";
}
revision "2017-07-06" {
description
"Move to oc-inet types, add IETF attribution, add RADIUS
counters, changed password leaf names to indicate hashed";
reference "0.2.0";
}
revision "2017-01-29" {
description
"Initial public release";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity AAA_SERVER_TYPE {
description
"Base identity for types of AAA servers";
}
identity SYSTEM_DEFINED_ROLES {
description
"Base identity for system_defined roles that can be assigned
to users.";
}
identity SYSTEM_ROLE_ADMIN {
base SYSTEM_DEFINED_ROLES;
description
"Built-in role that allows the equivalent of superuser
permission for all configuration and operational commands
on the device.";
}
identity AAA_ACCOUNTING_EVENT_TYPE {
description
"Base identity for specifying events types that should be
sent to AAA server for accounting";
}
identity AAA_ACCOUNTING_EVENT_COMMAND {
base AAA_ACCOUNTING_EVENT_TYPE;
description
"Specifies interactive command events for AAA accounting";
}
identity AAA_ACCOUNTING_EVENT_LOGIN {
base AAA_ACCOUNTING_EVENT_TYPE;
description
"Specifies login events for AAA accounting";
}
identity AAA_AUTHORIZATION_EVENT_TYPE {
description
"Base identity for specifying activities that should be
sent to AAA server for authorization";
}
identity AAA_AUTHORIZATION_EVENT_COMMAND {
base AAA_AUTHORIZATION_EVENT_TYPE;
description
"Specifies interactive command events for AAA authorization";
}
identity AAA_AUTHORIZATION_EVENT_CONFIG {
base AAA_AUTHORIZATION_EVENT_TYPE;
description
"Specifies configuration (e.g., EXEC) events for AAA
authorization";
}
identity AAA_METHOD_TYPE {
description
"Base identity to define well-known methods for AAA
operations";
}
identity TACACS_ALL {
base AAA_METHOD_TYPE;
description
"The group of all TACACS+ servers.";
}
identity RADIUS_ALL {
base AAA_METHOD_TYPE;
description
"The group of all RADIUS servers.";
}
identity LOCAL {
base AAA_METHOD_TYPE;
description
"Locally configured method for AAA operations.";
}
// typedef statements
typedef crypt-password-type {
type string;
description
"A password that is hashed based on the hash algorithm
indicated by the prefix in the string. The string
takes the following form, based on the Unix crypt function:
$<id>[$<param>=<value>(,<param>=<value>)*][$<salt>[$<hash>]]
Common hash functions include:
id | hash function
---+---------------
1 | MD5
2a| Blowfish
2y| Blowfish (correct handling of 8-bit chars)
5 | SHA-256
6 | SHA-512
These may not all be supported by a target device.";
}
}

View File

@@ -0,0 +1,865 @@
module openconfig-aaa {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/aaa";
prefix "oc-aaa";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
import openconfig-inet-types { prefix oc-inet; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-aaa-types { prefix oc-aaa-types; }
include openconfig-aaa-tacacs;
include openconfig-aaa-radius;
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
related to authorization, authentication, and accounting (AAA)
management.
Portions of this model reuse data definitions or structure from
RFC 7317 - A YANG Data Model for System Management";
oc-ext:openconfig-version "1.1.0";
revision 2025-10-31 {
description
"Added GLOME path.";
reference "1.1.0";
}
revision "2022-07-29" {
description
"Update user role to be mandatory.";
reference "1.0.0";
}
revision "2020-07-30" {
description
"Add secret-key-hashed for TACACS and RADIUS.";
reference "0.5.0";
}
revision "2019-10-28" {
description
"Fix bug in when statement path";
reference "0.4.3";
}
revision "2019-08-20" {
description
"Fix identity prefixes and when statement paths";
reference "0.4.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.4.1";
}
revision "2018-04-12" {
description
"Add when conditions, correct identities";
reference "0.4.0";
}
revision "2017-09-18" {
description
"Updated to use OpenConfig types modules";
reference "0.3.0";
}
revision "2017-07-06" {
description
"Move to oc-inet types, add IETF attribution, add RADIUS
counters, changed password leaf names to indicate hashed";
reference "0.2.0";
}
revision "2017-01-29" {
description
"Initial public release";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// grouping statements
grouping aaa-servergroup-common-config {
description
"Configuration data for AAA server groups";
leaf name {
type string;
description
"Name for the server group";
}
leaf type {
type identityref {
base oc-aaa-types:AAA_SERVER_TYPE;
}
description
"AAA server type -- all servers in the group must be of this
type";
}
}
grouping aaa-servergroup-common-state {
description
"Operational state data for AAA server groups";
//TODO: add list of group members as opstate
}
grouping aaa-servergroup-common-top {
description
"Top-level grouping for AAA server groups";
container server-groups {
description
"Enclosing container for AAA server groups";
list server-group {
key "name";
description
"List of AAA server groups. All servers in a group
must have the same type as indicated by the server
type.";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to configured name of the server group";
}
container config {
description
"Configuration data for each server group";
uses aaa-servergroup-common-config;
}
container state {
config false;
description
"Operational state data for each server group";
uses aaa-servergroup-common-config;
uses aaa-servergroup-common-state;
}
uses aaa-server-top;
}
}
}
grouping aaa-server-config {
description
"Common configuration data for AAA servers";
leaf name {
type string;
description
"Name assigned to the server";
}
leaf address {
type oc-inet:ip-address;
description "Address of the authentication server";
}
leaf timeout {
type uint16;
units seconds;
description
"Set the timeout in seconds on responses from the AAA
server";
}
}
grouping aaa-server-state {
description
"Common operational state data for AAA servers";
leaf connection-opens {
type oc-yang:counter64;
description
"Number of new connection requests sent to the server, e.g.
socket open";
}
leaf connection-closes {
type oc-yang:counter64;
description
"Number of connection close requests sent to the server, e.g.
socket close";
}
leaf connection-aborts {
type oc-yang:counter64;
description
"Number of aborted connections to the server. These do
not include connections that are close gracefully.";
}
leaf connection-failures {
type oc-yang:counter64;
description
"Number of connection failures to the server";
}
leaf connection-timeouts {
type oc-yang:counter64;
description
"Number of connection timeouts to the server";
}
leaf messages-sent {
type oc-yang:counter64;
description
"Number of messages sent to the server";
}
leaf messages-received {
type oc-yang:counter64;
description
"Number of messages received by the server";
}
leaf errors-received {
type oc-yang:counter64;
description
"Number of error messages received from the server";
}
}
grouping aaa-server-top {
description
"Top-level grouping for list of AAA servers";
container servers {
description
"Enclosing container the list of servers";
list server {
key "address";
description
"List of AAA servers";
leaf address {
type leafref {
path "../config/address";
}
description
"Reference to the configured address of the AAA server";
}
container config {
description
"Configuration data ";
uses aaa-server-config;
}
container state {
config false;
description
"Operational state data ";
uses aaa-server-config;
uses aaa-server-state;
}
uses aaa-tacacs-server-top {
when "../../config/type = 'oc-aaa:TACACS'";
}
uses aaa-radius-server-top {
when "../../config/type = 'oc-aaa:RADIUS'";
}
}
}
}
grouping aaa-admin-config {
description
"Configuration data for the system built-in
administrator / root user account";
leaf admin-password {
type string;
oc-ext:openconfig-hashed-value;
description
"The admin/root password, supplied as a cleartext string.
The system should hash and only store the password as a
hashed value.";
}
leaf admin-password-hashed {
type oc-aaa-types:crypt-password-type;
description
"The admin/root password, supplied as a hashed value
using the notation described in the definition of the
crypt-password-type.";
}
}
grouping aaa-admin-state {
description
"Operational state data for the root user";
leaf admin-username {
type string;
description
"Name of the administrator user account, e.g., admin, root,
etc.";
}
}
grouping aaa-authentication-admin-top {
description
"Top-level grouping for root user configuration and state
data";
container admin-user {
description
"Top-level container for the system root or admin user
configuration and operational state";
container config {
description
"Configuration data for the root user account";
uses aaa-admin-config;
}
container state {
config false;
description
"Operational state data for the root user account";
uses aaa-admin-config;
uses aaa-admin-state;
}
}
}
grouping aaa-authentication-user-config {
description
"Configuration data for local users";
leaf username {
type string;
description
"Assigned username for this user";
}
leaf password {
type string;
oc-ext:openconfig-hashed-value;
description
"The user password, supplied as cleartext. The system
must hash the value and only store the hashed value.";
}
leaf password-hashed {
type oc-aaa-types:crypt-password-type;
description
"The user password, supplied as a hashed value
using the notation described in the definition of the
crypt-password-type.";
}
leaf ssh-key {
type string;
description
"SSH public key for the user (RSA or DSA)";
}
leaf role {
type union {
type string;
type identityref {
base oc-aaa-types:SYSTEM_DEFINED_ROLES;
}
}
mandatory true;
description
"Role assigned to the user. The role must be supplied
as a role defined by the SYSTEM_DEFINED_ROLES
identity or a string that matches a user defined role.";
}
}
grouping aaa-authentication-user-state {
description
"Operational state data for local users";
}
grouping aaa-authentication-user-top {
description
"Top-level grouping for local users";
container users {
description
"Enclosing container list of local users";
list user {
key "username";
description
"List of local users on the system";
leaf username {
type leafref {
path "../config/username";
}
description
"References the configured username for the user";
}
container config {
description
"Configuration data for local users";
uses aaa-authentication-user-config;
}
container state {
config false;
description
"Operational state data for local users";
uses aaa-authentication-user-config;
uses aaa-authentication-user-state;
}
}
}
}
grouping aaa-accounting-methods-common {
description
"Common definitions for accounting methods";
leaf-list accounting-method {
type union {
type identityref {
base oc-aaa-types:AAA_METHOD_TYPE;
}
type string;
//TODO: in YANG 1.1 this should be converted to a leafref to
//point to the server group name.
}
ordered-by user;
description
"An ordered list of methods used for AAA accounting for this
event type. The method is defined by the destination for
accounting data, which may be specified as the group of
all TACACS+/RADIUS servers, a defined server group, or
the local system.";
}
}
grouping aaa-accounting-events-config {
description
"Configuration data for AAA accounting events";
leaf event-type {
type identityref {
base oc-aaa-types:AAA_ACCOUNTING_EVENT_TYPE;
}
description
"The type of activity to record at the AAA accounting
server";
}
leaf record {
type enumeration {
enum START_STOP {
description
"Send START record to the accounting server at the
beginning of the activity, and STOP record at the
end of the activity.";
}
enum STOP {
description
"Send STOP record to the accounting server when the
user activity completes";
}
}
description
"Type of record to send to the accounting server for this
activity type";
}
}
grouping aaa-accounting-events-state {
description
"Operational state data for accounting events";
}
grouping aaa-accounting-events-top {
description
"Top-level grouping for accounting events";
container events {
description
"Enclosing container for defining handling of events
for accounting";
list event {
key "event-type";
description
"List of events subject to accounting";
leaf event-type {
type leafref {
path "../config/event-type";
}
description
"Reference to the event-type being logged at the
accounting server";
}
container config {
description
"Configuration data for accounting events";
uses aaa-accounting-events-config;
}
container state {
config false;
description
"Operational state data for accounting events";
uses aaa-accounting-events-config;
uses aaa-accounting-events-state;
}
}
}
}
grouping aaa-accounting-config {
description
"Configuration data for event accounting";
uses aaa-accounting-methods-common;
}
grouping aaa-accounting-state {
description
"Operational state data for event accounting services";
}
grouping aaa-accounting-top {
description
"Top-level grouping for user activity accounting";
container accounting {
description
"Top-level container for AAA accounting";
container config {
description
"Configuration data for user activity accounting.";
uses aaa-accounting-config;
}
container state {
config false;
description
"Operational state data for user accounting.";
uses aaa-accounting-config;
uses aaa-accounting-state;
}
uses aaa-accounting-events-top;
}
}
grouping aaa-authorization-methods-config {
description
"Common definitions for authorization methods for global
and per-event type";
leaf-list authorization-method {
type union {
type identityref {
base oc-aaa-types:AAA_METHOD_TYPE;
}
type string;
}
ordered-by user;
description
"Ordered list of methods for authorizing commands. The first
method that provides a response (positive or negative) should
be used. The list may contain a well-defined method such
as the set of all TACACS or RADIUS servers, or the name of
a defined AAA server group. The system must validate
that the named server group exists.";
}
}
grouping aaa-authorization-events-config {
description
"Configuration data for AAA authorization events";
leaf event-type {
type identityref {
base oc-aaa-types:AAA_AUTHORIZATION_EVENT_TYPE;
}
description
"The type of event to record at the AAA authorization
server";
}
}
grouping aaa-authorization-events-state {
description
"Operational state data for AAA authorization events";
}
grouping aaa-authorization-events-top {
description
"Top-level grouping for authorization events";
container events {
description
"Enclosing container for the set of events subject
to authorization";
list event {
key "event-type";
description
"List of events subject to AAA authorization";
leaf event-type {
type leafref {
path "../config/event-type";
}
description
"Reference to the event-type list key";
}
container config {
description
"Configuration data for each authorized event";
uses aaa-authorization-events-config;
}
container state {
config false;
description
"Operational state data for each authorized activity";
uses aaa-authorization-events-config;
uses aaa-authorization-events-state;
}
}
}
}
grouping aaa-authorization-config {
description
"Configuration data for AAA authorization";
uses aaa-authorization-methods-config;
}
grouping aaa-authorization-state {
description
"Operational state data for AAA authorization";
}
grouping aaa-authorization-top {
description
"Top-level grouping for AAA authorization";
container authorization {
description
"Top-level container for AAA authorization configuration
and operational state data";
container config {
description
"Configuration data for authorization based on AAA
methods";
uses aaa-authorization-config;
}
container state {
config false;
description
"Operational state data for authorization based on AAA";
uses aaa-authorization-config;
uses aaa-authorization-state;
}
uses aaa-authorization-events-top;
}
}
grouping aaa-authentication-config {
description
"Configuration data for global authentication";
leaf-list authentication-method {
type union {
type identityref {
base oc-aaa-types:AAA_METHOD_TYPE;
}
type string;
//TODO: string should be a leafref to a defined
//server group. this will be possible in YANG 1.1
//type leafref {
//path "/aaa/server-groups/server-group/config/name";
//}
}
ordered-by user;
description
"Ordered list of authentication methods for users. This
can be either a reference to a server group, or a well-
defined designation in the AAA_METHOD_TYPE identity. If
authentication fails with one method, the next defined
method is tried -- failure of all methods results in the
user being denied access.";
}
}
grouping aaa-authentication-state {
description
"Operational state data for global authentication";
}
grouping aaa-authentication-top {
description
"Top-level grouping for top-level authentication";
container authentication {
description
"Top-level container for global authentication data";
container glome {
description
"GLOME (Generic Low Overhead Message Exchange) authentication parameters for console access.";
container state {
config false;
description
"Operational state parameters for GLOME.";
}
}
container config {
description
"Configuration data for global authentication services";
uses aaa-authentication-config;
}
container state {
config false;
description
"Operational state data for global authentication
services";
uses aaa-authentication-config;
uses aaa-authentication-state;
}
uses aaa-authentication-admin-top;
uses aaa-authentication-user-top;
}
}
grouping aaa-config {
description
"Configuration data for top level AAA";
}
grouping aaa-state {
description
"Operational state data for top level AAA";
}
grouping aaa-top {
description
"Top-level grouping for AAA services";
container aaa {
description
"Top-level container for AAA services";
container config {
description
"Configuration data for top level AAA services";
uses aaa-config;
}
container state {
config false;
description
"Operational state data for top level AAA services ";
uses aaa-config;
uses aaa-state;
}
uses aaa-authentication-top;
uses aaa-authorization-top;
uses aaa-accounting-top;
uses aaa-servergroup-common-top;
}
}
// data definition statements
}

View File

@@ -0,0 +1,935 @@
module openconfig-acl {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/acl";
prefix "oc-acl";
import openconfig-packet-match { prefix oc-match; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state
data for network access control lists (i.e., filters, rules,
etc.). ACLs are organized into ACL sets, with each set
containing one or more ACL entries. ACL sets are identified
by a unique name, while each entry within a set is assigned
a sequence-id that determines the order in which the ACL
rules are applied to a packet. Note that ACLs are evaluated
in ascending order based on the sequence-id (low to high).
Individual ACL rules specify match criteria based on fields in
the packet, along with an action that defines how matching
packets should be handled. Entries have a type that indicates
the type of match criteria, e.g., MAC layer, IPv4, IPv6, etc.";
oc-ext:openconfig-version "1.3.3";
revision "2023-02-06" {
description
"Add clarifying comments on use of interface-ref.";
reference "1.3.3";
}
revision "2023-01-29" {
description
"Update sequence-id reference to allow model to be re-used
outside of ACL context.";
reference "1.3.2";
}
revision "2022-12-20" {
description
"Remove unused openconfig-inet-types import";
reference "1.3.1";
}
revision "2022-06-01" {
description
"Add the management of prefix lists
that can be used in matches";
reference "1.3.0";
}
revision "2022-01-14" {
description
"Fix when statements for MIXED mode ACLs";
reference "1.2.2";
}
revision "2021-06-16" {
description
"Remove trailing whitespace";
reference "1.2.1";
}
revision "2021-03-17" {
description
"Add MPLS filter Support.";
reference "1.2.0";
}
revision "2019-11-27" {
description
"Fix xpaths in when statements.";
reference "1.1.1";
}
revision "2019-10-25" {
description
"Update when statements.";
reference "1.1.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "1.0.2";
}
revision "2018-04-24" {
description
"Clarified order of ACL evaluation";
reference "1.0.1";
}
revision "2017-05-26" {
description
"Separated ACL entries by type";
reference "1.0.0";
}
revision "2016-08-08" {
description
"OpenConfig public release";
reference "0.2.0";
}
revision "2016-01-22" {
description
"Initial revision";
reference "TBD";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
identity ACL_TYPE {
description
"Base identity for types of ACL sets";
}
identity ACL_IPV4 {
base ACL_TYPE;
description
"IP-layer ACLs with IPv4 addresses";
}
identity ACL_IPV6 {
base ACL_TYPE;
description
"IP-layer ACLs with IPv6 addresses";
}
identity ACL_L2 {
base ACL_TYPE;
description
"MAC-layer ACLs";
}
identity ACL_MIXED {
base ACL_TYPE;
description
"Mixed-mode ACL that specifies L2 and L3 protocol
fields. This ACL type is not implemented by many
routing/switching devices.";
}
identity ACL_MPLS {
base ACL_TYPE;
description
"An ACL that matches on fields from the MPLS header.";
}
// ACL action type
identity FORWARDING_ACTION {
description
"Base identity for actions in the forwarding category";
}
identity ACCEPT {
base FORWARDING_ACTION;
description
"Accept the packet";
}
identity DROP {
base FORWARDING_ACTION;
description
"Drop packet without sending any ICMP error message";
}
identity REJECT {
base FORWARDING_ACTION;
description
"Drop the packet and send an ICMP error message to the source";
}
identity LOG_ACTION {
description
"Base identity for defining the destination for logging
actions";
}
identity LOG_SYSLOG {
base LOG_ACTION;
description
"Log the packet in Syslog";
}
identity LOG_NONE {
base LOG_ACTION;
description
"No logging";
}
identity ACL_COUNTER_CAPABILITY {
description
"Base identity for system to indicate how it is able to report
counters";
}
identity INTERFACE_ONLY {
base ACL_COUNTER_CAPABILITY;
description
"ACL counters are available and reported only per interface";
}
identity AGGREGATE_ONLY {
base ACL_COUNTER_CAPABILITY;
description
"ACL counters are aggregated over all interfaces, and reported
only per ACL entry";
}
identity INTERFACE_AGGREGATE {
base ACL_COUNTER_CAPABILITY;
description
"ACL counters are reported per interface, and also aggregated
and reported per ACL entry.";
}
// grouping statements
// input interface
grouping input-interface-config {
description
"Config of interface";
}
grouping input-interface-state {
description
"State information of interface";
}
grouping input-interface-top {
description
"Input interface top level container";
container input-interface {
description
"Input interface container. The interface is resolved based
on the interface and subinterface leaves of the interface-ref
container, which are references to entries in the /interfaces
list.";
container config {
description
"Config data";
uses input-interface-config;
}
container state {
config false;
description
"State information";
uses input-interface-config;
uses input-interface-state;
}
uses oc-if:interface-ref;
}
}
// Action Type
grouping action-config {
description
"Config of action type";
leaf forwarding-action {
type identityref {
base FORWARDING_ACTION;
}
mandatory true;
description
"Specifies the forwarding action. One forwarding action
must be specified for each ACL entry";
}
leaf log-action {
type identityref {
base LOG_ACTION;
}
default LOG_NONE;
description
"Specifies the log action and destination for
matched packets. The default is not to log the
packet.";
}
}
grouping action-state {
description
"State information of action type";
}
grouping action-top {
description
"ACL action type top level container";
container actions {
description
"Enclosing container for list of ACL actions associated
with an entry";
container config {
description
"Config data for ACL actions";
uses action-config;
}
container state {
config false;
description
"State information for ACL actions";
uses action-config;
uses action-state;
}
}
}
grouping acl-counters-state {
description
"Common grouping for ACL counters";
leaf matched-packets {
type oc-yang:counter64;
description
"Count of the number of packets matching the current ACL
entry.
An implementation should provide this counter on a
per-interface per-ACL-entry if possible.
If an implementation only supports ACL counters per entry
(i.e., not broken out per interface), then the value
should be equal to the aggregate count across all interfaces.
An implementation that provides counters per entry per
interface is not required to also provide an aggregate count,
e.g., per entry -- the user is expected to be able implement
the required aggregation if such a count is needed.";
}
leaf matched-octets {
type oc-yang:counter64;
description
"Count of the number of octets (bytes) matching the current
ACL entry.
An implementation should provide this counter on a
per-interface per-ACL-entry if possible.
If an implementation only supports ACL counters per entry
(i.e., not broken out per interface), then the value
should be equal to the aggregate count across all interfaces.
An implementation that provides counters per entry per
interface is not required to also provide an aggregate count,
e.g., per entry -- the user is expected to be able implement
the required aggregation if such a count is needed.";
}
}
// Access List Entries
grouping access-list-entries-config {
description
"Access List Entries (ACE) config.";
leaf sequence-id {
type uint32;
description
"The sequence id determines the order in which ACL entries
are applied. The sequence id must be unique for each entry
in an ACL set. Target devices should apply the ACL entry
rules in ascending order determined by sequence id (low to
high), rather than the relying only on order in the list.";
}
leaf description {
type string;
description
"A user-defined description, or comment, for this Access List
Entry.";
}
}
grouping access-list-entries-state {
description
"Access List Entries state.";
uses acl-counters-state;
}
grouping access-list-entries-top {
description
"Access list entries to level container";
container acl-entries {
description
"Access list entries container";
list acl-entry {
key "sequence-id";
description
"List of ACL entries comprising an ACL set";
leaf sequence-id {
type leafref {
path "../config/sequence-id";
}
description
"references the list key";
}
container config {
description
"Access list entries config";
uses access-list-entries-config;
}
container state {
config false;
description
"State information for ACL entries";
uses access-list-entries-config;
uses access-list-entries-state;
}
uses oc-match:ethernet-header-top {
when "../../config/type='ACL_L2' or " +
"../../config/type='ACL_MIXED'" {
description
"MAC-layer fields are valid when the ACL type is L2 or
MIXED";
}
}
uses oc-match:ipv4-protocol-fields-top {
when "../../config/type='ACL_IPV4' or " +
"../../config/type='ACL_MIXED'" {
description
"IPv4-layer fields are valid when the ACL type is
IPv4 or MIXED";
}
}
uses oc-match:mpls-header-top {
when "../../config/type='ACL_MPLS' or " +
"../../config/type='ACL_MIXED'" {
description
"MPLS-layer fields are valid when the ACL type is
MPLS or MIXED";
}
}
uses oc-match:ipv6-protocol-fields-top {
when "../../config/type='ACL_IPV6' or " +
"../../config/type='ACL_MIXED'" {
description
"IPv6-layer fields are valid when the ACL type is
IPv6 or MIXED";
}
}
uses oc-match:transport-fields-top {
when "../../config/type='ACL_IPV6' or " +
"../../config/type='ACL_IPV4' or " +
"../../config/type='ACL_MIXED'" {
description
"Transport-layer fields are valid when specifying
L3 or MIXED ACL types";
}
}
uses input-interface-top;
uses action-top;
}
}
}
grouping acl-set-config {
description
"Access Control List config";
leaf name {
type string;
description
"The name of the access-list set";
}
leaf type {
type identityref {
base ACL_TYPE;
}
description
"The type determines the fields allowed in the ACL entries
belonging to the ACL set (e.g., IPv4, IPv6, etc.)";
}
leaf description {
type string;
description
"Description, or comment, for the ACL set";
}
}
grouping acl-set-state {
description
"Access Control List state";
}
grouping acl-set-top {
description
"Access list entries variables top level container";
container acl-sets {
description
"Access list entries variables enclosing container";
list acl-set {
key "name type";
description
"List of ACL sets, each comprising of a list of ACL
entries";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the name list key";
}
leaf type {
type leafref {
path "../config/type";
}
description
"Reference to the type list key";
}
container config {
description
"Access list config";
uses acl-set-config;
}
container state {
config false;
description
"Access list state information";
uses acl-set-config;
uses acl-set-state;
}
uses access-list-entries-top;
}
}
}
grouping interface-acl-entries-config {
description
"Configuration data for per-interface ACLs";
}
grouping interface-acl-entries-state {
description
"Operational state data for per-interface ACL entries";
leaf sequence-id {
type leafref {
path "/oc-acl:acl/oc-acl:acl-sets/" +
"oc-acl:acl-set[oc-acl:name=current()/../../../../set-name]" +
"[oc-acl:type=current()/../../../../type]/" +
"oc-acl:acl-entries/oc-acl:acl-entry/oc-acl:sequence-id";
}
description
"Reference to an entry in the ACL set applied to an
interface";
}
uses acl-counters-state;
}
grouping interface-acl-entries-top {
description
"Top-level grouping for per-interface ACL entries";
container acl-entries {
config false;
description
"Enclosing container for list of references to ACLs";
list acl-entry {
key "sequence-id";
description
"List of ACL entries assigned to an interface";
leaf sequence-id {
type leafref {
path "../state/sequence-id";
}
description
"Reference to per-interface acl entry key";
}
// no config container since the enclosing container is
// read-only
container state {
config false;
description
"Operational state data for per-interface ACL entries";
uses interface-acl-entries-config;
uses interface-acl-entries-state;
}
}
}
}
grouping interface-ingress-acl-config {
description
"Configuration data for per-interface ingress ACLs";
leaf set-name {
type leafref {
path "../../../../../../acl-sets/acl-set/config/name";
}
description
"Reference to the ACL set name applied on ingress";
}
leaf type {
type leafref {
path "../../../../../../acl-sets/acl-set[name=current()/../set-name]" +
"/config/type";
}
description
"Reference to the ACL set type applied on ingress";
}
}
grouping interface-ingress-acl-state {
description
"Operational state data for the per-interface ingress ACL";
}
grouping interface-ingress-acl-top {
description
"Top-level grouping for per-interface ingress ACL data";
container ingress-acl-sets {
description
"Enclosing container the list of ingress ACLs on the
interface";
list ingress-acl-set {
key "set-name type";
description
"List of ingress ACLs on the interface";
leaf set-name {
type leafref {
path "../config/set-name";
}
description
"Reference to set name list key";
}
leaf type {
type leafref {
path "../config/type";
}
description
"Reference to type list key";
}
container config {
description
"Configuration data ";
uses interface-ingress-acl-config;
}
container state {
config false;
description
"Operational state data for interface ingress ACLs";
uses interface-ingress-acl-config;
uses interface-ingress-acl-state;
}
uses interface-acl-entries-top;
}
}
}
grouping interface-egress-acl-config {
description
"Configuration data for per-interface egress ACLs";
leaf set-name {
type leafref {
path "../../../../../../acl-sets/acl-set/config/name";
}
description
"Reference to the ACL set name applied on egress";
}
leaf type {
type leafref {
path "../../../../../../acl-sets/acl-set[name=current()/../set-name]" +
"/config/type";
}
description
"Reference to the ACL set type applied on egress.";
}
}
grouping interface-egress-acl-state {
description
"Operational state data for the per-interface egress ACL";
}
grouping interface-egress-acl-top {
description
"Top-level grouping for per-interface egress ACL data";
container egress-acl-sets {
description
"Enclosing container the list of egress ACLs on the
interface";
list egress-acl-set {
key "set-name type";
description
"List of egress ACLs on the interface";
leaf set-name {
type leafref {
path "../config/set-name";
}
description
"Reference to set name list key";
}
leaf type {
type leafref {
path "../config/type";
}
description
"Reference to type list key";
}
container config {
description
"Configuration data ";
uses interface-egress-acl-config;
}
container state {
config false;
description
"Operational state data for interface egress ACLs";
uses interface-egress-acl-config;
uses interface-egress-acl-state;
}
uses interface-acl-entries-top;
}
}
}
grouping acl-interfaces-config {
description
"Configuration data for interface references";
leaf id {
type oc-if:interface-id;
description
"User-defined identifier for the interface -- a common
convention could be '<if name>.<subif index>'";
}
}
grouping acl-interfaces-state {
description
"Operational state data for interface references";
}
grouping acl-interfaces-top {
description
"Top-level grouping for interface-specific ACL data";
container interfaces {
description
"Enclosing container for the list of interfaces on which
ACLs are set";
list interface {
key "id";
description
"List of interfaces on which ACLs are set. The interface is resolved
based on the interface and subinterface leaves of the interface-ref
container, which are references to entries in the /interfaces
list. The key of the list is an arbitrary value that the
implementation should not use to resolve an interface name.";
leaf id {
type leafref {
path "../config/id";
}
description
"Reference to the interface id list key";
}
container config {
description
"Configuration for ACL per-interface data";
uses acl-interfaces-config;
}
container state {
config false;
description
"Operational state for ACL per-interface data";
uses acl-interfaces-config;
uses acl-interfaces-state;
}
uses oc-if:interface-ref;
uses interface-ingress-acl-top;
uses interface-egress-acl-top;
}
}
}
grouping acl-config {
description
"Global configuration data for ACLs";
}
grouping acl-state {
description
"Global operational state data for ACLs";
leaf counter-capability {
type identityref {
base ACL_COUNTER_CAPABILITY;
}
description
"System reported indication of how ACL counters are reported
by the target";
}
}
grouping acl-top {
description
"Top level grouping for ACL data and structure";
container acl {
description
"Top level enclosing container for ACL model config
and operational state data";
container config {
description
"Global config data for ACLs";
uses acl-config;
}
container state {
config false;
description
"Global operational state data for ACLs";
uses acl-config;
uses acl-state;
}
uses acl-set-top;
uses acl-interfaces-top;
}
}
// data definition statements
uses acl-top;
// augment statements
}

View File

@@ -0,0 +1,855 @@
module openconfig-bfd {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/bfd";
prefix "oc-bfd";
// import some basic types
import openconfig-extensions { prefix "oc-ext"; }
import openconfig-types { prefix "oc-types"; }
import openconfig-interfaces { prefix "oc-if"; }
import openconfig-inet-types { prefix "oc-inet"; }
import openconfig-policy-types { prefix "oc-pol-types"; }
import ietf-inet-types { prefix "ietf-if"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"An OpenConfig model of Bi-Directional Forwarding Detection (BFD)
configuration and operational state.";
oc-ext:openconfig-version "0.5.0";
revision "2025-09-03" {
description
"Add desired-min-echo-tx-interval and required-min-echo-rx-interval
leaves in bfd-interface-config to allow RFC 9127-compliant BFD echo
mode configuration per interface.";
reference "0.5.0";
}
revision "2025-03-18" {
description
"Clarify BFD session failure as a transition
from the UP state to the DOWN state. This does not include
UP to ADMIN_DOWN transitions, since when the BFD session is
administratively disabled it is not a session failure.";
reference "0.4.1";
}
revision "2025-02-05" {
description
"Move the up-transitions leaf from the async and echo
sub-containers into the state container.";
reference "0.4.0";
}
revision "2024-12-16" {
description
"Add Bfd diagnostic code for when
neighbor signaled session down. Specified in RFC5880.";
reference "0.3.1";
}
revision "2024-03-05" {
description
"Add configuration of min interval, multiplier when
BFD is enabled at protocol level";
reference "0.3.0";
}
revision "2023-08-09" {
description
"Update interface key to use interface-id type";
reference "0.2.6";
}
revision "2023-02-06" {
description
"Clarify interface references.";
reference "0.2.5";
}
revision "2022-06-28" {
description
"Remove reference to invalid oc-ift type check";
reference "0.2.4";
}
revision "2021-06-16" {
description
"Remove trailing whitespace";
reference "0.2.3";
}
revision "2021-03-17" {
description
"Remove augments from bfd module.
Add bfd support directly on the protocols";
reference "0.2.2";
}
revision "2020-05-08" {
description
"Ensure that when statements reference only read-write leaves
from read-write contexts.
Add ietf-inet-types LAG type to conditions for micro-bfd.";
reference "0.2.1";
}
revision "2019-10-25" {
description
"Correct when statements.";
reference "0.2.0";
}
revision "2019-06-02" {
description
"Fix detection multiplier to be 8-bit value";
reference "0.1.1";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.0";
}
revision "2017-10-19" {
description
"Adopt OpenConfig types models, type corrections";
reference "0.0.2";
}
revision "2016-06-24" {
description
"Initial revision";
reference "0.0.1";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
typedef bfd-session-state {
type enumeration {
enum UP {
description
"The BFD session is perceived to be up by the system.";
}
enum DOWN {
description
"The BFD session is perceived to be down by the system.";
}
enum ADMIN_DOWN {
description
"The BFD session is administratively disabled.";
}
enum INIT {
description
"The BFD session is perceived to be initialising by the
system.";
}
}
description
"The state of the BFD session according to the system referred
to by the context of the leaf.";
reference
"RFC5880 - Bidirectional Forwarding Detection, Section
4.1";
}
typedef bfd-diagnostic-code {
type enumeration {
enum NO_DIAGNOSTIC {
value 0;
description
"No diagnostic code was specified, or the session has not
changed state.";
}
enum DETECTION_TIMEOUT {
value 1;
description
"The control detection time expired: no BFD packet was
received within the required period.";
}
enum ECHO_FAILED {
value 2;
description
"The BFD echo function failed - echo packets have not been
received for the required period of time.";
}
enum FORWARDING_RESET {
value 3;
description
"The forwarding plane in the local system was reset - such
that the remote system cannot rely on the forwarding state of
the device specifying this error code.";
}
enum PATH_DOWN {
value 4;
description
"Signalling outside of BFD specified that the path underlying
this session has failed.";
}
enum CONCATENATED_PATH_DOWN {
value 5;
description
"When a BFD session runs over a series of path segments, this
error code indicates that a subsequent path segment (i.e.,
one in the transmit path between the source and destination
of the session) has failed.";
}
enum ADMIN_DOWN {
value 6;
description
"The BFD session has been administratively disabled by the
peer.";
}
enum REVERSE_CONCATENATED_PATH_DOWN {
value 7;
description
"In the case that a BFD session is running over a series of
path segments, this error code indicates that a path segment
on the reverse path (i.e., in the transmit direction from the
destination to the source of the session) has failed.";
}
enum NEIGHBOR_DOWN {
value 8;
description
"The Bfd neighbor signaled session down - Bfd packet was received with
neighbor state down.";
}
}
description
"Diagnostic codes defined by BFD. These typically indicate the
reason for a change of session state. The NEIGHBOR_DOWN diagnostic
was added to the enum at value 8 to avoid making a breaking change.
This deviates from RFC5880 where the enum is value 3. This also
shifts the following values by 1, in relation to RFC5880:
FORWARDING_RESET, PATH_DOWN, CONCATENATED_PATH_DOWN,
ADMIN_DOWN, REVERSE_CONCATENATED_PATH_DOWN.";
reference
"RFC5880 - Bidirectional Forwarding Detection, Section
4.1";
}
grouping bfd-interface-config {
description
"Top-level per-interface configuration parameters for BFD.";
leaf id {
type oc-if:interface-id;
description
"A unique identifier for the interface.";
}
leaf enabled {
type boolean;
description
"When this leaf is set to true then the BFD session is enabled
on the specified interface - if it is set to false, it is
administratively disabled.";
}
leaf local-address {
type oc-inet:ip-address;
description
"The source IP address to be used for BFD sessions over this
interface.";
}
uses bfd-configuration;
leaf enable-per-member-link {
type boolean;
default false;
description
"When this leaf is set to true - BFD will be enabled on
each member interface of the aggregated Ethernet bundle.";
}
leaf desired-min-echo-tx-interval {
type uint32;
units microseconds;
description
"The minimum interval between transmission of BFD echo
packets that the operator desires. This value controls the
transmission rate of echo packets sent by the local system.
Setting this value to 0 disables BFD echo mode on this
interface. This value is specified as an integer number
of microseconds.";
reference "RFC 9127, Appendix A.1";
}
leaf required-min-echo-rx-interval {
type uint32;
units microseconds;
description
"The minimum interval between received BFD echo packets that
this system should support. This value is advertised to the
remote peer and allows the peer to opt-out of echo mode or
specify receive capabilities. Setting this value to 0 indicates
that the local system does not support receiving echo packets.
This value is specified as an integer number of microseconds.";
reference "RFC 9127, Appendix A.1";
}
}
grouping bfd-interface-state {
// placeholder
description
"Operational state parameters relating to BFD running on an
interface.";
}
grouping bfd-session-state-mode-timers-common {
description
"Common operational state parameters that are re-used across
both asynchronous and echo modes of BFD.";
leaf last-packet-transmitted {
type uint64;
description
"The date and time at which the last BFD packet
was transmitted for this session, expressed as the number
of nanoseconds since the Unix Epoch (January 1, 1970,
00:00 UTC).";
}
leaf last-packet-received {
type uint64;
description
"The date and time at which the last BFD packet
was received for this session, expressed as the number
of nanoseconds since the Unix Epoch (January 1, 1970,
00:00 UTC).";
}
leaf transmitted-packets {
type uint64;
description
"The number of packets that have been transmitted
by the local system.";
}
leaf received-packets {
// TODO: looks to be unsupported on JUNOS
type uint64;
description
"The number of packets that have been received by the
local system from the remote neighbour.";
}
leaf up-transitions {
status deprecated;
type uint64;
description
"The number of times that the adjacency with the neighbor
has transitioned into the up state.
This leaf is deprecated and will be replaced by a single
up-transitions leaf in state container. New path:
/bfd/interfaces/interface/peers/peer/state/up-transitions.";
}
}
grouping bfd-session-state-sessiondetails-common {
description
"Common session details for a BFD session.";
leaf session-state {
type bfd-session-state;
description
"The state of the BFD session perceived by the local system.";
}
leaf remote-session-state {
type bfd-session-state;
description
"The reported state of the BFD session according to the remote
system. This state reflects the last state reported in a BFD
control packet.";
}
leaf last-failure-time {
type oc-types:timeticks64;
description
"The time of the last transition of the BFD session from the UP state
to the DOWN state, expressed as the number of nanoseconds since
the Unix epoch. This does not include UP to ADMIN_DOWN transitions";
}
leaf failure-transitions {
type uint64;
description
"The number of times that the BFD session has transitioned
from the UP state to the DOWN state. This does not include
UP to ADMIN_DOWN transitions";
}
leaf up-transitions {
// TODO: looks to only be supported in SROS
type uint64;
description
"The number of times that the adjacency with the neighbor
has transitioned into the up state.";
}
leaf local-discriminator {
type string;
description
"A unique identifier used by the local system to identify this
BFD session.";
}
leaf remote-discriminator {
type string;
description
"A unique identified used by the remote system to identify this
BFD session.";
}
leaf local-diagnostic-code {
type bfd-diagnostic-code;
description
"The local BFD diagnostic code indicating the most recent
reason for failure of this BFD session.";
}
leaf remote-diagnostic-code {
type bfd-diagnostic-code;
description
"The remote BFD diagnostic code indicating the remote system's
reason for failure of the BFD session";
}
leaf remote-minimum-receive-interval {
type uint32;
description
"The value of the minimum receive interval that was specified
in the most recent BFD control packet received from the peer.";
}
leaf demand-mode-requested {
type boolean;
description
"This leaf is set to true when the remote system has requested
demand mode be run for this session.";
}
leaf remote-authentication-enabled {
type boolean;
description
"This leaf is set to true when the remote system has specified
that authentication is present for the BFD session.";
}
leaf remote-control-plane-independent {
type boolean;
description
"This leaf is set to true when the remote system has specified
that the hardware implementing this BFD session is independent
of the control plane's liveliness.";
}
}
grouping bfd-session-state-async-common {
description
"Common parameters for asynchronous BFD sessions";
container async {
description
"Operational state parameters specifically relating to
asynchronous mode of BFD.";
uses bfd-session-state-mode-timers-common;
}
}
grouping bfd-session-state-echo-common {
description
"Common parameters for echo-mode BFD sessions.";
container echo {
description
"Operational state parameters specifically relating to the
echo mode of BFD.";
leaf active {
type boolean;
description
"This leaf is set to true when echo mode is running between
the local and remote system. When it is set to false, solely
asynchronous mode is active.";
}
uses bfd-session-state-mode-timers-common;
}
}
grouping bfd-session-state-common {
description
"Common operational state parameters that may be re-used across
multiple BFD session contexts.";
leaf local-address {
type oc-inet:ip-address;
description
"The IP address used by the local system for this BFD session.";
}
leaf remote-address {
type oc-inet:ip-address;
description
"The IP address used by the remote system for this BFD session.";
}
leaf-list subscribed-protocols {
type identityref {
base "oc-pol-types:INSTALL_PROTOCOL_TYPE";
}
description
"Indicates the set of protocols that currently use
this BFD session for liveliness detection.";
}
uses bfd-session-state-sessiondetails-common;
uses bfd-session-state-echo-common;
uses bfd-session-state-async-common;
}
grouping bfd-session-microbfd-common {
description
"BFD session parameters utilised only for micro-BFD sessions.";
uses bfd-session-state-sessiondetails-common;
uses bfd-session-state-async-common;
}
grouping bfd-interface-peer-state {
description
"Per-peer, per-interface operational state parameters for BFD.";
uses bfd-session-state-common;
}
grouping bfd-interface-microbfd-config {
description
"Configuration parameters for a microBFD session on an
interface.";
leaf local-address {
type oc-inet:ip-address;
description
"The local IP address used by the system for the micro-BFD session
specified.";
}
leaf remote-address {
type oc-inet:ip-address;
description
"The remote IP destination that should be used by the system for
the micro-BFD session specified.";
}
leaf member-interface {
type leafref {
path "/oc-if:interfaces/" +
"oc-if:interface/oc-if:config/oc-if:name";
}
// rjs: Note that this does not restrict to only interfaces that
// are part of the current LAG. An implementation should return
// NOK if such an interface is specified.
description
"Reference to a member link of the aggregate interface being
described.";
}
}
grouping bfd-interface-microbfd-state {
description
"Operational state parameters relating to a micro-BFD session on
an interface.";
uses bfd-session-microbfd-common;
}
grouping bfd-interface-microbfd-structural {
description
"Structural grouping for micro-bfd configuration and state
parameters.";
container micro-bfd-sessions {
when "/oc-if:interfaces/oc-if:interface" +
"[oc-if:name=current()/../interface-ref/config/interface]/" +
"oc-if:config/oc-if:type = 'ietf-if:ieee8023adLag'" {
description
"Include per-member link BFD only when the type of
interface is a link aggregate.";
}
description
"Parameters relating to micro-BFD sessions associated
with the interface.";
list micro-bfd-session {
key "member-interface";
description
"This list contains configuration and state parameters
relating to micro-BFD session.";
reference
"RFC7130 - Bidirectional Forwarding Detection (BFD)
on Link Aggregation Group (LAG) Interfaces.";
leaf member-interface {
type leafref {
path "../config/member-interface";
}
description
"A reference to the member interface of the link
aggregate.";
}
container config {
description
"Configuration parameters for the micro-BFD session.";
uses bfd-interface-microbfd-config;
}
container state {
config false;
description
"Operational state parameters for the micro-BFD session.";
uses bfd-interface-microbfd-config;
uses bfd-interface-microbfd-state;
}
}
}
}
grouping bfd-interface-peer-structural {
description
"Structural grouping for BFD peers (in the context of an interface).";
container peers {
description
"Parameters relating to the BFD peers which are seen
over this interface.";
list peer {
key "local-discriminator";
config false;
description
"Parameters relating to the BFD peer specified by the
remote address.";
leaf local-discriminator {
type leafref {
path "../state/local-discriminator";
}
description
"The local discriminator, which is unique for the
session on the system.";
}
container state {
config false;
description
"Operational state parameters for the BFD session.";
uses bfd-interface-peer-state;
}
}
}
}
grouping bfd-top {
description
"Structural grouping for Bidirectional Forwarding Detection (BFD).";
container bfd {
description
"Configuration and operational state parameters for BFD.";
reference "RFC5880, RFC5881";
container interfaces {
description
"Interfaces on which BFD sessions are to be enabled.";
list interface {
key "id";
description
"Per-interface configuration and state parameters for BFD.
The interface referenced is based on the interface and
subinterface leaves within the interface-ref container -
which reference an entry in the /interfaces/interface list -
and should not rely on the value of the list key.";
leaf id {
type leafref {
path "../config/id";
}
description
"A reference to an identifier for the interface on which
BFD is enabled.";
}
container config {
description
"Configuration parameters for BFD on the specified
interface.";
uses bfd-interface-config;
}
container state {
config false;
description
"Operational state parameters for BFD on the specified
interface.";
uses bfd-interface-config;
uses bfd-interface-state;
}
uses oc-if:interface-ref;
uses bfd-interface-microbfd-structural;
uses bfd-interface-peer-structural;
}
}
}
}
grouping enable-bfd-config {
description
"Configuration parameters relating to enabling BFD.";
leaf enabled {
type boolean;
description
"When this leaf is set to true, BFD is used to detect the
liveliness of the remote peer or next-hop.";
}
}
grouping bfd-configuration {
description
"Configuration parameters of BFD when it is enabled in protocols.";
leaf desired-minimum-tx-interval {
type uint32;
units microseconds;
description
"The minimum interval between transmission of BFD control
packets that the operator desires. This value is advertised to
the peer, however the actual interval used is specified by
taking the maximum of desired-minimum-tx-interval and the
value of the remote required-minimum-receive interval value.
This value is specified as an integer number of microseconds.
The value 0 is reserved and cannot be used.";
reference "section 4.1 of RFC 5880";
}
leaf required-minimum-receive {
type uint32;
units microseconds;
description
"The minimum interval between received BFD control packets that
this system should support. This value is advertised to the
remote peer to indicate the maximum frequency (i.e., minimum
inter-packet interval) between BFD control packets that is
acceptable to the local system.";
reference "section 4.1 of RFC 5880";
}
leaf detection-multiplier {
type uint8 {
range "1..max";
}
description
"The number of packets that must be missed to declare this
session as down. The detection interval for the BFD session
is calculated by multiplying the value of the negotiated
transmission interval by this value.";
reference "section 4.1 of RFC 5880";
}
}
grouping enable-bfd-state {
description
"Operational state parameters relating to enabling BFD.";
leaf associated-session {
// TODO: this is a leafref to something unique, but seems
// like it might be expensive for the NMS to find out since
// it will need to cycle through all interfaces looking for
// the associated local-discriminator.
type leafref {
path "/bfd/interfaces/interface/peers/peer/local-discriminator";
}
description
"A reference to the BFD session that is tracking the liveliness
of the remote entity.";
}
//
// A fix to the above is to have the following leaf to show which
// interface is associated.
//
// leaf associated-interface {
// type leafref {
// path "/bfd/interfaces/interface/config/id";
// }
// }
}
grouping bfd-enable {
description
"Grouping which can be included in a protocol wishing to enable
BFD.";
container enable-bfd {
description
"Enable BFD for liveliness detection to the next-hop or
neighbour.";
container config {
description
"Configuration parameters relating to enabling BFD.";
uses enable-bfd-config;
uses bfd-configuration;
}
container state {
config false;
description
"Operational state parameters relating to enabing BFD.";
uses enable-bfd-config;
uses bfd-configuration;
//uses enable-bfd-state;
}
}
}
uses bfd-top;
}

View File

@@ -0,0 +1,318 @@
module openconfig-if-8021x {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces/8021x";
prefix "oc-1x";
// import some basic types
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-if-ethernet { prefix oc-eth; }
import openconfig-vlan { prefix oc-vlan; }
import openconfig-vlan-types { prefix oc-vlan-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
netopenconfig@googlegroups.com";
description
"Model for managing 8021X. Augments the OpenConfig models for
wired interfaces and wireless SSIDs for configuration and state.";
oc-ext:openconfig-version "0.0.1";
revision "2020-01-28" {
description
"Initial draft of model, including only the most common 802.1X
configuration and state use-cases.";
reference "0.0.1";
}
// grouping statements
grouping vlan-map-config {
description
"Configuration data for mapping from VLAN name to VLAN id.";
leaf vlan-name {
type string;
mandatory true;
description
"The VLAN name to be mapped to the VLAN id.";
}
leaf id {
type oc-vlan-types:vlan-id;
mandatory true;
description
"The VLAN id to be mapped to the VLAN name.";
}
}
grouping dot1x-port-config {
description
"802.1X port-based configuration.";
leaf authenticate-port {
type boolean;
description
"Enable 802.1X port control on an interface.";
}
leaf host-mode {
type enumeration {
enum SINGLE_HOST {
description
"Only single supplicant can communicate through the port.
If the supplicant logs off or the port state is changed,
the port becomes unauthenticated.";
}
enum MULTI_HOST {
description
"Multiple hosts can communicate over a single port.
Only the first supplicant is authenticated while
subsequent hosts have network access without having to
authenticate.";
}
enum MULTI_DOMAIN {
description
"Allows for authentication of multiple clients
individually on one authenticator port.";
}
}
description
"Allow for single or multiple hosts to communicate through
an 802.1X controlled port.";
}
leaf reauthenticate-interval {
type uint16;
units seconds;
description
"Enable periodic re-authentication of the device connected
to this port. Setting a value of 0 disabled reauthentication
on this port.";
}
leaf retransmit-interval {
type uint16;
units seconds;
description
"How long the interface waits for a response from an
EAPoL Start before restarting 802.1X authentication on the
port.";
}
leaf supplicant-timeout {
type uint16;
units seconds;
description
"Time to wait for a response from the supplicant before
restarting the 802.1X authentication process.";
}
leaf max-requests {
type uint16;
description
"Maximum number of times an EAPoL request packet is retransmitted
to the supplicant before the authentication session fails.";
}
leaf server-fail-vlan {
type union {
type string;
type oc-vlan-types:vlan-id;
}
description
"If RADIUS is unresponsive, the supplicant shall be placed in
this VLAN. If this VLAN is configured as a VLAN name, the
vlan-map must be populated for the Authenticator to map this
VLAN name to a VLAN id.";
}
leaf auth-fail-vlan {
type union {
type string;
type oc-vlan-types:vlan-id;
}
description
"Upon failure to authenticate, the port is set to this VLAN.
If this VLAN is a configured as a VLAN name, the vlan-map must
be populated for the Authenticator to map this VLAN name to a
VLAN id.";
}
}
grouping vlan-map-top {
description
"Top-level grouping for vlan-map configuration and Operational
state data.";
container dot1x-vlan-map {
description
"Enclosing container for mapping a VLAN name to VLAN id";
list vlan-name {
key "vlan-name";
description
"A list of mappings from VLAN name to VLAN id.
Entries in this list are utilized for DVA using a VLAN
name; eg when RADIUS returns a VLAN name as the
tunnel-private-group-id.";
reference
"RFC 2868: RADIUS Attributes for Tunnel Protocol Support";
leaf vlan-name {
type leafref {
path "../config/vlan-name";
}
description "References the configured VLAN name";
}
container config {
description "Configuration data for each configured VLAN
name in the VLAN ID to VLAN name mapping";
uses vlan-map-config;
}
container state {
config false;
description
"Operational state data for each VLAN id
to VLAN name mapping.";
uses vlan-map-config;
}
}
}
}
grouping dot1x-sessions-top {
description
"Top-level grouping for 802.1X sessions.";
container authenticated-sessions {
description
"Top level container for authenticated sessions state data.";
list authenticated-session {
key "mac";
config false;
description
"The list of authenticated sessions on this device.";
leaf mac {
type leafref {
path "../state/mac";
}
description
"Device MAC address.";
}
container state {
config false;
description
"Top level state container for 802.1X.";
leaf mac {
type oc-yang:mac-address;
description
"Device MAC address.";
}
uses dot1x-sessions-state;
}
}
}
}
grouping dot1x-sessions-state {
description
"Grouping for 802.1X sessions State data.";
leaf session-id {
type string;
description
"The locally-significant session id which this authenticated
session applies to. Typically used for RADIUS accounting or
other system level telemetry.";
}
leaf status {
type enumeration {
enum AUTHENTICATED {
description
"The session has succesfully completed one of the authentication
methods allowed on the port.";
}
enum AUTHENTICATING {
description
"The session is in the process of authenticating.";
}
enum FAILED_AUTHENTICATION {
description
"An authentication has been attempted for this session,
and has failed.";
}
enum SUPPLICANT_TIMEOUT {
description
"An authentication has been attempted for this session,
however the supplicant has not responded. This is likely
due to the attached devices lack of 802.1X support.";
}
}
description
"The status of the 802.1X session for a device.";
}
}
grouping dot1x-top {
description
"Top-level grouping for 802.1X configuration and operational
state data.";
container dot1x {
description
"Top level container for 802.1X configuration and
state data.";
container config {
description
"Top level configuration container for 802.1X.";
uses dot1x-port-config;
}
container state {
config false;
description
"Top level state container for 802.1X.";
uses dot1x-port-config;
}
}
uses dot1x-sessions-top;
}
// Augment statements
augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet" {
description
"Adds 802.1X settings to individual Ethernet interfaces";
uses dot1x-top;
}
augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" +
"oc-vlan:switched-vlan" {
description
"Adds vlan-map to switched-vlans.";
uses vlan-map-top;
}
}

View File

@@ -0,0 +1,263 @@
module openconfig-if-aggregate {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces/aggregate";
prefix "oc-lag";
// import some basic types
import openconfig-interfaces { prefix oc-if; }
import openconfig-if-ethernet { prefix oc-eth; }
import iana-if-type { prefix ianaift; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
netopenconfig@googlegroups.com";
description
"Model for managing aggregated (aka bundle, LAG) interfaces.";
oc-ext:openconfig-version "2.4.6";
revision "2026-01-06" {
description
"Fix typo in description for min-links leaf.";
reference "2.4.6";
}
revision "2025-04-22" {
description
"Updated the definition of lag-speed leaf";
reference "2.4.5";
}
revision "2022-06-28" {
description
"Remove reference to invalid oc-ift type check";
reference "2.4.4";
}
revision "2020-05-01" {
description
"Update when statements to reference config nodes
from config true elements.";
reference "2.4.3";
}
revision "2019-04-16" {
description
"Update import prefix for iana-if-type module";
reference "2.4.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "2.3.2";
}
revision "2018-03-23" {
description
"Fix/cleanup when statements in aggregates model.";
reference "2.3.1";
}
revision "2018-01-05" {
description
"Add logical loopback to interface.";
reference "2.3.0";
}
revision "2017-12-22" {
description
"Add IPv4 proxy ARP configuration.";
reference "2.2.0";
}
revision "2017-12-21" {
description
"Added IPv6 router advertisement configuration.";
reference "2.1.0";
}
revision "2017-07-14" {
description
"Added Ethernet/IP state data; Add dhcp-client;
migrate to OpenConfig types modules; Removed or
renamed opstate values";
reference "2.0.0";
}
revision "2016-12-22" {
description
"Fixes to Ethernet interfaces model";
reference "1.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// extension statements
// feature statements
// identity statements
// typedef statements
typedef aggregation-type {
type enumeration {
enum LACP {
description "LAG managed by LACP";
}
enum STATIC {
description "Statically configured bundle / LAG";
}
}
description
"Type to define the lag-type, i.e., how the LAG is
defined and managed";
}
// grouping statements
grouping aggregation-logical-config {
description
"Configuration data for aggregate interfaces";
leaf lag-type {
type aggregation-type;
description
"Sets the type of LAG, i.e., how it is
configured / maintained";
}
leaf min-links {
type uint16;
description
"Specifies the minimum number of member
interfaces that must be active for the aggregate interface
to be available";
}
}
grouping aggregation-logical-state {
description
"Operational state data for aggregate interfaces";
leaf lag-speed {
type uint32;
units Mbps;
description
"Reports the effective speed of the aggregate interface, calculated
as the sum of the speeds of member interfaces that are
active (operationally up), forwarding-viable and selected by the
aggregation protocol (e.g., LACP) for active traffic distribution";
}
leaf-list member {
when "../../config/lag-type = 'STATIC'" {
description
"The simple list of member interfaces is active
when the aggregate is statically configured";
}
type oc-if:base-interface-ref;
description
"List of current member interfaces for the aggregate,
expressed as references to existing interfaces";
}
}
grouping aggregation-logical-top {
description "Top-level data definitions for LAGs";
container aggregation {
description
"Options for logical interfaces representing
aggregates";
container config {
description
"Configuration variables for logical aggregate /
LAG interfaces";
uses aggregation-logical-config;
}
container state {
config false;
description
"Operational state variables for logical
aggregate / LAG interfaces";
uses aggregation-logical-config;
uses aggregation-logical-state;
}
}
}
grouping ethernet-if-aggregation-config {
description
"Adds configuration items for Ethernet interfaces
belonging to a logical aggregate / LAG";
leaf aggregate-id {
type leafref {
path "/oc-if:interfaces/oc-if:interface/oc-if:name";
}
description
"Specify the logical aggregate interface to which
this interface belongs";
}
}
// data definition statements
// augment statements
augment "/oc-if:interfaces/oc-if:interface" {
description "Adds LAG configuration to the interface module";
uses aggregation-logical-top {
when "oc-if:config/oc-if:type = 'ianaift:ieee8023adLag'" {
description
"active when the interface is set to type LAG";
}
}
}
augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" +
"oc-eth:config" {
description
"Adds LAG settings to individual Ethernet interfaces";
uses ethernet-if-aggregation-config;
}
augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" +
"oc-eth:state" {
description
"Adds LAG settings to individual Ethernet interfaces";
uses ethernet-if-aggregation-config;
}
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,117 @@
module openconfig-if-ethernet-ext {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces/ethernet-ext";
prefix "oc-eth-ext";
// import some basic types
import openconfig-interfaces { prefix oc-if; }
import openconfig-if-ethernet { prefix oc-eth; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module adds extensions to the base ethernet configuration
and operational state model to support additional use cases.";
oc-ext:openconfig-version "0.1.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2018-07-10" {
description
"Initial version of Ethernet extensions module to add frame
size distribution stats";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
grouping ethernet-in-frames-size-dist {
description
"Grouping for defining the size distribution of the frames
received";
container in-distribution {
description
"The size distribution of the received frames.";
leaf in-frames-64-octets {
type oc-yang:counter64;
description
"Number of packets (including bad packets) received that
were 64 bytes in length (excluding framing bits but
including FCS bytes).";
}
leaf in-frames-65-127-octets {
type oc-yang:counter64;
description
"Number of good and bad packets received that were
between 65 and 127 bytes in length (excluding framing bits
but including FCS bytes).";
}
leaf in-frames-128-255-octets {
type oc-yang:counter64;
description
"Number of good and bad packets received that were
between 128 and 255 bytes in length inclusive
(excluding framing bits but including FCS bytes).";
}
leaf in-frames-256-511-octets {
type oc-yang:counter64;
description
"Number of good and bad packets received that were
between 256 and 511 bytes in length inclusive
(excluding framing bits but including FCS bytes).";
}
leaf in-frames-512-1023-octets {
type oc-yang:counter64;
description
"Number of good and bad packets received that were
between 512 and 1023 bytes in length inclusive
(excluding framing bits but including FCS bytes).";
}
leaf in-frames-1024-1518-octets {
type oc-yang:counter64;
description
"Number of good and bad packets received that were
between 1024 and 1518 bytes in length inclusive
(excluding framing bits but including FCS bytes).";
}
}
}
// augment statements
augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" +
"oc-eth:state/oc-eth:counters" {
description
"Adds size distribution to the ethernet counters";
uses ethernet-in-frames-size-dist;
}
}

View File

@@ -0,0 +1,825 @@
module openconfig-if-ethernet {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces/ethernet";
prefix "oc-eth";
// import some basic types
import openconfig-interfaces { prefix oc-if; }
import iana-if-type { prefix ianaift; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-transport-types { prefix oc-opt-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
netopenconfig@googlegroups.com";
description
"Model for managing Ethernet interfaces -- augments the OpenConfig
model for interface configuration and state.";
oc-ext:openconfig-version "2.17.0";
revision "2026-03-12" {
description
"Add ethernet FEC modes for 200g serdes";
reference "2.17.0";
}
revision "2025-11-20" {
description
"Add ethernet FEC statistics - fec-uncorrectable-blocks,
fec-corrected-blocks and per-/post-FEC BER statics.
Deprecate in-block-errors as it is ambigous.";
reference "2.16.0";
}
revision "2025-11-14" {
description
"Add SPEED_1600GB to list of speeds.";
reference "2.15.0";
}
revision "2024-09-17" {
description
"Refactor config/state nodes to account for physical ethernet vs.
aggregate interface characteristics along with description updates
to indicate applicability.";
reference "2.14.0";
}
revision "2023-03-10" {
description
"Allow Ethernet configuration parameters to be
used for aggregate (LAG) interfaces.";
reference "2.13.0";
}
revision "2022-04-20" {
description
"Remove unused import";
reference "2.12.2";
}
revision "2021-07-20" {
description
"Fix typo in hardware MAC address description.";
reference "2.12.1";
}
revision "2021-07-07" {
description
"Add support for configuring fec-mode per interface.";
reference "2.12.0";
}
revision "2021-06-16" {
description
"Remove trailing whitespace.";
reference "2.11.1";
}
revision "2021-06-09" {
description
"Add support for standalone link training.";
reference "2.11.0";
}
revision "2021-05-17" {
description
"Add ethernet counters: in-carrier-errors,
in-interrupted-tx, in-late-collision, in-mac-errors-rx,
in-single-collision, in-symbol-error and out-mac-errors-tx";
reference "2.10.0";
}
revision "2021-03-30" {
description
"Add counter for drops due to oversized frames.";
reference "2.9.0";
}
revision "2020-05-06" {
description
"Minor formatting fix.";
reference "2.8.1";
}
revision "2020-05-06" {
description
"Add 200G, 400G, 600G and 800G Ethernet speeds.";
reference "2.8.0";
}
revision "2020-05-05" {
description
"Fix when statement checks to use rw paths when
from a rw context.";
reference "2.7.3";
}
revision "2019-04-16" {
description
"Update import prefix for iana-if-type module";
reference "2.7.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "2.6.2";
}
revision "2018-09-04" {
description
"Remove in-crc-align-errors as it is a duplicate of
in-crc-errors";
reference "2.6.1";
}
revision "2018-08-28" {
description
"Add Ethernet counter in-block-errors";
reference "2.6.0";
}
revision "2018-07-02" {
description
"Add new ethernet counters of in-undersize-frames,
in-crc-align-errors and the distribution container";
reference "2.5.0";
}
revision "2018-04-10" {
description
"Add identities for 2.5 and 5 Gbps.";
reference "2.4.0";
}
revision "2018-01-05" {
description
"Add logical loopback to interface.";
reference "2.3.0";
}
revision "2017-12-21" {
description
"Added IPv6 router advertisement configuration.";
reference "2.1.0";
}
revision "2017-07-14" {
description
"Added Ethernet/IP state data; Add dhcp-client;
migrate to OpenConfig types modules; Removed or
renamed opstate values";
reference "2.0.0";
}
revision "2016-12-22" {
description
"Fixes to Ethernet interfaces model";
reference "1.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity INTERFACE_FEC {
description
"Base type to specify FEC modes that can be configured on the interface.
These are FEC modes defined for applying to logical interfaces and their
underlying electrical channels.";
}
identity FEC_FC {
base INTERFACE_FEC;
description
"Firecode is used for channels with NRZ modulation and speeds less than 100G.
This FEC is designed to comply with the IEEE 802.3, Clause 74.";
}
identity FEC_RS528 {
base INTERFACE_FEC;
description
"RS528 is used for channels with NRZ modulation. This FEC is designed to
comply with IEEE 802.3, Clause 91.";
}
identity FEC_RS544 {
base INTERFACE_FEC;
description
"RS544 is used for channels with PAM4 modulation.";
}
identity FEC_RS544_LOW_LATENCY {
base INTERFACE_FEC;
description
"RS544-low-latency is used for channels with PAM4 modulation for low latency.";
}
identity FEC_RS544_2X_INTERLEAVE {
base INTERFACE_FEC;
description
"RS544-2x-interleave is used for channels with PAM4 modulation.";
}
identity FEC_RS544_2X_INTERLEAVE_CL172 {
base INTERFACE_FEC;
description
"RS544-2x-interleave-cl172 is used for channels with PAM4 modulation with the IEEE 802.3df variant.";
}
identity FEC_RS544_2X_INTERLEAVE_ETC {
base INTERFACE_FEC;
description
"RS544-2x-interleave-etc is used for channels with PAM4 modulation with the ETC variant.";
}
identity FEC_DISABLED {
base INTERFACE_FEC;
description
"FEC is administratively disabled.";
}
identity ETHERNET_SPEED {
description "base type to specify available Ethernet link
speeds";
}
identity SPEED_10MB {
base ETHERNET_SPEED;
description "10 Mbps Ethernet";
}
identity SPEED_100MB {
base ETHERNET_SPEED;
description "100 Mbps Ethernet";
}
identity SPEED_1GB {
base ETHERNET_SPEED;
description "1 Gbps Ethernet";
}
identity SPEED_2500MB {
base ETHERNET_SPEED;
description "2.5 Gbps Ethernet";
}
identity SPEED_5GB {
base ETHERNET_SPEED;
description "5 Gbps Ethernet";
}
identity SPEED_10GB {
base ETHERNET_SPEED;
description "10 Gbps Ethernet";
}
identity SPEED_25GB {
base ETHERNET_SPEED;
description "25 Gbps Ethernet";
}
identity SPEED_40GB {
base ETHERNET_SPEED;
description "40 Gbps Ethernet";
}
identity SPEED_50GB {
base ETHERNET_SPEED;
description "50 Gbps Ethernet";
}
identity SPEED_100GB {
base ETHERNET_SPEED;
description "100 Gbps Ethernet";
}
identity SPEED_200GB {
base ETHERNET_SPEED;
description "200 Gbps Ethernet";
}
identity SPEED_400GB {
base ETHERNET_SPEED;
description "400 Gbps Ethernet";
}
identity SPEED_600GB {
base ETHERNET_SPEED;
description "600 Gbps Ethernet";
}
identity SPEED_800GB {
base ETHERNET_SPEED;
description "800 Gbps Ethernet";
}
identity SPEED_1600GB {
base ETHERNET_SPEED;
description "1600 Gbps Ethernet";
}
identity SPEED_UNKNOWN {
base ETHERNET_SPEED;
description
"Interface speed is unknown. Systems may report
speed UNKNOWN when an interface is down or unpopuplated (e.g.,
pluggable not present).";
}
// typedef statements
// grouping statements
grouping ethernet-interface-config {
description
"Common interface configuration for physical ethernet + logical
aggregate interfaces";
leaf mac-address {
type oc-yang:mac-address;
description
"Assigns a MAC address to the Ethernet interface. If not
specified, the corresponding operational state leaf is
expected to show the system-assigned MAC address.";
}
leaf enable-flow-control {
type boolean;
default false;
description
"Enable or disable flow control for this interface.
Ethernet flow control is a mechanism by which a receiver
may send PAUSE frames to a sender to stop transmission for
a specified time.
This setting should override auto-negotiated flow control
settings. If left unspecified, and auto-negotiate is TRUE,
flow control mode is negotiated with the peer interface.";
reference
"IEEE 802.3x";
}
}
grouping physical-interface-config {
description
"Configuration specific to physical ethernet interfaces. Note
that this grouping is to only apply when the interface `type` is
set to 'ianaift:ethernetCsmacd'. This is not currently restricted
by YANG language statements (must/when) due to uses of this module
within other domains (e.g. wifi).";
leaf auto-negotiate {
type boolean;
default true;
description
"Set to TRUE to request the interface to auto-negotiate
transmission parameters with its peer interface. When
set to FALSE, the transmission parameters are specified
manually.";
reference
"IEEE 802.3-2012 auto-negotiation transmission parameters";
}
leaf standalone-link-training {
type boolean;
default false;
description
"Link training is automatic tuning of the SerDes transmit and
receive parameters to ensure an optimal connection over copper
links. It is normally run as part of the auto negotiation
sequence as specified in IEEE 802.3 Clause 73.
Standalone link training is used when full auto negotiation is
not desired on an Ethernet link but link training is needed.
It is configured by setting the standalone-link-training leaf
to TRUE and augo-negotiate leaf to FALSE.
Note: If auto-negotiate is true, then the value of standalone
link training leaf will be ignored.";
}
leaf duplex-mode {
type enumeration {
enum FULL {
description "Full duplex mode";
}
enum HALF {
description "Half duplex mode";
}
}
description
"When auto-negotiate is TRUE, this optionally sets the
duplex mode that will be advertised to the peer. If
unspecified, the interface should negotiate the duplex mode
directly (typically full-duplex). When auto-negotiate is
FALSE, this sets the duplex mode on the interface directly.";
}
leaf port-speed {
type identityref {
base ETHERNET_SPEED;
}
description
"When auto-negotiate is TRUE, this optionally sets the
port-speed mode that will be advertised to the peer for
negotiation. If unspecified, it is expected that the
interface will select the highest speed available based on
negotiation. When auto-negotiate is set to FALSE, sets the
link speed to a fixed value -- supported values are defined
by ETHERNET_SPEED identities";
}
leaf fec-mode {
type identityref {
base INTERFACE_FEC;
}
description
"The FEC mode applied to the physical channels associated with
the interface.";
}
}
grouping ethernet-interface-state-counters {
description
"Ethernet-specific counters and statistics";
// ingress counters
leaf fec-uncorrectable-blocks {
type oc-yang:counter64;
when "../../../config/fec-mode != 'FEC_DISABLED'" {
description
"Applicable if FEC is enabled.";
}
description
"The number of block/codeword that were uncorrectable by
the FEC;
This is IEEE802.3 clause 119.3.3 (also IEEE802.3df clause
172.3.3 for 800GE) FEC_uncorrected_cw_counter.";
}
leaf fec-corrected-blocks {
type oc-yang:counter64;
when "../../../config/fec-mode != 'FEC_DISABLED'" {
description
"Applicable if FEC is enabled.";
}
description
"The number of words/symbols that were corrected by
the FEC;
Applicable if fec-mode is not NONE.
This is IEEE802.3 clause 119.3.2 (also IEEE802.3df clause
172.3.2 for 800GE) FEC_corrected_cw_counter";
}
leaf in-mac-control-frames {
type oc-yang:counter64;
description
"MAC layer control frames received on the interface";
}
leaf in-mac-pause-frames {
type oc-yang:counter64;
description
"MAC layer PAUSE frames received on the interface";
}
leaf in-oversize-frames {
type oc-yang:counter64;
description
"The total number of frames received that were
longer than 1518 octets (excluding framing bits,
but including FCS octets) and were otherwise
well formed.";
}
leaf in-undersize-frames {
type oc-yang:counter64;
description
"The total number of frames received that were
less than 64 octets long (excluding framing bits,
but including FCS octets) and were otherwise well
formed.";
reference
"RFC 2819: Remote Network Monitoring MIB -
etherStatsUndersizePkts";
}
leaf in-jabber-frames {
type oc-yang:counter64;
description
"Number of jabber frames received on the
interface. Jabber frames are typically defined as oversize
frames which also have a bad CRC. Implementations may use
slightly different definitions of what constitutes a jabber
frame. Often indicative of a NIC hardware problem.";
}
leaf in-fragment-frames {
type oc-yang:counter64;
description
"The total number of frames received that were less than
64 octets in length (excluding framing bits but including
FCS octets) and had either a bad Frame Check Sequence
(FCS) with an integral number of octets (FCS Error) or a
bad FCS with a non-integral number of octets (Alignment
Error).";
}
leaf in-8021q-frames {
type oc-yang:counter64;
description
"Number of 802.1q tagged frames received on the interface";
}
leaf in-crc-errors {
type oc-yang:counter64;
description
"The total number of frames received that
had a length (excluding framing bits, but
including FCS octets) of between 64 and 1518
octets, inclusive, but had either a bad
Frame Check Sequence (FCS) with an integral
number of octets (FCS Error) or a bad FCS with
a non-integral number of octets (Alignment Error)";
reference
"RFC 2819: Remote Network Monitoring MIB -
etherStatsCRCAlignErrors";
}
leaf in-block-errors {
status deprecated;
type oc-yang:counter64;
description
"The number of received errored blocks. Error detection codes
are capable of detecting whether one or more errors have
occurred in a given sequence of bits the block. It is
normally not possible to determine the exact number of errored
bits within the block";
}
leaf in-carrier-errors {
type oc-yang:counter64;
description
"The number of received errored frames due to a carrier issue.
The value refers to MIB counter for
dot3StatsCarrierSenseErrors
oid=1.3.6.1.2.1.10.7.2.1.11";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-interrupted-tx {
type oc-yang:counter64;
description
"The number of received errored frames due to interrupted
transmission issue. The value refers to MIB counter for
dot3StatsDeferredTransmissions
oid=1.3.6.1.2.1.10.7.2.1.7";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-late-collision {
type oc-yang:counter64;
description
"The number of received errored frames due to late collision
issue. The value refers to MIB counter for
dot3StatsLateCollisions
oid=1.3.6.1.2.1.10.7.2.1.8";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-mac-errors-rx {
type oc-yang:counter64;
description
"The number of received errored frames due to MAC errors
received. The value refers to MIB counter for
dot3StatsInternalMacReceiveErrors
oid=1.3.6.1.2.1.10.7.2.1.16";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-single-collision {
type oc-yang:counter64;
description
"The number of received errored frames due to single collision
issue. The value refers to MIB counter for
dot3StatsSingleCollisionFrames
oid=1.3.6.1.2.1.10.7.2.1.4";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-symbol-error {
type oc-yang:counter64;
description
"The number of received errored frames due to symbol error.
The value refers to MIB counter for
in-symbol-error
oid=1.3.6.1.2.1.10.7.2.1.18";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
leaf in-maxsize-exceeded {
type oc-yang:counter64;
description
"The total number frames received that are well-formed but
dropped due to exceeding the maximum frame size on the interface
(e.g., MTU or MRU)";
}
// egress counters
leaf out-mac-control-frames {
type oc-yang:counter64;
description
"MAC layer control frames sent on the interface";
}
leaf out-mac-pause-frames {
type oc-yang:counter64;
description
"MAC layer PAUSE frames sent on the interface";
}
leaf out-8021q-frames {
type oc-yang:counter64;
description
"Number of 802.1q tagged frames sent on the interface";
}
leaf out-mac-errors-tx {
type oc-yang:counter64;
description
"The number of sent errored frames due to MAC errors
transmitted. The value refers to MIB counter for
dot3StatsInternalMacTransmitErrors
oid=1.3.6.1.2.1.10.7.2.1.10";
reference
"RFC 1643 Definitions of Managed
Objects for the Ethernet-like Interface Types.";
}
}
grouping physical-interface-state {
description
"Grouping for operational state specific to physical ethernet
interfaces. Note that this grouping is to only apply when the
interface `type` is set to 'ianaift:ethernetCsmacd'. This is not
currently restricted by YANG language statements (must/when) due
to uses of this module within other domains (e.g. wifi).";
leaf hw-mac-address {
type oc-yang:mac-address;
description
"Represents the 'burned-in', or system-assigned, MAC
address for the Ethernet interface.";
}
leaf negotiated-duplex-mode {
type enumeration {
enum FULL {
description "Full duplex mode";
}
enum HALF {
description "Half duplex mode";
}
}
description
"When auto-negotiate is set to TRUE, and the interface has
completed auto-negotiation with the remote peer, this value
shows the duplex mode that has been negotiated.";
}
leaf negotiated-port-speed {
type identityref {
base ETHERNET_SPEED;
}
description
"When auto-negotiate is set to TRUE, and the interface has
completed auto-negotiation with the remote peer, this value
shows the interface speed that has been negotiated.";
}
}
grouping ethernet-interface-state {
description
"Common state for physical ethernet and aggregate interfaces";
container counters {
description "Ethernet interface counters";
uses ethernet-interface-state-counters;
}
container pre-fec-ber {
description
"Bit error rate before forward error correction -- computed
value with 18 decimal precision. Note that decimal64
supports values as small as i x 10^-18 where i is an
integer. Values smaller than this should be reported as 0
to inidicate error free or near error free performance.
Values include the instantaneous, average, minimum, and
maximum statistics. If avg/min/max statistics are not
supported, the target is expected to just supply the
instant value. Applicable id gec-mode is not NONE.";
uses oc-opt-types:avg-min-max-instant-stats-precision18-ber;
}
container post-fec-ber {
description
"Bit error rate after forward error correction -- computed
value with 18 decimal precision. Note that decimal64
supports values as small as i x 10^-18 where i is an
integer. Values smaller than this should be reported as 0
to inidicate error free or near error free performance.
Values include the instantaneous, average, minimum, and
maximum statistics. If avg/min/max statistics are not
supported, the target is expected to just supply the
instant value. Applicable id gec-mode is not NONE.";
uses oc-opt-types:avg-min-max-instant-stats-precision18-ber;
}
}
// data definition statements
grouping ethernet-top {
description "top-level Ethernet config and state containers";
container ethernet {
description
"Top-level container for ethernet configuration
and state";
container config {
description "Configuration data for ethernet interfaces";
uses ethernet-interface-config;
uses physical-interface-config;
}
container state {
config false;
description "State variables for Ethernet interfaces";
uses ethernet-interface-config;
uses physical-interface-config;
uses physical-interface-state;
uses ethernet-interface-state;
}
}
}
// augment statements
augment "/oc-if:interfaces/oc-if:interface" {
description "Adds addtional Ethernet-specific configuration to
interfaces model";
uses ethernet-top {
when "oc-if:config/oc-if:type = 'ianaift:ethernetCsmacd' or " +
"oc-if:config/oc-if:type = 'ianaift:ieee8023adLag'" {
description
"Additional interface configuration parameters when
the interface type is Ethernet, or the interface is an aggregate
interface.";
}
}
}
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,179 @@
module openconfig-if-ip-ext {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/interfaces/ip-ext";
prefix "oc-ip-ext";
import openconfig-interfaces { prefix oc-if; }
import openconfig-if-ip { prefix oc-ip; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module adds extensions to the base IP configuration and
operational state model to support additional use cases.";
oc-ext:openconfig-version "2.3.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "2.3.1";
}
revision "2018-01-05" {
description
"Add logical loopback to interface.";
reference "2.3.0";
}
revision "2017-12-21" {
description
"Added IPv6 router advertisement configuration.";
reference "2.1.0";
}
revision "2017-07-14" {
description
"Added Ethernet/IP state data; Add dhcp-client;
migrate to OpenConfig types modules; Removed or
renamed opstate values";
reference "2.0.0";
}
revision "2016-12-22" {
description
"Fixes to Ethernet interfaces model";
reference "1.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// grouping statements
grouping ipv6-autoconf-config {
description
"Configuration data for IPv6 address autoconfiguration";
leaf create-global-addresses {
type boolean;
default true;
description
"[adapted from IETF IP model RFC 7277]
If enabled, the host creates global addresses as
described in RFC 4862.";
reference
"RFC 4862: IPv6 Stateless Address Autoconfiguration
Section 5.5";
}
leaf create-temporary-addresses {
type boolean;
default false;
description
"[adapted from IETF IP model RFC 7277]
If enabled, the host creates temporary addresses as
described in RFC 4941.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6";
}
leaf temporary-valid-lifetime {
type uint32;
units "seconds";
default 604800;
description
"[adapted from IETF IP model RFC 7277]
The time period during which the temporary address
is valid.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6
- TEMP_VALID_LIFETIME";
}
leaf temporary-preferred-lifetime {
type uint32;
units "seconds";
default 86400;
description
"[adapted from IETF IP model RFC 7277]
The time period during which the temporary address is
preferred.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6
- TEMP_PREFERRED_LIFETIME";
}
}
grouping ipv6-autoconf-state {
description
"Operational state data for IPv6 address autoconfiguration";
//TODO: placeholder for additional opstate for IPv6 autoconf
}
grouping ipv6-autoconf-top {
description
"Top-level grouping for IPv6 address autoconfiguration";
container autoconf {
description
"Top-level container for IPv6 autoconf";
container config {
description
"[adapted from IETF IP model RFC 7277]
Parameters to control the autoconfiguration of IPv6
addresses, as described in RFC 4862.";
reference
"RFC 4862: IPv6 Stateless Address Autoconfiguration";
uses ipv6-autoconf-config;
}
container state {
config false;
description
"Operational state data ";
uses ipv6-autoconf-config;
uses ipv6-autoconf-state;
}
}
}
// data definition statements
// augment statements
augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" +
"oc-if:subinterface/oc-ip:ipv6" {
description
"Adds address autoconfiguration to the base IP model";
uses ipv6-autoconf-top;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,549 @@
module openconfig-lacp {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/lacp";
prefix "oc-lacp";
// import some basic types
import openconfig-interfaces { prefix oc-if; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-types { prefix oc-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module describes configuration and operational state
data for Link Aggregation Control Protocol (LACP) for
managing aggregate interfaces. It works in conjunction with
the OpenConfig interfaces and aggregate interfaces models.";
oc-ext:openconfig-version "2.2.0";
revision "2026-04-09" {
description
"Add LACP fallback timeout leaf.";
reference "2.2.0";
}
revision "2024-09-24" {
description
"Add LACP fallback leaf under both config and state.";
reference "2.1.0";
}
revision "2023-12-11" {
description
"Add config container for aggregation member and port-priority leaf under
both config and state";
reference "2.0.0";
}
revision "2021-07-20" {
description
"Add count of number of timeouts and time of the last timeout.";
reference "1.2.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "1.1.1";
}
revision "2017-05-05" {
description
"Add member local and remote port num";
reference "1.1.0";
}
revision "2016-05-26" {
description
"OpenConfig public release";
reference "1.0.2";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// typedef statements
typedef lacp-activity-type {
type enumeration {
enum ACTIVE {
description
"Interface is an active member, i.e., will detect and
maintain aggregates";
}
enum PASSIVE {
description
"Interface is a passive member, i.e., it participates
with an active partner";
}
}
description
"Describes the LACP membership type, active or passive, of the
interface in the aggregate";
reference "IEEE 802.1AX-2008";
}
typedef lacp-timeout-type {
type enumeration {
enum LONG {
description
"Participant wishes to use long timeouts to detect
status of the aggregate, i.e., will expect less frequent
transmissions. Long timeout is 90 seconds.";
}
enum SHORT {
description
"Participant wishes to use short timeouts, i.e., expects
frequent transmissions to aggressively detect status
changes. Short timeout is 3 seconds.";
}
}
description
"Type of timeout used, short or long, by LACP participants";
reference "IEEE 802.1AX-2008";
}
typedef lacp-synchronization-type {
type enumeration {
enum IN_SYNC {
description
"Participant is in sync with the system id and key
transmitted";
}
enum OUT_SYNC {
description
"Participant is not in sync with the system id and key
transmitted";
}
}
description
"Indicates LACP synchronization state of participant";
reference "IEEE 802.1AX-2008";
}
typedef lacp-period-type {
type enumeration {
enum FAST {
description "Send LACP packets every second";
}
enum SLOW {
description "Send LACP packets every 30 seconds";
}
}
description
"Defines the period options for the time between sending
LACP messages";
reference "IEEE 802.3ad";
}
// grouping statements
grouping aggregation-lacp-members-config {
description
"Configuration data for lacp member interfaces";
leaf interface {
type oc-if:base-interface-ref;
description
"Reference to interface member of the LACP aggregate";
}
leaf port-priority {
type uint16;
description
"Member interface's priority in its aggregate interface.";
}
}
grouping aggregation-lacp-members-state {
description
"Operational status data for the member interfaces";
leaf activity {
type lacp-activity-type;
description "Indicates participant is active or passive";
}
leaf timeout {
type lacp-timeout-type;
description
"The timeout type (short or long) used by the
participant";
}
leaf synchronization {
type lacp-synchronization-type;
description
"Indicates whether the participant is in-sync or
out-of-sync";
}
leaf aggregatable {
type boolean;
description
"A true value indicates that the participant will allow
the link to be used as part of the aggregate. A false
value indicates the link should be used as an individual
link";
}
leaf collecting {
type boolean;
description
"If true, the participant is collecting incoming frames
on the link, otherwise false";
}
leaf distributing {
type boolean;
description
"When true, the participant is distributing outgoing
frames; when false, distribution is disabled";
}
leaf system-id {
type oc-yang:mac-address;
description
"MAC address that defines the local system ID for the
aggregate interface";
}
leaf oper-key {
type uint16;
description
"Current operational value of the key for the aggregate
interface";
}
leaf partner-id {
type oc-yang:mac-address;
description
"MAC address representing the protocol partner's interface
system ID";
}
leaf partner-key {
type uint16;
description
"Operational value of the protocol partner's key";
}
leaf port-num {
type uint16;
description
"Port number of the local (actor) aggregation member";
}
leaf partner-port-num {
type uint16;
description
"Port number of the partner (remote) port for this member
port";
}
leaf partner-port-priority {
type uint16;
description
"Member interface partner's priority in its aggregate interface.";
}
leaf last-change {
type oc-types:timeticks64;
description
"The timestamp indicates the absolute time of the last state
change of a LACP timeout. The last state change of the LACP
timeout is defined as what is reported as the operating state
to the system. The state change is both a timeout event and
when the timeout event is no longer active. The value is the
timestamp in nanoseconds relative to the Unix Epoch
(Jan 1, 1970 00:00:00 UTC).";
}
}
grouping aggregation-lacp-members-statistics {
description
"LACP packet statistics for the member interfaces";
container counters {
description
"LACP protocol counters";
leaf lacp-in-pkts {
type oc-yang:counter64;
description
"Number of LACPDUs received";
}
leaf lacp-out-pkts {
type oc-yang:counter64;
description
"Number of LACPDUs transmitted";
}
leaf lacp-rx-errors {
type oc-yang:counter64;
description
"Number of LACPDU receive packet errors";
}
leaf lacp-tx-errors {
type oc-yang:counter64;
description
"Number of LACPDU transmit packet errors";
}
leaf lacp-unknown-errors {
type oc-yang:counter64;
description
"Number of LACPDU unknown packet errors";
}
leaf lacp-errors {
type oc-yang:counter64;
description
"Number of LACPDU illegal packet errors";
}
leaf lacp-timeout-transitions {
type oc-yang:counter64;
description
"Number of times the LACP state has transitioned
with a timeout since the time the device restarted
or the interface was brought up, whichever is most
recent. The last state change of the LACP timeout
is defined as what is reported as the operating state
to the system. The state change is both a timeout
event and when the timeout event is no longer active.";
}
}
}
grouping aggregation-lacp-members-top {
description
"Top-level grouping for aggregate members list";
container members {
description
"Configuration and operational state of the aggregate member
interfaces";
list member {
key "interface";
description
"List of member interfaces and their associated status for
a LACP-controlled aggregate interface";
leaf interface {
type leafref {
path "../config/interface";
}
description
"Reference to aggregate member interface";
}
container config {
description
"Operational state data for aggregate members";
uses aggregation-lacp-members-config;
}
container state {
config false;
description
"Operational state data for aggregate members";
uses aggregation-lacp-members-config;
uses aggregation-lacp-members-state;
uses aggregation-lacp-members-statistics;
}
}
}
}
grouping lacp-interfaces-config {
description
"Configuration data for each LACP-enabled interface";
leaf name {
type oc-if:base-interface-ref;
description
"Reference to the interface on which LACP should be
configured. The type of the target interface must be
ieee8023adLag";
}
leaf interval {
type lacp-period-type;
default SLOW;
description
"Set the period between LACP messages -- uses
the lacp-period-type enumeration.";
}
leaf lacp-mode {
type lacp-activity-type;
default ACTIVE;
description
"ACTIVE is to initiate the transmission of LACP packets.
PASSIVE is to wait for peer to initiate the transmission of
LACP packets.";
//TODO:some implementations configure the LACP mode on each
//member interface rather than on the LAG interface. There
//may be use cases for this identified at a later time.
}
leaf system-id-mac {
type oc-yang:mac-address;
description
"The MAC address portion of the node's System ID. This is
combined with the system priority to construct the 8-octet
system-id";
}
leaf fallback {
type boolean;
description
"If the fallback is set to true, current LACP interface is
able to establish a Link Aggregation (LAG) before it receives
LACP PDUs from its peer, and fallback to a single port active
after the expiry of the timeout period.";
}
leaf fallback-timeout {
type uint16;
units "seconds";
description
"The timeout in seconds to wait for LACP PDUs before falling back to a single port.";
}
uses aggregation-lacp-global-config;
}
grouping lacp-interfaces-state {
description
"Operational state data for each LACP-enabled interface";
}
grouping lacp-interfaces-top {
description
"Top-level grouping for LACP-enabled interfaces";
container interfaces {
description
"Enclosing container for the list of LACP-enabled
interfaces";
list interface {
key "name";
description
"List of aggregate interfaces managed by LACP";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for each LACP aggregate interface";
uses lacp-interfaces-config;
}
container state {
config false;
description
"Operational state data for each LACP aggregate
interface";
uses lacp-interfaces-config;
uses lacp-interfaces-state;
}
uses aggregation-lacp-members-top;
}
}
}
grouping aggregation-lacp-global-config {
description
"Configuration data for LACP aggregate interfaces";
leaf system-priority {
type uint16;
description
"Sytem priority used by the node on this LAG interface.
Lower value is higher priority for determining which node
is the controlling system.";
}
}
grouping aggregation-lacp-global-state {
description
"Operational data for LACP aggregate interfaces";
}
grouping aggregation-lacp-top {
description
"Top level configuration and state variable containers for
LACP data";
container lacp {
description
"Configuration and operational state data for LACP protocol
operation on the aggregate interface";
container config {
description
"Configuration data for LACP";
uses aggregation-lacp-global-config;
}
container state {
config false;
description
"Operational state data for LACP";
uses aggregation-lacp-global-config;
uses aggregation-lacp-global-state;
}
uses lacp-interfaces-top;
}
}
// data definition statements
uses aggregation-lacp-top;
// augment statements
}

View File

@@ -0,0 +1,340 @@
module openconfig-lldp-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/lldp/types";
prefix "oc-lldp-types";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines types related to the LLDP protocol model.";
oc-ext:openconfig-version "0.2.0";
revision "2025-12-09" {
description
"Add Management interface numbering subtype typedef.";
reference "0.2.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2016-05-16" {
description
"Initial public revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity LLDP_SYSTEM_CAPABILITY {
description
"Base identity for standard LLDP system capabilities.
The system capabilities field contains a bit-map of the
capabilities that define the primary function(s) of
the system. A system may advertise more than one capability.";
reference
"Table 8-4 System Capabilities, IEEE 802.1AB-2009";
}
identity OTHER {
base LLDP_SYSTEM_CAPABILITY;
description
"Other capability not specified; bit position 1";
}
identity REPEATER {
base LLDP_SYSTEM_CAPABILITY;
description
"Repeater capability; bit position 2";
reference
"IETF RFC 2108";
}
identity MAC_BRIDGE {
base LLDP_SYSTEM_CAPABILITY;
description
"MAC bridge capability; bit position 3";
reference
"IEEE Std 802.1D";
}
identity WLAN_ACCESS_POINT {
base LLDP_SYSTEM_CAPABILITY;
description
"WLAN access point capability; bit position 4";
reference
"IEEE Std 802.11 MIB";
}
identity ROUTER {
base LLDP_SYSTEM_CAPABILITY;
description
"Router; bit position 5";
reference
"IETF RFC 1812";
}
identity TELEPHONE {
base LLDP_SYSTEM_CAPABILITY;
description
"Telephone capability; bit position 6";
reference
"IETF RFC 4293";
}
identity DOCSIS_CABLE_DEVICE {
base LLDP_SYSTEM_CAPABILITY;
description
"DOCSIS cable device; bit position 7";
reference
"IETF RFC 4639 and IETF RFC 4546";
}
identity STATION_ONLY {
base LLDP_SYSTEM_CAPABILITY;
description
"Station only capability, for devices that implement only an
end station capability, and for which none of the other
capabilities apply; bit position 8";
reference
"IETF RFC 4293";
}
identity C_VLAN {
base LLDP_SYSTEM_CAPABILITY;
description
"C-VLAN component of a VLAN Bridge; bit position 9";
reference
"IEEE Std 802.1Q";
}
identity S_VLAN {
base LLDP_SYSTEM_CAPABILITY;
description
"S-VLAN component of a VLAN Bridge; bit position 10";
reference
"IEEE Std 802.1Q";
}
identity TWO_PORT_MAC_RELAY {
base LLDP_SYSTEM_CAPABILITY;
description
"Two-port MAC Relay (TPMR) capability; bit position 11";
reference
"IEEE Std 802.1Q";
}
identity LLDP_TLV {
description
"A base identity which describes the TLVs in LLDP";
}
identity CHASSIS_ID {
base LLDP_TLV;
description
"The chassis identifier of the device associated with
the transmitting LLDP agent";
reference "IEEE Std 802.1AB";
}
identity PORT_ID {
base LLDP_TLV;
description
"The port identifier associated with the interface
on with the LLDP agent is transmitting";
reference "IEEE Std 802.1AB";
}
identity PORT_DESCRIPTION {
base LLDP_TLV;
description
"The description of the port that is associated with
the interface on which the LLDP agent is transmitting";
reference "IEEE Std 802.1AB";
}
identity SYSTEM_NAME {
base LLDP_TLV;
description
"The assigned name (sysName or hostname) of the device
which is transmitting the LLDP PDU";
reference "IEEE Std 802.1AB";
}
identity SYSTEM_DESCRIPTION {
base LLDP_TLV;
description
"The description (sysDescr) of the device which is
transmitting the LLDP PDU";
reference "IEEE Std 802.1AB";
}
identity SYSTEM_CAPABILITIES {
base LLDP_TLV;
description
"The primary functions of the device transmitting the
LLDP PDU and their administrative status";
reference "IEEE Std 802.1AB";
}
identity MANAGEMENT_ADDRESS {
base LLDP_TLV;
description
"The address associated with the device transmitting the
LLDP PDU which can be used for higher-layer network
management";
reference "IEEE Std 802.1AB";
}
// typedef statements
typedef chassis-id-type {
type enumeration {
enum CHASSIS_COMPONENT {
description
"Chassis identifier based on the value of entPhysicalAlias
object defined in IETF RFC 2737";
}
enum INTERFACE_ALIAS {
description
"Chassis identifier based on the value of ifAlias object
defined in IETF RFC 2863";
}
enum PORT_COMPONENT {
description
"Chassis identifier based on the value of entPhysicalAlias
object defined in IETF RFC 2737 for a port or backplane
component";
}
enum MAC_ADDRESS {
description
"Chassis identifier based on the value of a unicast source
address (encoded in network byte order and IEEE 802.3
canonical bit order), of a port on the containing chassis
as defined in IEEE Std 802-2001";
}
enum NETWORK_ADDRESS {
description
"Chassis identifier based on a network address,
associated with a particular chassis. The encoded address
is composed of two fields. The first field is a single
octet, representing the IANA AddressFamilyNumbers value
for the specific address type, and the second field is the
network address value";
}
enum INTERFACE_NAME {
description
"Chassis identifier based on the name of the interface,
e.g., the value of ifName object defined in IETF RFC 2863";
}
enum LOCAL {
description
"Chassis identifier based on a locally defined value";
}
}
description
"Type definition with enumerations describing the source of
the chassis identifier";
reference
"IEEE 802.1AB LLDP MIB";
}
typedef port-id-type {
type enumeration {
enum INTERFACE_ALIAS {
description
"Chassis identifier based on the value of ifAlias object
defined in IETF RFC 2863";
}
enum PORT_COMPONENT {
description
"Port identifier based on the value of entPhysicalAlias
object defined in IETF RFC 2737 for a port component";
}
enum MAC_ADDRESS {
description
"Port identifier based on the value of a unicast source
address (encoded in network byte order and IEEE 802.3
canonical bit order) associated with a port";
}
enum NETWORK_ADDRESS {
description
"Port identifier based on a network address,
associated with a particular port";
}
enum INTERFACE_NAME {
description
"Port identifier based on the name of the interface,
e.g., the value of ifName object defined in IETF RFC 2863";
}
enum AGENT_CIRCUIT_ID {
description
"Port identifer based on the circuit id in the DHCP
relay agent information option as defined in IETF
RFC 3046";
}
enum LOCAL {
description
"Port identifier based on a locally defined alphanumeric
string";
}
}
description
"Type definition with enumerations describing the basis of
the port identifier";
reference
"IEEE 802.1AB LLDP MIB";
}
typedef mgmt-interface-number-subtype {
type enumeration {
enum UNKNOWN {
value 1;
description
"Represents the case where the interface is not known. In this
case, the corresponding interface number is of zero length.";
}
enum IFINDEX {
value 2;
description
"Represents interface identifier based on the ifIndex MIB
object.";
}
enum SYSTEM_PORT_NUMBER {
value 3;
description
"Represents interface identifier based on the system port
numbering convention.";
}
}
description
"The Management address interface numbering subtype field
indicating the numbering method used for defining the interface
number.";
reference
"Sec 8.5.9.5 of IEEE Std 802.1AB-2016";
}
}

View File

@@ -0,0 +1,878 @@
module openconfig-lldp {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/lldp";
prefix "oc-lldp";
import openconfig-lldp-types { prefix oc-lldp-types; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-inet-types { prefix oc-inet; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-types { prefix oc-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
for the LLDP protocol.";
oc-ext:openconfig-version "1.1.0";
revision "2026-04-06" {
description
"Add global TTL configuration/state leaf, interface port-description and custom-tlv-names leaves, custom TLV name leaf, global custom-tlvs list, and add interface counter timestamps for LLDP.";
reference "1.1.0";
}
revision "2026-01-14" {
description
"Refactor LLDP management addresses to accomodate 802.1AB defined
TLV. Add configurable management interface. Switch from IETF to
OC YANG types. Deprecate management-address-type and
management-address leafs. Cleanup unused/empty groupings.";
reference "1.0.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2018-07-17" {
description
"Adds ttl to lldp-neighbor-state";
reference "0.2.0";
}
revision "2016-05-16" {
description
"Initial public revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// grouping statements
grouping lldp-common-counters {
description
"Definition of global and per-interface counters";
leaf frame-in {
type oc-yang:counter64;
description
"The number of lldp frames received.";
}
leaf frame-out {
type oc-yang:counter64;
description
"The number of frames transmitted out.";
}
leaf frame-error-in {
type oc-yang:counter64;
description
"The number of LLDP frames received with errors.";
}
leaf frame-discard {
type oc-yang:counter64;
description
"The number of LLDP frames received and discarded.";
}
leaf tlv-discard {
type oc-yang:counter64;
description
"The number of TLV frames received and discarded.";
}
leaf tlv-unknown {
type oc-yang:counter64;
description
"The number of frames received with unknown TLV.";
}
leaf last-clear {
type oc-yang:date-and-time;
description
"Indicates the last time the counters were
cleared.";
}
}
grouping lldp-global-counters {
description
"Definition of global LLDP counters";
uses lldp-common-counters;
leaf tlv-accepted {
type oc-yang:counter64;
description
"The number of valid TLVs received.";
}
leaf entries-aged-out {
type oc-yang:counter64;
description
"The number of entries aged out due to timeout.";
}
}
grouping lldp-interface-counters {
description
"Definition of per-interface LLDP counters";
uses lldp-common-counters;
leaf frame-error-out {
type oc-yang:counter64;
description
"The number of frame transmit errors on the
interface.";
}
}
grouping lldp-interface-packet-timestamps {
description
"Definition of per-interface LLDP packet timestamps";
leaf last-packet-transmitted {
type oc-types:timeticks64;
description
"Timestamp of the last LLDP packet transmitted on this interface.";
}
leaf last-good-packet-received {
type oc-types:timeticks64;
description
"Timestamp of the last valid LLDP packet received on this interface.";
}
}
grouping lldp-system-info-config {
description
"Configuration data for system-level local and remote
LLDP information";
leaf system-name {
type string {
length 0..255;
}
description
"The system name field shall contain an alpha-numeric string
that indicates the system's administratively assigned name.
The system name should be the system's fully qualified domain
name. If implementations support IETF RFC 3418, the sysName
object should be used for this field.";
}
leaf system-description {
type string {
length 0..255;
}
description
"The system description field shall contain an alpha-numeric
string that is the textual description of the network entity.
The system description should include the full name and
version identification of the system's hardware type,
software operating system, and networking software. If
implementations support IETF RFC 3418, the sysDescr object
should be used for this field.";
}
leaf chassis-id {
type string;
description
"The Chassis ID is a mandatory TLV which identifies the
chassis component of the endpoint identifier associated with
the transmitting LLDP agent";
}
leaf chassis-id-type {
type oc-lldp-types:chassis-id-type;
description
"This field identifies the format and source of the chassis
identifier string. It is an enumerator defined by the
LldpChassisIdSubtype object from IEEE 802.1AB MIB.";
}
leaf management-interface {
type oc-if:interface-id;
description
"The interface in which to derive the population of Management
Address TLV parameters. If unspecified, the implementation may
choose which interface is utilized.";
}
}
grouping lldp-management-addresses {
description
"Operational state data to represent local or remote Management
Address TLV parameters.";
container mgmt-addresses {
config false;
description
"Encapsulating container for management addresses";
list mgmt-address {
description
"List of management addresses in use by the local/remote
system";
key "address";
leaf address {
type leafref {
path "../state/address";
}
description
"Reference to the management address key";
}
container state {
description
"Operational state data for management addresses";
uses lldp-management-address-state;
}
}
}
}
grouping lldp-management-address-state {
description
"Local or remote management address state data.";
leaf address {
type union {
type oc-inet:ip-address;
type oc-yang:mac-address;
}
description
"Management address associated with the Management Address
TLV.";
reference
"Sec 8.5.9.4 of IEEE Std 802.1AB-2016";
}
leaf interface-number {
type uint32;
description
"Interface number that identifies the specific interface
associated with this management address.";
reference
"Sec 8.5.9.6 of IEEE Std 802.1AB-2016";
}
leaf interface-number-subtype {
type oc-lldp-types:mgmt-interface-number-subtype;
description
"The Management address interface numbering subtype field
indicating the numbering method used for defining the
interface-number.";
reference
"Sec 8.5.9.5 of IEEE Std 802.1AB-2016";
}
}
grouping lldp-neighbor-state {
description
"Operational state data for LLDP neighbors";
leaf id {
type string;
description
"System generated identifier for the neighbor on the
interface.";
}
leaf age {
type uint64;
units "seconds";
description
"Age since discovery";
}
leaf last-update {
type int64;
description
"Seconds since last update received.";
}
leaf ttl {
type uint16;
units "seconds";
description
"The time-to-live (TTL) is a mandatory TLV which indicates
how long information from the neighbor should be considered
valid.";
}
leaf port-id {
type string;
description
"The Port ID is a mandatory TLV which identifies the port
component of the endpoint identifier associated with the
transmitting LLDP agent. If the specified port is an IEEE
802.3 Repeater port, then this TLV is optional.";
}
leaf port-id-type {
type oc-lldp-types:port-id-type;
description
"This field identifies the format and source of the port
identifier string. It is an enumerator defined by the
PtopoPortIdType object from RFC2922.";
}
leaf port-description {
type string;
description
"The binary string containing the actual port identifier for
the port which this LLDP PDU was transmitted. The source and
format of this field is defined by PtopoPortId from
RFC2922.";
}
leaf management-address {
type string;
status deprecated;
description
"The Management Address is a mandatory TLV which identifies a
network address associated with the local LLDP agent, which
can be used to reach the agent on the port identified in the
Port ID TLV.
This leaf has been deprecated in favor of the management-address
list structure to accomodate multiple addresses and distinct
typing to pair up with the 802.1AB Management Address TLV
specification.";
}
leaf management-address-type {
type string;
status deprecated;
description
"The enumerated value for the network address type
identified in this TLV. This enumeration is defined in the
'Assigned Numbers' RFC [RFC3232] and the
ianaAddressFamilyNumbers object.
This leaf has been deprecated in favor of the management-address
list structure to accomodate multiple addresses and distinct
typing to pair up with the 802.1AB Management Address TLV
specification.";
}
}
grouping lldp-capabilities-config {
description
"Configuration data for LLDP capabilities";
}
grouping lldp-capabilities-state {
description
"Operational state data for LLDP capabilities";
leaf name {
type identityref {
base oc-lldp-types:LLDP_SYSTEM_CAPABILITY;
}
description
"Name of the system capability advertised by the neighbor.
Capabilities are represented in a bitmap that defines the
primary functions of the system. The capabilities are
defined in IEEE 802.1AB.";
}
leaf enabled {
type boolean;
description
"Indicates whether the corresponding system capability is
enabled on the neighbor.";
reference
"Sec 8.5.8.2 of IEEE 802.1AB-2009";
}
}
grouping lldp-capabilities-top {
description
"Top-level grouping for LLDP capabilities";
container capabilities {
config false;
description
"Enclosing container for list of LLDP capabilities";
list capability {
key "name";
description
"List of LLDP system capabilities advertised by the
neighbor";
leaf name {
type leafref {
path "../state/name";
}
description
"Reference to capabilities list key";
}
container config {
description
"Configuration data for LLDP capabilities";
uses lldp-capabilities-config;
}
container state {
config false;
description
"Operational state data for LLDP capabilities";
uses lldp-capabilities-config;
uses lldp-capabilities-state;
}
}
}
}
grouping lldp-custom-tlv-config {
description
"Configuration data for custom LLDP TLVs";
uses lldp-custom-tlv-common;
}
grouping lldp-custom-tlv-common {
description
"Common data for custom LLDP TLVs";
leaf name {
type string;
description
"Administrative name of the custom TLV for human identification
and reference purposes, allowing operators to define a template
once at the global level and then reference it by name elsewhere
rather than by their numeric type, OUI, and subtype values.";
}
leaf type {
type int32;
description
"The integer value identifying the type of information
contained in the value field.";
}
leaf oui {
type string;
description
"The organizationally unique identifier field shall contain
the organization's OUI as defined in Clause 9 of IEEE Std
802. The high-order octet is 0 and the low-order 3 octets
are the SMI Network Management Private Enterprise Code of
the Vendor in network byte order, as defined in the
'Assigned Numbers' RFC [RFC3232].";
}
leaf oui-subtype {
type string;
description
"The organizationally defined subtype field shall contain a
unique subtype value assigned by the defining organization.";
}
// TODO: consider making this string type
leaf value {
type binary;
description
"A variable-length octet-string containing the
instance-specific information for this TLV.";
}
}
grouping lldp-custom-tlv-state {
description
"Operational state data for custom LLDP TLVs";
uses lldp-custom-tlv-common;
}
grouping lldp-custom-tlv-top {
description
"Top-level grouping for custom LLDP TLVs";
container custom-tlvs {
config false;
description
"Enclosing container for list of custom TLVs from a
neighbor";
list tlv {
key "type oui oui-subtype";
description
"List of custom LLDP TLVs from a neighbor";
leaf type {
type leafref {
path "../state/type";
}
description
"Reference to type list key";
}
leaf oui {
type leafref {
path "../state/oui";
}
description
"Reference to oui list key";
}
leaf oui-subtype {
type leafref {
path "../state/oui-subtype";
}
description
"Reference to oui-subtype list key";
}
container config {
description
"Configuration data for custom LLDP TLVs";
}
container state {
config false;
description
"Operational state data ";
uses lldp-custom-tlv-state;
}
}
}
}
grouping lldp-neighbor-top {
description
"Top-level grouping for the LLDP neighbor list";
container neighbors {
config false;
description
"Enclosing container for list of LLDP neighbors on an
interface";
list neighbor {
key "id";
description
"List of LLDP neighbors";
leaf id {
type leafref {
path "../state/id";
}
description
" ";
}
container config {
description
"Configuration data ";
}
container state {
config false;
description
"Operational state data ";
uses lldp-system-info-config;
uses lldp-neighbor-state;
}
uses lldp-management-addresses;
uses lldp-custom-tlv-top;
uses lldp-capabilities-top;
}
}
}
grouping lldp-interface-config {
description
"Configuration data for LLDP on each interface";
leaf name {
type oc-if:base-interface-ref;
description
"Reference to the LLDP Ethernet interface";
}
leaf enabled {
type boolean;
default "true";
description
"Enable or disable the LLDP protocol on the interface.";
}
leaf port-description {
type string;
description
"The binary string advertised in the 'Port Description' TLV
(Type 3) of LLDP.
When this leaf is populated, its value must be used as the
advertised port description, overriding any system-generated
strings or the generic interface description found in
/interfaces/interface/config/description.
If this leaf is not populated, the implementation
should default to advertising the value of
/interfaces/interface/state/description.";
reference
"Sec 8.5.4 of IEEE Std 802.1AB-2016";
}
leaf-list custom-tlv-names {
type leafref {
path "../../../../custom-tlvs/tlv/name";
}
description
"References to global custom TLV names to be advertised on this
interface. If a custom TLV name is present in this list, the
corresponding custom TLV will be advertised in LLDP PDUs transmitted
on this interface. If a custom TLV name is not present in this list,
it will not be advertised on this interface.";
}
}
grouping lldp-interface-state {
description
"Operational state data for LLDP on each interface";
container counters {
description
"LLDP counters on each interface";
uses lldp-interface-counters;
}
uses lldp-interface-packet-timestamps;
}
grouping lldp-interface-top {
description
"Top-level grouping ";
container interfaces {
description
"Enclosing container ";
list interface {
key "name";
description
"List of interfaces on which LLDP is enabled / available";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for LLDP on each interface";
uses lldp-interface-config;
}
container state {
config false;
description
"Operational state data ";
uses lldp-interface-config;
uses lldp-interface-state;
}
uses lldp-neighbor-top;
}
}
}
grouping lldp-config {
description
"Configuration data for global LLDP parameters";
leaf enabled {
type boolean;
default "true";
description
"System level state of the LLDP protocol.";
}
leaf hello-timer {
type uint64;
units "seconds";
description
"System level hello timer for the LLDP protocol.";
}
leaf ttl {
type uint16;
units "seconds";
description
"Time-to-live value for LLDP PDUs transmitted by this system.
This value is carried in the TTL TLV and indicates the time
interval for which information contained in the LLDP PDU is
valid at the receiving system.
Note: The TTL value is independent from the hello-timer interval.
The hello-timer controls how frequently LLDP PDUs are transmitted,
while the TTL value indicates the validity duration of information
contained in those PDUs at the receiving system.";
reference
"Sec 8.5.3 of IEEE Std 802.1AB-2016";
}
leaf-list suppress-tlv-advertisement {
type identityref {
base oc-lldp-types:LLDP_TLV;
}
description
"Indicates whether the local system should suppress the
advertisement of particular TLVs with the LLDP PDUs that it
transmits. Where a TLV type is specified within this list, it
should not be included in any LLDP PDU transmitted by the
local agent.";
}
}
grouping lldp-state {
description
"Operational state data for global LLDP parameters";
container counters {
description
"Global LLDP counters";
uses lldp-global-counters;
}
}
grouping lldp-global-custom-tlv-top {
description
"Top-level grouping for global custom LLDP TLVs";
container custom-tlvs {
description
"Enclosing container for list of global custom TLVs.
Implementation Note: Custom TLV OUI/subtype combinations
MUST NOT collide with standard LLDP TLVs. Configuration
of conflicting OUI/subtype values is not permitted.";
list tlv {
key "name";
description
"List of global custom LLDP TLVs";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for global custom TLVs";
uses lldp-custom-tlv-common;
}
container state {
config false;
description
"Operational state data for global custom TLVs";
uses lldp-custom-tlv-common;
}
}
}
}
grouping lldp-top {
description
"Top-level grouping for LLDP model";
container lldp {
description
"Top-level container for LLDP configuration and state data";
container config {
description
"Configuration data ";
uses lldp-config;
uses lldp-system-info-config;
}
container state {
config false;
description
"Operational state data ";
uses lldp-config;
uses lldp-system-info-config;
uses lldp-state;
}
uses lldp-management-addresses;
uses lldp-interface-top;
uses lldp-global-custom-tlv-top;
}
}
// data definition statements
uses lldp-top;
}

View File

@@ -0,0 +1,172 @@
module openconfig-local-routing-network-instance {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/local-routing-netinst";
prefix "oc-loc-rt-netinst";
import openconfig-network-instance { prefix "oc-ni"; }
import openconfig-extensions { prefix "oc-ext"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module adds leaves that relate to network-instances
to the local routing subtree.";
oc-ext:openconfig-version "1.1.0";
revision "2025-07-01" {
description
"Add reference to static next-hop-group and augment the local routing
module.";
reference "1.1.0";
}
revision "2025-06-30" {
description
"Add leaves that relate to network-instances to the
local routing module.";
reference "1.0.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
grouping static-nexthop-networkinstance {
description
"This grouping define leaves that need references to the network-instance
subtree within the local routing module. It is used to augment the
/network-instances/network-instance/protocols/protocol/static-routes/ +
static-route/next-hops/next-hop/{config,state} containers.";
leaf next-network-instance {
description
"Instead of finding the next-hop for a destination address in the current
network-instance, look up the destination address in the routing table
of the specified network-instance.
For example, let 'next-network-instance' = 'DEFAULT'. If a packet arrives
in the 'BLUE' network-instance and the destination address matches this
route, the destination address will be looked up again in the 'DEFAULT'
network-instance to find the next-hop.
This leaf is mutually exclusive with 'next-hop', 'nh-network-instance'
leaves";
type leafref {
path "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:config/oc-ni:name";
}
}
leaf nh-network-instance {
description
"Network-instance in which IP address of next-hop should
be looked up, to find egress interface. This attribute
is only valid if next-hop is given as IP address.
This attribute may be combined with recurse attribute of any
value, in which case recurse setting applies to
nh-network-instance.
For example, let 'nh-network-instance' = 'DEFAULT'. If a
packet arrives on the 'BLUE' network-instance and the
destination address matches this route, look up the IP
configured as next-hop in the 'DEFAULT' network-instance.
This leaf is mutually exclusive with next-network-instance
leaf";
type leafref {
path "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:config/oc-ni:name";
}
}
}
grouping static-next-hop-group-networkinstance {
description
"Grouping of nodes for a reference to a static next-hop-group.";
container next-hop-group {
description
"Configuration and state parameters relating to the
next-hop-group. In the future, this container will replace the container
/network-instances/network-instance/protocols/protocol/static-routes/static/next-hops.
If a statically configured next-hop-group is used for a static route
prefix then the 'static-routes/static/next-hops' container must not
be used.";
container config {
description
"Configuration parameters relating to the next-hop-group.";
uses next-hop-group-config;
}
container state {
config false;
description
"Operational parameters relating to the next-hop-group.";
uses next-hop-group-config;
}
}
}
grouping next-hop-group-config {
description
"Grouping of configuration parameters for a reference to a
static next-hop-group.";
leaf name {
description
"A user defined name to reference a static next-hop-group.";
// we are at /network-instances/network-instance/protocols/protocol/static-routes/static/next-hop-group/config/name
type leafref {
path "../../../../../../../oc-ni:static/oc-ni:next-hop-groups/oc-ni:next-hop-group/oc-ni:config/oc-ni:name";
}
}
}
augment "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:protocols/oc-ni:protocol/oc-ni:static-routes/oc-ni:static" {
description
"Add network-instance leaves to static routing next-hop container.";
uses static-next-hop-group-networkinstance;
}
augment "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:protocols/oc-ni:protocol/oc-ni:static-routes/oc-ni:static/oc-ni:next-hops/oc-ni:next-hop/oc-ni:config" {
description
"Add network-instance leaves to static routing next-hop container.";
uses static-nexthop-networkinstance;
}
augment "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:protocols/oc-ni:protocol/oc-ni:static-routes/oc-ni:static/oc-ni:next-hops/oc-ni:next-hop/oc-ni:state" {
description
"Add network-instance leaves to static routing next-hop container.";
uses static-nexthop-networkinstance;
}
augment "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:static/oc-ni:next-hops/oc-ni:next-hop/oc-ni:config" {
description
"Add network-instance leaves to static next-hop container.";
uses static-nexthop-networkinstance;
}
augment "/oc-ni:network-instances/oc-ni:network-instance/oc-ni:static/oc-ni:next-hops/oc-ni:next-hop/oc-ni:state" {
description
"Add network-instance leaves to static next-hop container.";
uses static-nexthop-networkinstance;
}
}

View File

@@ -0,0 +1,516 @@
module openconfig-local-routing {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/local-routing";
prefix "oc-loc-rt";
// import some basic types
import openconfig-inet-types { prefix inet; }
import openconfig-policy-types { prefix oc-pt; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-bfd { prefix oc-bfd; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module describes configuration and operational state data
for routes that are locally generated, i.e., not created by
dynamic routing protocols. These include static routes, locally
created aggregate routes for reducing the number of constituent
routes that must be advertised, summary routes for IGPs, etc.
This model expresses locally generated routes as generically as
possible, avoiding configuration of protocol-specific attributes
at the time of route creation. This is primarily to avoid
assumptions about how underlying router implementations handle
route attributes in various routing table data structures they
maintain. Hence, the definition of locally generated routes
essentially creates 'bare' routes that do not have any protocol-
specific attributes.
When protocol-specific attributes must be attached to a route
(e.g., communities on a locally defined route meant to be
advertised via BGP), the attributes should be attached via a
protocol-specific policy after importing the route into the
protocol for distribution (again via routing policy).";
oc-ext:openconfig-version "4.1.0";
revision "2025-07-29" {
description
"Add wecmp-weight leaf to support wECMP with static routes.";
reference "4.1.0";
}
revision "2025-07-01" {
description
"Move static next-hop-group to local-routing-network-instance and
augment the local routing module.";
reference "4.0.0";
}
revision "2025-06-30" {
description
"Remove leaves that referenced network instances (see 2.2.0)
and replace with augment";
reference "3.0.0";
}
revision "2025-03-31" {
description
"Add static routing to other network instance for destination
lookup";
reference "2.2.0";
}
revision "2025-02-20" {
description
"Add static next-hop-groups and encapsulation headers.";
reference "2.1.0";
}
revision "2022-11-01" {
description
"Update static route nexthop index description.";
reference "2.0.1";
}
revision "2022-05-10" {
description
"Removal of top-level /local-routes, description update to
static route metric, addition of static/aggregate route
preference, addition of aggregate route metric.";
reference "2.0.0";
}
revision "2020-03-24" {
description
"Add bfd support without augmentation.";
reference "1.2.0";
}
revision "2020-03-24" {
description
"Add a description statement to static routes.";
reference "1.1.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "1.0.2";
}
revision "2017-05-15" {
description
"Update to resolve style guide non-compliance.";
reference "1.0.1";
}
revision "2016-05-11" {
description
"OpenConfig public release";
reference "1.0.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity LOCAL_DEFINED_NEXT_HOP {
description
"A base identity type of local defined next-hops";
}
identity DROP {
base LOCAL_DEFINED_NEXT_HOP;
description
"Discard traffic for the corresponding destination";
}
identity LOCAL_LINK {
base LOCAL_DEFINED_NEXT_HOP;
description
"Treat traffic towards addresses within the specified
next-hop prefix as though they are connected to a local
link. When the LOCAL_LINK next-hop type is specified,
an interface must also be specified such that
the local system can determine which link to trigger
link-layer address discovery against";
}
identity LOCAL_DEFINED_WEIGHT {
description
"A base identity type of locally defined next-hop weight.";
}
identity AUTO {
base LOCAL_DEFINED_WEIGHT;
description
"The wecmp-weight leaf inherits value from egress interface
bandwidth expressed in bps.";
}
// typedef statements
typedef local-defined-next-hop {
type identityref {
base LOCAL_DEFINED_NEXT_HOP;
}
description
"Pre-defined next-hop designation for locally generated
routes";
}
typedef local-defined-weight {
type identityref {
base LOCAL_DEFINED_WEIGHT;
}
description
"Pre-defined wECMP weight for locally generated
static route next-hops";
}
// grouping statements
grouping local-generic-settings {
description
"Generic options that can be set on local routes when
they are defined";
leaf set-tag {
type oc-pt:tag-type;
description
"Set a generic tag value on the route. This tag can be
used for filtering routes that are distributed to other
routing protocols.";
}
leaf description {
type string;
description
"An optional textual description for the route.";
}
}
grouping local-common-route-attributes {
description
"Common route attributes that can be set on static route next-hops
as well as aggregate routes.";
leaf metric {
type uint32;
description
"A metric (or cost) which is utilized to specify the order of
selection of the next-hop entry. The lower the metric, the more
preferable the prefix entry is. When this value is not
specified, the metric is inherited from the default metric of
the implementation for static route entries. When multiple
next-hops are specified for a static route, the metric is
utilized to determine which of the next-hops to be installed in
the RIB. When multiple next-hops have the same metric (be it
specified, or simply the default) then these next-hops should
all be installed in the RIB.";
}
leaf preference {
type uint32;
description
"Administrative Distance (preference) of the entry. The
preference defines the order of selection when multiple
sources (protocols, static, etc.) contribute to the same
prefix entry. The lower the preference, the more preferable the
prefix is. When this value is not specified, the preference is
inherited from the default preference of the implementation for
static routes.";
}
leaf wecmp-weight {
type union {
type uint64;
type local-defined-weight;
}
description
"The weight of next-hop used for WECMP (a.k.a. UCMP, WCMP). This
leaf has significance only if multiple next-hops of given prefix
form ECMP group, and all of this next-hops have ecmp-weight leaf
specified. Else, wecmp-weight should be ignored.
The value 'AUTO' sets value to be equal to egress interface
bandwidth expressed in bps (not Bps as BGP link-bandwidth
extended-community does).
It is recommended to express explicit value in bps to be compatible
if mixing next-hops with wecmp-weight = 'AUTO'.
This leaf is valid only if recurse leaf is set to false, or
if interface-ref is specified.";
}
}
grouping local-static-config {
description
"Configuration data for static routes.";
leaf prefix {
type inet:ip-prefix;
description
"Destination prefix for the static route, either IPv4 or
IPv6.";
}
uses local-generic-settings;
}
grouping local-static-state {
description
"Operational state data for static routes";
}
grouping local-static-nexthop-config {
description
"Configuration parameters related to each next-hop entry
specified for a static route";
leaf index {
type string;
description
"An user-specified identifier utilised to uniquely reference
the next-hop entry in the next-hop list. The value of this
index has no semantic meaning other than for referencing
the entry. It is observed that implementations typically
only support a numeric value for this string. ";
}
leaf next-hop {
type union {
type inet:ip-address;
type local-defined-next-hop;
}
description
"The next-hop that is to be used for the static route
- this may be specified as:
- an IP address or
- a pre-defined next-hop type - for instance, DROP or
LOCAL_LINK or
When this leaf is not set, and the interface-ref
value is specified for the next-hop, then the system should
treat the prefix as though it is directly connected to the
interface.
This leaf is mutualy exclusive with next-network-instance
leaf";
}
leaf recurse {
type boolean;
default false;
description
"Determines whether the next-hop should be allowed to
be looked up recursively - i.e., via a RIB entry which has
been installed by a routing protocol, or another static route
- rather than needing to be connected directly to an
interface of the local system within the current network
instance. When the interface reference specified within the
next-hop entry is set (i.e., is not null) then forwarding is
restricted to being via the interface specified - and
recursion is hence disabled.
This leaf is mutualy exclusive with next-network-instance
leaf";
}
uses local-common-route-attributes;
}
grouping local-static-nexthop-state {
description
"Operational state parameters relating to a next-hop entry
for a static route";
}
grouping local-static-top {
description
"Top-level grouping for the list of static route definitions";
container static-routes {
description
"Enclosing container for the list of static routes";
list static {
key "prefix";
description
"List of locally configured static routes";
leaf prefix {
type leafref {
path "../config/prefix";
}
description
"Reference to the destination prefix list key.";
}
container config {
description
"Configuration data for static routes";
uses local-static-config;
}
container state {
config false;
description
"Operational state data for static routes";
uses local-static-config;
uses local-static-state;
}
container next-hops {
description
"Configuration and state parameters relating
to the next-hops that are to be utilised for the static
route being specified.
In the future, this container will be deprecated in favor of the
/network-instances/network-instance/static/next-hop-groups
container. If a statically configured next-hop-group is used
for a static route prefix then the 'static-routes/static/next-hops'
container must not be used.";
list next-hop {
key "index";
description
"A list of next-hops to be utilised for the static
route being specified. In the future, this list will be
deprecated in favor of
/network-instances/network-instance/static/next-hop-groups.";
leaf index {
type leafref {
path "../config/index";
}
description
"A reference to the index of the current next-hop.
The index is intended to be a user-specified value
which can be used to reference the next-hop in
question, without any other semantics being
assigned to it.";
}
container config {
description
"Configuration parameters relating to the next-hop
entry";
uses local-static-nexthop-config;
}
container state {
config false;
description
"Operational state parameters relating to the
next-hop entry";
uses local-static-nexthop-config;
uses local-static-nexthop-state;
}
uses oc-bfd:bfd-enable;
uses oc-if:interface-ref;
}
}
}
}
}
grouping local-aggregate-config {
description
"Configuration data for aggregate routes";
leaf prefix {
type inet:ip-prefix;
description
"Aggregate prefix to be advertised";
}
leaf discard {
type boolean;
default false;
description
"When true, install the aggregate route with a discard
next-hop -- traffic destined to the aggregate will be
discarded with no ICMP message generated. When false,
traffic destined to an aggregate address when no
constituent routes are present will generate an ICMP
unreachable message.";
}
uses local-generic-settings;
uses local-common-route-attributes;
}
grouping local-aggregate-state {
description
"Operational state data for local aggregate advertisement
definitions";
}
grouping local-aggregate-top {
description
"Top-level grouping for local aggregates";
container local-aggregates {
description
"Enclosing container for locally-defined aggregate
routes";
list aggregate {
key "prefix";
description
"List of aggregates";
leaf prefix {
type leafref {
path "../config/prefix";
}
description
"Reference to the configured prefix for this aggregate";
}
container config {
description
"Configuration data for aggregate advertisements";
uses local-aggregate-config;
}
container state {
config false;
description
"Operational state data for aggregate
advertisements";
uses local-aggregate-config;
uses local-aggregate-state;
}
}
}
}
}

View File

@@ -0,0 +1,226 @@
module openconfig-messages {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/messages";
prefix "oc-messages";
// import some basic types
import openconfig-extensions { prefix "oc-ext"; }
import openconfig-system-logging { prefix "oc-log"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
related to Syslog messages that a device may generate.
These messages are historically obtained through the Syslog
transport, however this module allows for obtaining them through
an alternative transport, such as a Subscribe operation over an
RPC.
This module does not usurp traditional syslog servers, which may
still be configured through the
/yang/system/openconfig-system.yang model, rather it provies the
Operator with an alternative method of consuming messages.";
oc-ext:openconfig-version "0.1.0";
revision 2024-07-15 {
description
"Remove unused top-level messages container.";
reference "0.1.0";
}
revision "2018-08-13" {
description
"Initial draft.";
reference "0.0.1";
}
// identity statements
identity DEBUG_SERVICE {
description
"Base identity for debug services. Identities within this base
identity are to be augmented in by vendors.";
}
// grouping statements
grouping messages-config {
description
"Configuration data for defining Syslog message severity.";
leaf severity {
type oc-log:syslog-severity;
description
"Specifies that only messages of the given severity (or
greater severity) are sent over the RPC.
This is analogous to differentiating which severity is to be
sent to legacy Syslog servers, as opposed to local buffer or
files.";
}
}
grouping messages-state {
description
"Operational state data for Syslog messages.";
container message {
oc-ext:telemetry-atomic;
config false;
description
"Syslog messages the client is Subscribing to. This is all
messages currently configured to be sent according to
syslog-severity.";
reference
"IETF RFC 5424 - The Syslog Protocol";
// Decide if it is OK to include ALL in this leaf.
leaf msg {
type string;
description
"Message payload. If other leafs within this container not
supported, this leaf MAY include the entire message,
inclding pri, procid, app-name etc..";
}
leaf priority {
type uint8;
description
"The Priority value (PRIVAL) represents both the
Facility and Severity.";
reference
"IETF RFC 5424, Section 6.2.1";
}
leaf app-name {
type string;
description
"The APP-NAME field SHOULD identify the device or
application that originated the message.";
reference
"IETF RFC 5424, Section 6.2.5.";
}
leaf procid {
type string;
description
"PROCID is a value that is included in the message, having
no interoperable meaning, except that a change in the value
indicates there has been a discontinuity in syslog
reporting.";
reference
"IETF RFC 5424, Section 6.2.6.";
}
leaf msgid {
type string;
description
"The MSGID SHOULD identify the type of message. For
example, a firewall might use the MSGID 'TCPIN' for
incoming TCP traffic and the MSGID 'TCPOUT' for outgoing
TCP traffic.";
reference
"IETF RFC 5424, Section 6.2.7.";
}
}
}
grouping debug-messages-config {
description
"Configuration data for enabling debug messages.";
leaf service {
type identityref {
base DEBUG_SERVICE;
}
description
"Enumeration of all services which can have debugging enabled.
Vendors are to augment this base identity with their platform
or OS specific debug options.";
}
leaf enabled {
type boolean;
default false;
description
"Enable and disable debugging.";
}
}
grouping debug-messages-top {
description
"Configuration data for enabling Syslog debug messages.";
container debug-entries {
description
"Enclosing container for list of debugs to enable.";
list debug-service {
key "service";
description
"List of debugging entries.";
leaf service {
type leafref {
path "../config/service";
}
description
"Reference to the debug-enable service key.";
}
container config {
description
"Configuration data for debug service entries.";
uses debug-messages-config;
}
container state {
config false;
description
"Operational state data for enabled debugs.";
uses debug-messages-config;
}
}
}
}
grouping messages-top {
description
"Top-level grouping for Syslog messages.";
container messages {
description
"Top-level container for Syslog messages.";
container config {
description
"Configuration data for Syslog messages.";
uses messages-config;
}
container state {
config false;
description
"Operational state data for a Syslog messages.";
uses messages-config;
uses messages-state;
}
uses debug-messages-top;
}
}
}

View File

@@ -0,0 +1,953 @@
submodule openconfig-network-instance-l2 {
belongs-to openconfig-network-instance {
prefix "oc-netinst";
}
// import some basic types
import openconfig-extensions { prefix "oc-ext"; }
import openconfig-interfaces { prefix "oc-if"; }
import openconfig-yang-types { prefix "oc-yang"; }
import openconfig-inet-types { prefix "oc-inet"; }
import openconfig-evpn-types { prefix oc-evpn-types; }
import openconfig-evpn { prefix "oc-evpn"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module contains groupings which specifically relate to
Layer 2 network instance configuration and operational state
parameters.";
oc-ext:openconfig-version "4.7.0";
revision "2026-03-17" {
description
"Add enable-aigp to BGP address families in neighbors and peer-groups.";
reference "4.7.0";
}
revision "2025-03-26" {
description
"Add OSPFv3 container";
reference "4.6.0";
}
revision "2025-02-20" {
description
"Add static next-hop-groups and encapsulation headers.";
reference "4.5.0";
}
revision "2024-02-27" {
description
"Clarify that tables are created only by the system and not
users.";
reference "4.4.1";
}
revision "2024-02-27" {
description
"Clarify metric to be used for route redistribution when
disable-metric-propagation is set to true.";
reference "4.4.0";
}
revision "2023-12-13" {
description
"Expand when statement for connection-points endpoints";
reference "4.3.0";
}
revision "2023-11-03" {
description
"Add reference URL for Route Redistribution rules";
reference "4.2.2";
}
revision "2023-11-01" {
description
"Refactor apply policy to separate default policy in it's own common
set of groupings";
reference "4.2.1";
}
revision "2023-09-07" {
description
"Add L2RIB Per Producer Next-Hop Capability";
reference "4.2.0";
}
revision "2023-08-09" {
description
"Update interface key to use interface-id type";
reference "4.1.1";
}
revision "2023-07-12" {
description
"Moved ethernet-segments to top level
container.";
reference "4.1.0";
}
revision "2023-04-25" {
description
"Clarify use of interface-ref.";
reference "4.0.3";
}
revision "2023-03-15" {
description
"Clarify that tables are to be deleted by the
network operating system";
reference "4.0.2";
}
revision "2023-02-07" {
description
"Add prefixes to identity values in when statements";
reference "4.0.1";
}
revision "2022-12-21" {
description
"Removal of global per network-instance MTU";
reference "4.0.0";
}
revision "2022-12-21" {
description
"Removal of interface list unique statement";
reference "3.1.0";
}
revision "2022-12-20" {
description
"Removal of top-level enabled-address-families leaf-list";
reference "3.0.0";
}
revision "2022-11-18" {
description
"Enforce network-instance type as mandatory, removal of top-level
enabled leaf, migrate IETF types to OpenConfig types";
reference "2.0.0";
}
revision "2022-09-15" {
description
"Add fallback-vrf option.";
reference "1.4.0";
}
revision "2022-07-04" {
description
"Add pcep protocol to network-instance";
reference "1.3.0";
}
revision "2022-06-21" {
description
"Add prefix to qualification netinst-ref.";
reference "1.2.0";
}
revision "2022-04-20" {
description
"Add support for l2rib state data";
reference "1.1.0";
}
revision "2022-04-19" {
description
"Description updates for DEFAULT_INSTANCE implementation
guidance and default value/guidance for protocol instances";
reference "1.0.0";
}
revision "2022-04-19" {
description
"Fix some broken xpath references in when statements.";
reference "0.16.3";
}
revision "2021-11-17" {
description
"Add prefix to qualification prefix to when statements
at identifier level.";
reference "0.16.2";
}
revision "2021-07-22" {
description
"Remove unused imported models.";
reference "0.16.1";
}
revision "2021-06-11" {
description
"Structural update for arp-proxy and
proxy-nd.";
reference "0.16.0";
}
revision "2021-01-25" {
description
"Add support for evpn";
reference "0.15.0";
}
revision "2020-06-20" {
description
"Add support for toggling metric propagation
when using table-connections.";
reference "0.14.0";
}
revision "2019-11-28" {
description
"Revert fixes for paths in when statements";
reference "0.13.2";
}
revision "2019-04-16" {
description
"Move BGP RIB into the protocol/bgp container.";
reference "0.12.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.11.1";
}
revision "2018-08-11" {
description
"Add vlan id as additional key in MAC table";
reference "0.11.0";
}
revision "2018-06-22" {
description
"Fix typo in OSPF when statement";
reference "0.10.2";
}
revision "2018-06-05" {
description
"Fix bugs in when statements";
reference "0.10.1";
}
revision "2018-02-19" {
description
"Add PIM and IGMP to network instance";
reference "0.10.0";
}
revision "2017-12-13" {
description
"Fix incorrect constraint on SR and MPLS containers";
reference "0.9.0";
}
revision "2017-08-24" {
description
"Minor formatting fixes";
reference "0.8.1";
}
revision "2017-02-28" {
description
"Add OSPFv2 to network instance";
reference "0.8.0";
}
revision "2017-01-26" {
description
"Add policy forwarding to network instance";
reference "0.7.0";
}
revision "2017-01-13" {
description
"Add AFT to the network instance";
reference "0.6.0";
}
revision "2016-12-15" {
description
"Add segment routing to network instance";
reference "0.5.0";
}
revision "2016-11-10" {
description
"Update model to include IS-IS.";
reference "0.4.1";
}
revision "2016-10-12" {
description
"Update table connections";
reference "0.4.0";
}
revision "2016-09-28" {
description
"Change L2 instance to submodule; add MAC table";
reference "0.3.0";
}
revision "2016-08-11" {
description
"Resolve repeated container names in routing protocols";
reference "0.2.3";
}
revision "2016-07-08" {
description
"Updated with refactored routing protocol models";
reference "0.2.1";
}
revision "2016-03-29" {
description
"Initial revision";
reference "0.2.0";
}
revision "2015-11-20" {
description
"Initial revision";
reference "0.1.0";
}
grouping l2ni-instance {
description
"Configuration and operational state parameters relating
to a Layer 2 network instance";
container fdb {
description
"Operational state and configuration parameters relating to
the forwarding database of the network instance";
container config {
description
"Configuration parameters relating to the FDB";
uses l2ni-fdb-mac-config;
}
container state {
config false;
description
"Operational state parameters relating to the FDB";
uses l2ni-fdb-mac-config;
}
uses l2ni-mac-table-top;
uses oc-evpn:evpn-mac-mobility-top;
uses oc-evpn:evpn-arp-proxy-top;
uses oc-evpn:evpn-nd-proxy-top;
uses l2ni-l2rib-top;
}
}
grouping l2ni-fdb-mac-config {
description
"Parameters relating to FDB behaviour relating to MAC
addresses";
leaf mac-learning {
type boolean;
description
"When this leaf is set to true, MAC learning is enabled for
the network instance, such that MAC addresses are learned
from ingress frames and added to the FDB.";
}
leaf mac-aging-time {
// Cisco supports one aging time for local and remote, but
// can specify this time is absolute or against inactivity.
// ALU SROS supports different aging times for local and remote
// but does not allow absolute/inactivity specification.
// JNPR supports only a single aging time, and no specification
// of whether inactivity/absolute is used.
// It is easy to augment new options in here for local remote
// and an extra leaf to allow specification of the type of aging
// so this is left as a single value.
type uint16;
units seconds;
description
"The number of seconds of inactivity after which the entry
in the local FDB is timed out.";
}
leaf maximum-entries {
type uint16;
description
"The maximum number of MAC address entries that should be
accepted into the FDB";
}
uses oc-evpn:evpn-mac-vrf-config;
}
grouping l2ni-encapsulation-config {
description
"Encapsulation related configuration parameters for a L2
network instance";
leaf control-word {
type boolean;
description
"Whether the control-word should be used for the network
instance";
reference "RFC3985";
}
}
grouping l2ni-mac-table-config {
description
"Configuration data for MAC table entries";
leaf mac-address {
type oc-yang:mac-address;
description
"MAC address for the dynamic or static MAC table
entry";
}
leaf vlan {
//TODO(aashaikh): Consider whether this should just reflect the
//VLAN id or be a union type to also support displaying/setting
//the VLAN by name (i.e., global VLAN configured in the VLAN
// model).
type leafref {
path "../../../../../../vlans/vlan/config/vlan-id";
}
description
"VLAN on which the MAC address is present. The same MAC
address may be seen on multiple VLANs in some cases.";
}
}
grouping l2ni-mac-table-state {
description
"Operational state data for MAC table entries";
leaf age {
type uint64;
units seconds;
description
"The time in seconds since the MAC address has been in the
table";
}
leaf entry-type {
type enumeration {
enum STATIC {
description
"Statically programmed MAC table entry";
}
enum DYNAMIC {
description
"Dynamically learned MAC table entry";
}
}
description
"Indicates whether the entry was statically configured, or
dynamically learned.";
}
leaf evi {
type oc-evpn-types:vni-id;
description "EVPN EVI to associate with the BD/VLAN";
}
}
grouping l2ni-mac-table-top {
description
"Top-level grouping for MAC table list";
container mac-table {
description
"Table of learned or statically configured MAC addresses and
corresponding VLANs in the bridge domain";
container entries {
description
"Enclosing container for list of MAC table entries";
list entry {
key "mac-address vlan";
description
"List of learned MAC addresses";
leaf mac-address {
type leafref {
path "../config/mac-address";
}
description
"Reference to mac-address list key";
}
leaf vlan {
type leafref {
path "../config/vlan";
}
description
"Reference to vlan list key";
}
container config {
description
"Configuration data for MAC table entries";
uses l2ni-mac-table-config;
}
container state {
config false;
description
"Operational state data for MAC table entries";
uses l2ni-mac-table-config;
uses l2ni-mac-table-state;
}
container interface {
description
"Reference to the base and/or subinterface for the
MAC table entry";
uses oc-if:interface-ref;
}
}
}
}
}
grouping l2ni-l2rib-top {
description
"Top-level grouping for l2rib MAC and MAC-IP table list";
container l2rib {
config false;
description
"Operational state container for MAC address and MAC-IP address
information that is learned and installed into the MAC VRF Layer 2
Routing Information Base (L2RIB)";
container mac-table {
description
"Operational state container for MAC address information installed
into the MAC VRF of the L2RIB";
container entries {
description
"Enclosing container for list of MAC address entries";
list entry {
key "mac-address";
description "List of learned MAC addresses";
leaf mac-address {
type leafref {
path "../state/mac-address";
}
description "Leafref of MAC address object";
}
container state {
config false;
description
"Operational state data for L2RIB MAC table object entry";
uses l2ni-l2rib-mac-table-state;
}
container producers {
description "Source producers for each MAC Table entry";
list producer {
key "producer";
description
"List of producers for each MAC table entry";
leaf producer {
type leafref {
path "../state/producer";
}
description
"Reference to producer list key";
}
container state {
config false;
description "State container for L2RIB MAC Table Entries";
uses l2ni-l2rib-common-producer-state;
uses l2ni-l2rib-mac-table-producer-state;
}
}
}
}
}
uses l2ni-l2rib-common-next-hop-group-state;
uses l2ni-l2rib-common-next-hop-state;
}
container mac-ip-table {
description
"Operational state container for MAC-IP address information installed
into the MAC VRF of the L2RIB";
container entries {
description
"Enclosing container for list of MAC-IP address entries";
list entry {
key "mac-address host-ip";
description "List of learned MAC-IP addresses";
leaf mac-address {
type leafref {
path "../state/mac-address";
}
description "Leafref of MAC-IP address object";
}
leaf host-ip {
type leafref {
path "../state/host-ip";
}
description "IP address of the Customer Edge device";
}
container state {
config false;
description
"Operational state data for L2RIB MAC-IP table object entry";
uses l2ni-l2rib-mac-ip-table-state;
}
container producers {
description "Source producers for each MAC-IP Table entry";
list producer {
key "producer";
description
"List of producers for each MAC-IP table entry";
leaf producer {
type leafref {
path "../state/producer";
}
description
"Reference to producer list key";
}
container state {
config false;
description "State container for L2RIB MAC Table Entries";
uses l2ni-l2rib-common-producer-state;
}
}
}
}
}
uses l2ni-l2rib-common-next-hop-group-state;
uses l2ni-l2rib-common-next-hop-state;
}
}
}
grouping l2ni-l2rib-mac-table-state {
description "L2RIB MAC Table Operational State Grouping";
uses l2ni-l2rib-common-state;
}
grouping l2ni-l2rib-mac-ip-table-state {
description "L2RIB Mac-IP Table Operational State Grouping";
uses l2ni-l2rib-common-state;
leaf host-ip {
type oc-inet:ip-address;
description
"Host IP address of the CE device for the L2RIB MAC-IP entry";
reference "RFC7432: BGP MPLS-Based Ethernet VPN";
}
leaf l3-vni {
type oc-evpn-types:evi-id;
description
"Symmetric IRB uses the same forwarding semantics when routing
between IP subnets with VRF Lite or MPLS L3VPNs. With symmetric IRB,
all traffic egressing and returning from a VTEP uses the same VNI.
Specifically, the same Layer 3 VNI (L3VNI) associated with the VRF
is used for all routed traffic. Layer3 VNI used for inter-subnet
routing";
}
}
grouping l2ni-l2rib-common-state {
description "L2RIB Common Property Operational State Data Grouping";
leaf mac-address {
type oc-yang:mac-address;
description "MAC address of the L2RIB MAC or MAC-IP entry";
}
leaf vlan {
type leafref {
path "../../../../../../../vlans/vlan/config/vlan-id";
}
description
"VLAN on which the MAC or MAC-IP address is present.";
}
leaf evi {
type oc-evpn-types:evi-id;
description "EVPN Instance Identifier for the MAC or MAC-IP";
}
leaf l2-vni {
type oc-evpn-types:evi-id;
description "Layer2 VNI segment mapped to given vlan-id";
}
}
grouping l2ni-l2rib-common-producer-state {
description "L2RIB Common Producer Attributes Operational State Data Grouping";
leaf producer {
type enumeration {
enum LOCAL {
description "local producer source";
}
enum STATIC {
description "static producer source";
}
enum BGP {
description "bgp producer source";
}
}
description "Source of the learned L2RIB route";
}
leaf seq-number {
type uint32;
description
"The sequence number is used to ensure that PEs retain the correct
MAC/IP Advertisement route when multiple updates occur for the same
MAC address";
reference "RFC7432: BGP MPLS-Based Ethernet VPN";
}
leaf mobility-state {
type enumeration {
enum FROZEN {
description
"Permanently frozen mac-address";
}
enum DUPLICATE {
description
"Duplicate mac-address";
}
}
description
"Indicates if learned MAC address is duplicate or frozen";
reference "draft-ietf-bess-evpn-irb-extended-mobility-05";
}
leaf esi {
type oc-evpn-types:esi;
description
"Ethernet Segment Identifier (ESI) for local and remote routes.
ESI is used to resolve the next-hop-group. All mac-addresses
learned with the same ESI should point to the same next-hop-group";
}
leaf sticky {
type boolean;
description "MAC address is sticky and not subjected to MAC moves";
reference "RFC7432: BGP MPLS-Based Ethernet VPN";
}
leaf next-hop {
type leafref {
path "../../../../../../next-hops/next-hop/index";
}
status deprecated;
description "Leafref next-hop for the MAC-IP table entry";
}
leaf-list next-hop-group {
type leafref {
path "../../../../../../next-hop-groups/next-hop-group/id";
}
description "Leafref next-hop-group for the MAC-IP table entry";
}
}
grouping l2ni-l2rib-common-next-hop-state {
description "L2RIB Common Next Hop Attributes Operational State Data Grouping";
container next-hops {
description "A next-hop associated with the MAC or MAC-IP entry";
list next-hop {
key "index";
description "List of next hop attributes for each MAC or MAC-IP";
leaf index {
type leafref {
path "../state/index";
}
description
"A unique index identifying the next-hop entry for the
MAC or MAC-IP entry";
}
container state {
description "State container for common next-hop attributes";
config false;
leaf index {
type uint64;
description "A unique entry for the next-hop.";
}
leaf peer-ip {
type oc-inet:ip-address;
description "Next hop peer address";
}
leaf label {
type oc-evpn-types:evi-id;
description "Next hop label representing the l2vni for the route";
}
leaf esi {
type oc-evpn-types:esi;
description "Ethernet Segment Identifier (ESI)";
reference "RFC7432: BGP MPLS-Based Ethernet VPN";
}
leaf resolved {
type boolean;
description
"Indicates if the path is eligible for forwarding as per evpn mass
withdraw procedures as defined in RFC 7432";
}
uses oc-if:interface-ref-common;
}
}
}
}
grouping l2ni-l2rib-common-next-hop-group-state {
description "L2RIB Common Next Hop Group Attributes Operational State Data Grouping";
container next-hop-groups {
description "Surrounding container for groups of L2RIB next-hops.";
list next-hop-group {
key "id";
description
"An individual set of next-hops grouped into a common group.
Each entry within an L2RIB can optionally point to a
next-hop-group.";
leaf id {
type leafref {
path "../state/id";
}
description
"A reference to a unique identifier for the next-hop-group.";
}
container state {
description "State container for common next-hop-group attributes";
config false;
leaf id {
type uint64;
description
"A unique identifier for the next-hop-group. This index is not
expected to be consistent across reboots, or reprogramming of
the next-hop-group. When updating a next-hop-group, if the group
is removed by the system or assigned an alternate identifier, the
system should send telemetry notifications deleting the previous
identifier. If the identifier of the next-hop-group is changed,
all L2RIB entries that reference it must also be updated.";
}
leaf esi {
type oc-evpn-types:esi;
description "Ethernet Segment Identifier (ESI)";
reference "RFC7432: BGP MPLS-Based Ethernet VPN";
}
leaf type {
type enumeration {
enum ESI {
description
"Per ESI pathlist next-hop-group used for evpn mass withdraw procedures as defined in RFC 7432";
}
enum ESI_EVI {
description
"Per ESI,EVI pathlist next-hop-group used for evpn aliasing procedures as defined in RFC 7432";
}
enum BASE_ECMP {
description
"Base ECMP next-hop-group used in absence of evpn aliasing";
}
}
description "Type of next-hop-group";
}
}
container next-hops {
description
"Surrounding container for the list of next-hops within the next-hop-group.";
list next-hop {
key "index";
description
"An individual next-hop within the next-hop-group. Each next-hop is a
reference to an entry within the next-hop list.";
leaf index {
type leafref {
path "../state/index";
}
description
"A reference to the index for the next-hop within the the next-hop-group.";
}
container state {
description
"Operational state parameters related to a next-hop within the next-hop-group.";
config false;
leaf index {
type leafref {
path "../../../../../../next-hops/next-hop/index";
}
description
"A reference to the identifier for the next-hop to which the entry in the
next-hop group corresponds.";
}
}
}
}
}
}
}
grouping l2ni-l2rib-mac-table-producer-state {
description "L2RIB MAC Table Operational State Data Grouping";
leaf derived-from-mac-ip {
type boolean;
description "Derived from BGP MAC-IP route-type 2";
}
leaf directly-received {
type boolean;
description "BGP learned MAC route-type 2";
}
}
}

View File

@@ -0,0 +1,242 @@
module openconfig-network-instance-l3 {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/network-instance-l3";
prefix "oc-ni-l3";
// import some basic types
import openconfig-extensions { prefix "oc-ext"; }
import openconfig-types { prefix "octypes"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module contains groupings which specifically relate to
Layer 3 network instance configuration and operational state
parameters.";
oc-ext:openconfig-version "2.0.0";
revision "2022-11-08" {
description
"Removal of top-level enabled-address-families leaf-list";
reference "2.0.0";
}
revision "2022-09-15" {
description
"Reflect implementation status by releasing 1.0.0.";
reference "1.0.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.11.1";
}
revision "2018-08-17" {
description
"Add a route limit for L3 network instances.";
reference "0.11.0";
}
revision "2017-12-13" {
description
"Fix incorrect constraint on SR and MPLS containers";
reference "0.9.0";
}
revision "2017-08-24" {
description
"Minor formatting fixes";
reference "0.8.1";
}
revision "2017-02-28" {
description
"Add OSPFv2 to network instance";
reference "0.8.0";
}
revision "2017-01-26" {
description
"Add policy forwarding to network instance";
reference "0.7.0";
}
revision "2017-01-13" {
description
"Add AFT to the network instance";
reference "0.6.0";
}
revision "2016-12-15" {
description
"Add segment routing to network instance";
reference "0.5.0";
}
revision "2016-11-10" {
description
"Update model to include IS-IS.";
reference "0.4.1";
}
revision "2016-09-28" {
description
"Change L2 instance to submodule; add MAC table";
reference "0.3.0";
}
revision "2016-08-11" {
description
"Resolve repeated container names in routing protocols";
reference "0.2.3";
}
revision "2016-07-08" {
description
"Updated with refactored routing protocol models";
reference "0.2.1";
}
revision "2016-03-29" {
description
"Initial revision";
reference "0.2.0";
}
revision "2016-03-14" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
grouping l3ni-instance {
description
"Configuration and operational state parameters relevant
to network instances that include a Layer 3 type";
}
grouping l3ni-route-limit-structural {
description
"Configuration and state for the maximum number of routes
that should be used by routing instance.";
container route-limits {
description
"Configuration and operational state relating to the
maximum number of routes for the address family that
should be allowed within the Layer 3 network instance.
When the specified value is reached, no further prefixes
should be installed into the system's RIB from this network
instance unless the warning only leaf is set. In this case,
new routes should still be installed. If a alarm threshold
is specified, then this should be used to generate
alarms via telemetry for the network instance.";
list route-limit {
key "afi";
description
"A route limit applying to a particular address family.";
leaf afi {
type leafref {
path "../config/afi";
}
description
"Reference to the address family for which the route
limit is being applied.";
}
container config {
description
"Configuration options relating to the route limit.";
uses l3ni-route-limit-config;
}
container state {
config false;
description
"Operational state parameters relating to the route limit.";
uses l3ni-route-limit-config;
uses l3ni-route-limit-state;
}
}
}
}
grouping l3ni-route-limit-config {
description
"Configuration options relating to the route limit for a network
instance.";
leaf afi {
type identityref {
base octypes:ADDRESS_FAMILY;
}
description
"The address family for which the route limit applies.";
}
leaf maximum {
type uint32;
description
"The maximum number of routes for the address family. The
system should not install more than maximum number of
prefixes into the RIB unless the warning-only leaf is specified.";
}
leaf warning-only {
type boolean;
default false;
description
"When specified, the route limit specified is considered only as
a warning - and routes should continue to be installed into the
RIB over the limit specified in the maximum leaf.";
}
leaf alarm-threshold {
type uint32;
description
"When specified, an alarm should be generated when the threshold
number of installed routes is reached.";
}
}
grouping l3ni-route-limit-state {
description
"Operational state relating to the route limit for a network
instance.";
leaf threshold-exceeded {
type boolean;
description
"This leaf should be set to true in the case that the threshold
number of routes has been exceeded.";
}
leaf installed-routes {
type uint32;
description
"The current number of routes installed for the address family.";
}
}
}

View File

@@ -0,0 +1,144 @@
module openconfig-network-instance-policy {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/network-instance/policy";
prefix "oc-ni-pol";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
import openconfig-routing-policy { prefix oc-rpol; }
import openconfig-policy-types { prefix oc-pol-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines routing policy statements (conditions and
actions) for the network instance model. These statements are
generally added to the routing policy model.";
oc-ext:openconfig-version "0.1.3";
revision "2024-09-19" {
description
"Correct typo in description of
match-protocol-instance/protocol-name.";
reference "0.1.3";
}
revision "2023-07-25" {
description
"Expand description of
match-protocol-instance/protocol-name.";
reference "0.1.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2017-02-15" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// grouping statements
grouping protocol-instance-policy-config {
description
"Configuration data for policy matching on protocol instance";
leaf protocol-identifier {
type identityref {
base oc-pol-types:INSTALL_PROTOCOL_TYPE;
}
description
"The identifier (protocol type) of the
protocol instance to match on in the local network
instance.";
}
leaf protocol-name {
type string;
description
"The name of the protocol instance to match
on in the local network instance. The string
must match one of /network-instances/
network-instance/protocols/
protocol/name in the local network
instance.";
}
}
grouping protocol-instance-policy-state {
description
"Operational state data for policy matching on protocol
instance";
}
grouping protocol-instance-policy-top {
description
"Top-level grouping for policy matching on protocol instance";
container match-protocol-instance {
description
"Top-level container for protocol instance match condition
in policy statements. The protocol instance is referenced
by an identifier and name";
container config {
description
"Configuration data for policy matching on protocol
instance";
uses protocol-instance-policy-config;
}
container state {
config false;
description
"Operational state data for policy matching on protocol instance";
uses protocol-instance-policy-config;
uses protocol-instance-policy-state;
}
}
}
// data definition statements
// augment statements
augment "/oc-rpol:routing-policy/oc-rpol:policy-definitions/" +
"oc-rpol:policy-definition/oc-rpol:statements/oc-rpol:statement/" +
"oc-rpol:conditions" {
description
"Add match conditions for protocol instances to the routing
policy model.";
uses protocol-instance-policy-top;
}
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,350 @@
module openconfig-network-instance-static {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/network-instance-static";
prefix "oc-ni-static";
import openconfig-extensions { prefix "oc-ext"; }
import openconfig-aft { prefix "oc-aft"; }
import openconfig-aft-types { prefix "oc-aftt"; }
import openconfig-local-routing { prefix "oc-loc-rt"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"Static configurations associated with a network instance";
oc-ext:openconfig-version "0.2.1";
revision "2025-08-05" {
description
"Fix typo in description of MPLS encapsulation headers.";
reference "0.2.1";
}
revision "2025-07-17" {
description
"Adding static encapsulation headers for GRE and MPLS.";
reference "0.2.0";
}
revision "2025-02-20" {
description
"Initial revision adding static next-hop-groups and encapsulation headers.";
reference "0.1.0";
}
grouping ni-static-structural {
description
"Logical grouping for static configurations.";
container static {
description
"Surrounding container for static configurations.";
uses next-hop-groups-top {
description
"Configuration and state parameters relating to
statically configured next hop group";
}
uses static-next-hops-top {
description
"Configuration and state parameters relating to
statically configured next hop";
}
}
}
grouping next-hop-groups-top {
description
"Logical grouping for statically configured next-hop-groups";
container next-hop-groups {
description
"Surrounding container for groups of next-hops.";
list next-hop-group {
key "name";
description
"A list of user defined next-hop-groups. Each next-hop-group contains a
list of next-hops noting where packets should be forwarded, plus any
packet header fields that may be set. Static routes and policy-forwarding
actions in OpenConfig may reference a next-hop-group name to indicate
where packets should be forwarded.";
leaf name {
type leafref {
path "../config/name";
}
description
"A reference to a unique identifier for the next-hop-group.";
}
container config {
description
"Configuration parameters relating to next-hop-groups.";
uses static-nhg-top;
}
container state {
config false;
description
"State parameters relating to next-hop-groups.";
uses static-nhg-top;
}
container next-hops {
description
"Surrounding container for the list of next-hops within
the next-hop-group.";
list next-hop {
key "index";
description
"An individual next-hop within the next-hop-group. Each
next-hop is a reference to an entry within the next-hop
list.";
leaf index {
type leafref {
path "../config/index";
}
description
"A reference to the index for the next-hop within the
the next-hop-group.";
}
container config {
description
"Configuration parameters related to a next-hop
within the next-hop-group.";
uses static-nhg-next-hop;
}
container state {
config false;
description
"State parameters related to a next-hop
within the next-hop-group.";
uses static-nhg-next-hop;
}
}
}
}
}
}
grouping static-nhg-top {
description
"Logical grouping for statically configured next-hop-groups";
leaf name {
type string;
description
"A user defined name that uniquely identifies the next-hop-group.";
}
}
grouping static-nhg-next-hop {
description
"Configuration parameters relating to an individual next-hop
within the next-hop-group.";
leaf index {
type leafref {
// We are at network-instance/static/next-hop-groups/next-hop-group/next-hops/next-hop/index
path "../../../../../../next-hops/next-hop/index";
}
description
"A reference to the identifier for the next-hop to which
the entry in the next-hop group corresponds.";
}
}
grouping static-next-hops-top {
description
"Logical grouping for statically configured next-hops.";
container next-hops {
description
"The list of next-hops that are to be used for entry within
the network instance. The structure of each next-hop is address
family independent, such that it is possible to resolve fully
how the next-hop is treated. For example:
- Where ingress IPv4 unicast packets are to be forwarded via
an MPLS LSP, the next-hop list should indicate the MPLS
label stack that is used to the next-hop.
- Where ingress MPLS labelled packets are to be forwarded to
an IPv6 nexthop (for example, a CE within a VPN), then the
popped label stack, and IPv6 next-hop address should be
indicated.";
list next-hop {
key "index";
description
"A next-hop associated with the forwarding instance.";
leaf index {
type leafref {
path "../config/index";
}
description
"A unique index identifying the next-hop entry";
}
container config {
description
"Configuration parameters relating to the next-hop entry";
uses oc-loc-rt:local-static-nexthop-config;
}
container state {
config false;
description
"State parameters relating to the next-hop entry";
uses oc-loc-rt:local-static-nexthop-config;
}
uses static-encap-headers;
}
}
}
grouping static-encap-headers {
description
"Grouping for encapsulation headers.";
container encap-headers {
description
"Container for packet encapsulation headers. When leaves in this
container are populated, it indicates encapsulation of the packet
matching the next-hop is performed using a stack of one or more
headers defined in the list encap-header.
Each entry in the list must indicate an encapsulation type and
populate a container with the parameters for that encapsulation
header.";
list encap-header {
description
"A list of headers added on top of a packet ordered by the
index value. The inner-most header is the 0th value and is
adjacent to the original packet. Additional headers may be
added in index order.
For example, in an encapsulation stack for MPLS in UDPv4, the
first index in the list is the MPLS header and the second
index is a UDPv4 header.";
key "index";
leaf index {
type leafref {
path "../config/index";
}
description
"A unique index identifying an encapsulation header in a stack
of encapsulation headers.";
}
container config {
description
"Config parameters relating to encapsulation headers.";
uses oc-aft:aft-common-nexthop-encap-headers-state;
}
container state {
config false;
description
"State parameters relating to encapsulation headers.";
uses oc-aft:aft-common-nexthop-encap-headers-state;
}
container udp-v4 {
when "../config/type = 'oc-aftt:UDPV4'";
description
"Container of nodes for UDP in IPv4 encapsulation. When this
container is used, an IPv4 header with a UDP header is added
to the encapsulation list.";
container config {
description
"Configuration parameters relating to encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-udp-v4-state;
}
container state {
config false;
description
"State parameters relating to encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-udp-v4-state;
}
}
container gre {
when "../config/type = 'oc-aftt:GRE'";
description
"Container of nodes for GRE encapsulation. When this
container is used, a GRE header is added to the encapsulation
list.";
container config {
description
"Configuration parameters relating to GRE encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-gre-config;
}
container state {
config false;
description
"State parameters relating to GRE encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-gre-config;
}
}
container mpls {
when "../config/type = 'oc-aftt:MPLS'";
description
"Container of nodes for MPLS encapsulation. When this
container is used, a MPLS header is added to the encapsulation
list. Only client configured leaves are defined. The system
should set the MPLS TTL and Bottom of Stack bit per RFC 3032.
To specify multiple labels, the client should create multiple
encap-header list entries.";
container config {
description
"Configuration parameters relating to MPLS encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-mpls-config;
}
container state {
config false;
description
"State parameters relating to MPLS encapsulation headers.";
uses oc-aft:aft-common-entry-nexthop-encap-mpls-config;
}
}
}
}
}
}

View File

@@ -0,0 +1,329 @@
module openconfig-network-instance-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/network-instance-types";
prefix "oc-ni-types";
import openconfig-extensions { prefix "oc-ext"; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"Types associated with a network instance";
oc-ext:openconfig-version "0.9.3";
revision "2021-07-14" {
description
"Use auto-generated regex for route-distinguisher pattern statements";
reference "0.9.3";
}
revision "2021-06-16" {
description
"Remove trailing whitespace";
reference "0.9.2";
}
revision "2021-05-21" {
description
"Add support for evpn";
reference "0.9.1";
}
revision "2021-03-03" {
description
"Fix route-distinguisher's pattern statement, and remove the regexp-posix
extension, which makes pattern statements conform to the YANG standard.";
reference "0.9.0";
}
revision "2020-06-30" {
description
"Add OpenConfig POSIX pattern extensions.";
reference "0.8.3";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.8.2";
}
revision "2017-08-24" {
description
"Minor formatting fixes";
reference "0.8.1";
}
revision "2017-02-28" {
description
"Add OSPFv2 to network instance";
reference "0.8.0";
}
revision "2017-01-26" {
description
"Add policy forwarding to network instance";
reference "0.7.0";
}
revision "2017-01-13" {
description
"Add AFT to the network instance";
reference "0.6.0";
}
revision "2016-12-15" {
description
"Add segment routing to network instance";
reference "0.5.0";
}
revision "2016-11-10" {
description
"Update model to include IS-IS.";
reference "0.4.1";
}
revision "2016-10-12" {
description
"Update table connections";
reference "0.4.0";
}
revision "2016-09-28" {
description
"Change L2 instance to submodule; add MAC table";
reference "0.3.0";
}
revision "2016-08-11" {
description
"Resolve repeated container names in routing protocols";
reference "0.2.3";
}
revision "2016-07-08" {
description
"Updated with refactored routing protocol models";
reference "0.2.1";
}
revision "2016-03-29" {
description
"Initial revision";
reference "0.2.0";
}
revision "2015-10-18" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity NETWORK_INSTANCE_TYPE {
description
"A base identity which can be extended to indicate different
types of network instance supported by a device.";
}
identity DEFAULT_INSTANCE {
base NETWORK_INSTANCE_TYPE;
description
"A special routing instance which acts as the 'default' or
'global' routing instance for a network device.";
}
identity L3VRF {
base NETWORK_INSTANCE_TYPE;
description
"A private Layer 3 only routing instance which is formed of
one or more RIBs";
}
identity L2VSI {
base NETWORK_INSTANCE_TYPE;
description
"A private Layer 2 only switch instance which is formed of
one or more L2 forwarding tables";
}
identity L2P2P {
base NETWORK_INSTANCE_TYPE;
description
"A private Layer 2 only forwarding instance which acts as
a point to point connection between two endpoints";
}
identity L2L3 {
base NETWORK_INSTANCE_TYPE;
description
"A private Layer 2 and Layer 3 forwarding instance";
}
identity ENDPOINT_TYPE {
description
"Specification of the type of endpoint that is being associated
with a network instance";
}
identity LOCAL {
base ENDPOINT_TYPE;
description
"A local interface which is being associated with the endpoint.
In addition, the LOCAL endpoint can be used with the VXLAN
attributes to define a VXLAN tunnel end-point interface.";
}
identity REMOTE {
base ENDPOINT_TYPE;
description
"A remote interface which is being associated with the
endpoint";
}
identity LABEL_ALLOCATION_MODE {
description
"Base identity to be used to express types of label allocation
strategies to be used within a network instance";
}
identity PER_PREFIX {
base LABEL_ALLOCATION_MODE;
description
"A label is to be allocated per prefix entry in the RIB for the
network instance";
}
identity PER_NEXTHOP {
base LABEL_ALLOCATION_MODE;
description
"A label is to be allocated per nexthop entry in the RIB for
the network instance";
}
identity INSTANCE_LABEL {
base LABEL_ALLOCATION_MODE;
description
"A single label is to be used for the instance";
}
identity ENCAPSULATION {
description
"On the wire encapsulations that can be used when
differentiating network instances";
}
identity MPLS {
base ENCAPSULATION;
description
"Use MPLS labels to distinguish network instances on the wire";
}
identity VXLAN {
base ENCAPSULATION;
description
"Use VXLAN (RFC7348) VNIs to distinguish network instances on
the wire";
}
identity SIGNALLING_PROTOCOL {
description
"The signalling protocol that should be used to diseminate
entries within a forwarding instance";
}
identity LDP {
base SIGNALLING_PROTOCOL;
description
"Use LDP-based setup for signalling. Where the instance is
a point-to-point service this refers to RFC4447 ('Martini')
setup. Where the service is an L2VSI, or L2L3 instance it
refers to RFC4762 LDP-signalled VPLS instances";
}
identity BGP_VPLS {
base SIGNALLING_PROTOCOL;
description
"Use BGP-based signalling and autodiscovery for VPLS instances
as per RFC4761";
}
identity BGP_EVPN {
base SIGNALLING_PROTOCOL;
description
"Use BGP-based Ethernet VPN (RFC7432) based signalling for
the network instance";
}
// rjs note:
// this should move to openconfig-types when merged
typedef route-distinguisher {
type union {
// type 0: <2-byte administrator>:<4-byte assigned number>
// <0-65535>:<0-4294967295>
type string {
pattern
'([0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|'
+ '65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]):([0-9]|[1-9][0-9]{1,8}|'
+ '[1-3][0-9]{9}|4[01][0-9]{8}|42[0-8][0-9]{7}|429[0-3][0-9]{6}|'
+ '4294[0-8][0-9]{5}|42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|'
+ '4294967[01][0-9]{2}|42949672[0-8][0-9]|429496729[0-5])';
oc-ext:posix-pattern
'^(([0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|'
+ '65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]):([0-9]|[1-9][0-9]{1,8}|'
+ '[1-3][0-9]{9}|4[01][0-9]{8}|42[0-8][0-9]{7}|429[0-3][0-9]{6}|'
+ '4294[0-8][0-9]{5}|42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|'
+ '4294967[01][0-9]{2}|42949672[0-8][0-9]|429496729[0-5]))$';
}
// type 1: <ip-address>:<2-byte assigned number>
// <ipv4>:<0-65535>
type string {
pattern
'([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|'
+ '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}:([0-9]|'
+ '[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|'
+ '655[0-2][0-9]|6553[0-5])';
oc-ext:posix-pattern
'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|'
+ '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}:([0-9]|'
+ '[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|'
+ '655[0-2][0-9]|6553[0-5]))$';
}
// type 2: <4-byte as-number>:<2-byte assigned number>
// <0-4294967295>:<0-65535>
type string {
pattern
'([0-9]|[1-9][0-9]{1,8}|[1-3][0-9]{9}|4[01][0-9]{8}|'
+ '42[0-8][0-9]{7}|429[0-3][0-9]{6}|4294[0-8][0-9]{5}|'
+ '42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|4294967[01][0-9]{2}|'
+ '42949672[0-8][0-9]|429496729[0-5]):([0-9]|[1-9][0-9]{1,3}|'
+ '[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|'
+ '6553[0-5])';
oc-ext:posix-pattern
'^(([0-9]|[1-9][0-9]{1,8}|[1-3][0-9]{9}|4[01][0-9]{8}|'
+ '42[0-8][0-9]{7}|429[0-3][0-9]{6}|4294[0-8][0-9]{5}|'
+ '42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|4294967[01][0-9]{2}|'
+ '42949672[0-8][0-9]|429496729[0-5]):([0-9]|[1-9][0-9]{1,3}|'
+ '[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|'
+ '6553[0-5]))$';
}
}
description "A route distinguisher value";
reference "RFC4364";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
module openconfig-platform-boot-loader {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/boot-loader";
prefix "oc-boot-loader";
import openconfig-platform { prefix oc-platform; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines data related to BOOT_LOADER components in the
OpenConfig platform model.";
oc-ext:openconfig-version "0.2.0";
revision "2026-02-27" {
description
"Added uboot, linuxboot, and systemd-boot types";
reference "0.2.0";
}
revision "2025-07-10" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity BOOT_LOADER_BASE {
description
"Base identity for boot-loader types";
}
identity BOOT_LOADER_GRUB {
base BOOT_LOADER_BASE;
description
"GRUB is a boot-loader and boot manager for Linux and other Unix-based
OSes.";
reference "https://www.gnu.org/software/grub/";
}
identity BOOT_LOADER_ONIE {
base BOOT_LOADER_BASE;
description
"Open Network Install Environment (ONIE) is the combination of a boot
loader and a small operating system for network switches.
https://opencomputeproject.github.io/onie/overview/";
}
identity BOOT_LOADER_UBOOT {
base BOOT_LOADER_BASE;
description
"Das U-Boot, or the Universal Boot Loader.";
reference "https://u-boot.org/about/";
}
identity BOOT_LOADER_LINUXBOOT {
base BOOT_LOADER_BASE;
description
"LinuxBoot is the concept of using a Linux kernel and initramfs as a
bootloader.";
reference "https://www.linuxboot.org/";
}
identity BOOT_LOADER_SYSTEMD_BOOT {
base BOOT_LOADER_BASE;
description
"systemd-boot, previously called gummiboot (German for 'rubber dinghy')
and sometimes referred to as sd-boot, is an easy-to-configure UEFI boot
manager. It provides a textual menu to select the boot entry and an editor
for the kernel command line.";
reference "https://systemd.io/";
}
// typedef statements
// grouping statements
grouping boot-loader-state {
description
"Operational state data for boot-loader components";
leaf type {
type identityref {
base BOOT_LOADER_BASE;
}
description
"Specifies the type of boot-loader";
}
}
// data definition statements
// augment statements
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:boot-loader/oc-platform:state" {
description
"Adding boot-loader data to component model";
uses boot-loader-state;
}
}

View File

@@ -0,0 +1,72 @@
module openconfig-platform-cpu {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/cpu";
prefix "oc-cpu";
import openconfig-platform { prefix oc-platform; }
import openconfig-types { prefix oc-types; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines data related to FAN components in the
OpenConfig platform model.";
oc-ext:openconfig-version "0.1.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2018-01-30" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
grouping component-cpu-utilization {
description
"Per-component CPU statistics";
container utilization {
description
"Statistics representing CPU utilization of the
component.";
container state {
config false;
description
"Operational state variables relating to the utilization
of the CPU.";
uses oc-types:avg-min-max-instant-stats-pct;
}
}
}
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:cpu" {
description
"Adding CPU utilization data to component model";
uses component-cpu-utilization;
}
}

View File

@@ -0,0 +1,82 @@
module openconfig-platform-ext {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/extension";
prefix "oc-platform-ext";
import openconfig-platform { prefix oc-platform; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines optional extensions to the OpenConfig
platform model.";
oc-ext:openconfig-version "0.1.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2018-01-18" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// typedef statements
// grouping statements
grouping platform-component-ext-state {
description
"Operational state data for platform components";
leaf entity-id {
type uint32;
description
"A unique numeric identifier assigned by the system to the
component. This identifier may be used to represent the
corresponding SNMP Entity MIB identifier.";
}
}
// data definition statements
// augment statements
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:state" {
description
"Adding extension state data to components";
uses platform-component-ext-state;
}
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,152 @@
module openconfig-platform-fan {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/fan";
prefix "oc-fan";
import openconfig-platform { prefix oc-platform; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-alarm-types { prefix oc-alarm-types; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines data related to FAN components in the
OpenConfig platform model.";
oc-ext:openconfig-version "0.2.0";
revision "2025-07-16" {
description
"Add fan alarm thresholds.";
reference "0.2.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2018-01-18" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// typedef statements
// grouping statements
grouping fan-threshold-state {
description
"Grouping for all alarm thresholds for a particular severity level.";
leaf severity {
type identityref {
base oc-alarm-types:OPENCONFIG_ALARM_SEVERITY;
}
description
"The type of alarm to which the thresholds apply.";
}
leaf speed-upper {
type uint32;
units rpm;
description
"Upper fan speed alarm threshold";
}
leaf speed-lower {
type uint32;
units rpm;
description
"Lower fan speed alarm threshold";
}
}
grouping fan-threshold-top {
description
"Top-level grouping for fan speed alarm thresholds";
container thresholds {
description
"Enclosing container for fan speed alarm thresholds.";
list threshold {
key "severity";
config false;
description
"List of fan speed alarm thresholds, indexed by alarm severity.";
leaf severity {
type leafref {
path "../state/severity";
}
config false;
description
"The severity applied to the group of thresholds.
An implementation's highest severity threshold
should be mapped to OpenConfig's `CRITICAL`
severity level.";
}
container state {
config false;
description
"Operational alarm thresholds for the fan.
These thresholds should be sourced by the device manufacturer";
uses fan-threshold-state;
}
}
}
}
grouping fan-state {
description
"Operational state data for fan components";
leaf speed {
type uint32;
units rpm;
description
"Current (instantaneous) fan speed";
}
}
// data definition statements
// augment statements
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:fan/oc-platform:state" {
description
"Adding fan data to component model";
uses fan-state;
}
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:fan" {
description
"Adding fan alarm threshold";
uses fan-threshold-top;
}
}

View File

@@ -0,0 +1,157 @@
module openconfig-platform-linecard {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/linecard";
prefix "oc-linecard";
import openconfig-platform { prefix oc-platform; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines data related to LINECARD components in
the openconfig-platform model";
oc-ext:openconfig-version "1.2.0";
revision "2024-04-12" {
description
"Add install-position, install-component and deprecate location and
slot-id.";
reference "1.2.0";
}
revision "2023-02-13" {
description
"Renamed platform-utilization-top to platform-resource-utilization-top.";
reference "1.1.0";
}
revision "2022-07-28" {
description
"Remove leaf power-admin-state and use a common definition
instead.";
reference "1.0.0";
}
revision "2022-04-21" {
description
"Add platform utilization to linecard.";
reference "0.2.0";
}
revision "2020-05-10" {
description
"Remove when statement that references read-only entity from
a read-write context.";
reference "0.1.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2017-08-03" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// extension statements
// feature statements
// identity statements
// typedef statements
// grouping statements
grouping linecard-config {
description
"Configuration data for linecard components";
uses oc-platform:component-power-management;
}
grouping linecard-state {
description
"Operational state data for linecard components";
leaf slot-id {
status deprecated;
type string;
description
"Identifier for the slot or chassis position in which the
linecard is installed.
This leaf is deprecated and will be replaced by install-position
and install-component leaves in a future major revision of this
model.";
}
}
grouping linecard-top {
description
"Top-level grouping for linecard data";
container linecard {
description
"Top-level container for linecard data";
container config {
description
"Configuration data for linecards";
uses linecard-config;
}
container state {
config false;
description
"Operational state data for linecards";
uses linecard-config;
uses linecard-state;
}
uses oc-platform:platform-resource-utilization-top;
}
}
// data definition statements
// augment statements
augment "/oc-platform:components/oc-platform:component" {
description
"Adding linecard data to physical inventory. This subtree
is only valid when the type of the component is LINECARD.";
uses linecard-top;
}
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,146 @@
module openconfig-platform-psu {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/platform/psu";
prefix "oc-platform-psu";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
import openconfig-types { prefix oc-types; }
import openconfig-platform { prefix oc-platform; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines a schema for power supply components in
the OpenConfig platform model.";
oc-ext:openconfig-version "0.2.1";
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2018-01-16" {
description
"Changed admin state leaf name";
reference "0.2.0";
}
revision "2017-12-21" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// typedef statements
// grouping statements
grouping psu-config {
description
"Configuration data for power supply components";
leaf enabled {
type boolean;
default true;
description
"Adminsitrative control on the on/off state of the power
supply unit.";
}
}
grouping psu-state {
description
"Operational state data for power supply components";
// TODO(aashaikh): May need to convert some of these to
// interval statistics once decided on which leaves to include.
leaf capacity {
type oc-types:ieeefloat32;
units watts;
description
"Maximum power capacity of the power supply.";
}
leaf input-current {
type oc-types:ieeefloat32;
units amps;
description
"The input current draw of the power supply.";
}
leaf input-voltage {
type oc-types:ieeefloat32;
units volts;
description
"Input voltage to the power supply.";
}
leaf output-current {
type oc-types:ieeefloat32;
units amps;
description
"The output current supplied by the power supply.";
}
leaf output-voltage {
type oc-types:ieeefloat32;
units volts;
description
"Output voltage supplied by the power supply.";
}
leaf output-power {
type oc-types:ieeefloat32;
units watts;
description
"Output power supplied by the power supply.";
}
}
// data definition statements
// augment statements
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:power-supply/oc-platform:config" {
description
"Adds power supply data to component operational state.";
uses psu-config;
}
augment "/oc-platform:components/oc-platform:component/" +
"oc-platform:power-supply/oc-platform:state" {
description
"Adds power supply data to component operational state.";
uses psu-config;
uses psu-state;
}
// rpc statements
// notification statements
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,297 @@
module openconfig-policy-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/policy-types";
prefix "oc-pol-types";
// import some basic types
import ietf-yang-types { prefix yang; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-yang-types { prefix oc-yang; }
// meta
organization
"OpenConfig working group";
contact
"OpenConfig working group
netopenconfig@googlegroups.com";
description
"This module contains general data definitions for use in routing
policy. It can be imported by modules that contain protocol-
specific policy conditions and actions.";
oc-ext:openconfig-version "3.3.0";
revision "2024-05-14" {
description
"Add hex-string-prefixed to typedef tag-type.";
reference "3.3.0";
}
revision "2022-11-08" {
description
"Add INSTALL_PROTOCOL_TYPE local.";
reference "3.2.3";
}
revision "2022-02-11" {
description
"Add PCEP to INSTALL_PROTOCOL_TYPES identity";
reference "3.2.2";
}
revision "2021-12-10" {
description
"Add INSTALL_PROTOCOL_TYPE gRIBI.";
reference "3.2.1";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "3.1.1";
}
revision "2018-06-05" {
description
"Add PIM, IGMP to INSTALL_PROTOCOL_TYPES identity";
reference "3.1.0";
}
revision "2017-07-14" {
description
"Replace policy choice node/type with policy-result
enumeration;simplified defined set naming;removed generic
IGP actions; migrate to OpenConfig types; added mode for
prefix sets";
reference "3.0.0";
}
revision "2016-05-12" {
description
"OpenConfig public release";
reference "2.0.1";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity ATTRIBUTE_COMPARISON {
description
"base type for supported comparison operators on route
attributes";
}
identity ATTRIBUTE_EQ {
base ATTRIBUTE_COMPARISON;
description "== comparison";
}
identity ATTRIBUTE_GE {
base ATTRIBUTE_COMPARISON;
description ">= comparison";
}
identity ATTRIBUTE_LE {
base ATTRIBUTE_COMPARISON;
description "<= comparison";
}
typedef match-set-options-type {
type enumeration {
enum ANY {
description "match is true if given value matches any member
of the defined set";
}
enum ALL {
description "match is true if given value matches all
members of the defined set";
}
enum INVERT {
description "match is true if given value does not match any
member of the defined set";
}
}
default ANY;
description
"Options that govern the behavior of a match statement. The
default behavior is ANY, i.e., the given value matches any
of the members of the defined set";
}
typedef match-set-options-restricted-type {
type enumeration {
enum ANY {
description "match is true if given value matches any member
of the defined set";
}
enum INVERT {
description "match is true if given value does not match any
member of the defined set";
}
}
default ANY;
description
"Options that govern the behavior of a match statement. The
default behavior is ANY, i.e., the given value matches any
of the members of the defined set. Note this type is a
restricted version of the match-set-options-type.";
//TODO: restriction on enumerated types is only allowed in
//YANG 1.1. Until then, we will require this additional type
}
grouping attribute-compare-operators {
description "common definitions for comparison operations in
condition statements";
leaf operator {
type identityref {
base ATTRIBUTE_COMPARISON;
}
description
"type of comparison to be performed";
}
leaf value {
type uint32;
description
"value to compare with the community count";
}
}
typedef tag-type {
type union {
type uint32;
type yang:hex-string;
type oc-yang:hex-string-prefixed {
length "3..18";
}
}
description
"Type for expressing route tags on a local system, including IS-IS
and OSPF; This may be expressed as either decimal or hexidecimal
integer.";
reference
"RFC 2178 OSPF Version 2 specifies a 32 bit value
RFC 5130 A Policy Control Mechanism in IS-IS Using
Administrative Tags specifies 32 bit and 64 bit values.";
}
identity INSTALL_PROTOCOL_TYPE {
description
"Base type for routing protocols, including those which may
install prefixes into the RIB";
}
identity BGP {
base INSTALL_PROTOCOL_TYPE;
description
"BGP";
reference
"RFC 4271";
}
identity ISIS {
base INSTALL_PROTOCOL_TYPE;
description
"IS-IS";
reference
"ISO/IEC 10589";
}
identity OSPF {
base INSTALL_PROTOCOL_TYPE;
description
"OSPFv2";
reference
"RFC 2328";
}
identity OSPF3 {
base INSTALL_PROTOCOL_TYPE;
description
"OSPFv3";
reference
"RFC 5340";
}
identity STATIC {
base INSTALL_PROTOCOL_TYPE;
description
"Locally-installed static route";
}
identity DIRECTLY_CONNECTED {
base INSTALL_PROTOCOL_TYPE;
description
"A directly connected route";
}
identity LOCAL_AGGREGATE {
base INSTALL_PROTOCOL_TYPE;
description
"Locally defined aggregate route";
}
identity PIM {
base INSTALL_PROTOCOL_TYPE;
description
"Protocol Independent Multicast";
reference
"RFC 7761";
}
identity IGMP {
base INSTALL_PROTOCOL_TYPE;
description
"Internet Group Management Protocol";
reference
"RFC 3376";
}
identity GRIBI {
base INSTALL_PROTOCOL_TYPE;
description "gRPC Routing Information Base Interface";
}
identity PCEP {
base INSTALL_PROTOCOL_TYPE;
description
"Path Computation Element Communication Protocol";
reference
"RFC 5440";
}
identity LOCAL {
base INSTALL_PROTOCOL_TYPE;
description
"A local route.
Local routes define a route for the one specific IP
address configured on the router interface. They are
created in association with directly connected routes.
Local routes must end with a /32 in the case of ipv4
or /128 for ipv6.
For example, when configuring an interface with the ip
address
10.244.136.79/31
the derived DIRECTLY_CONNECTED route is
10.244.136.78/31
and the derived LOCAL route is
10.244.136.79/32.";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
module openconfig-qos-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/qos-types";
prefix "oc-qos-types";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines types and identities used in OpenConfig
models related to quality-of-service (QoS)";
oc-ext:openconfig-version "1.0.1";
revision "2026-01-06" {
description
"Fix typo in description for minimum and maximum queue thresholds.";
reference "1.0.1";
}
revision "2025-12-16" {
description
"Bump version to 1.0.0";
reference "1.0.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2016-12-16" {
description
"Fix incorrect interface-ref placement";
reference "0.2.0";
}
revision "2016-08-08" {
description
"Initial revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// extension statements
// feature statements
// identity statements
identity QOS_QUEUE_TYPE {
description
"Base identity for supported queue types, primarily
defined by their drop behavior / strategy";
}
identity DROP_TAIL {
base QOS_QUEUE_TYPE;
description
"When the queue is filled to capacity, newly arriving packets
are discarded until there is room in the queue to accept new
traffic. Packets are not differentiated, i.e., all packets
are treated identically.";
}
identity RED {
base QOS_QUEUE_TYPE;
description
"Queue management based on Random Early Detection (RED). RED
drops packets based on a drop probability that is based on the
average queue length, and settings of minimum and maximum
queue thresholds. On ECN-capable devices, packets may be
marked instead of dropped to signal congestion to the
sender.";
reference
"IETF RFC 2309 - Recommendations on Queue Management and
Congestion Avoidance in the Internet
IETF RFC 7567 - IETF Recommendations Regarding Active Queue
Management";
}
identity WRED {
base QOS_QUEUE_TYPE;
description
"Queue management based on a variant of RED in which the packet
drop probability is based on its traffic class.";
}
identity QOS_SCHEDULER_TYPE {
description
"Base identity to describe supported QoS scheduler types.";
}
identity ONE_RATE_TWO_COLOR {
base QOS_SCHEDULER_TYPE;
description
"Token bucket scheduler with a single rate (committed information
rate) and two colors (conforming and exceeding). The scheduler
behavior is governed by two parameters, the CIR which
determines the rate of token fill (bps) and the committed
burst size (depth of the token bucket in bytes).";
}
identity TWO_RATE_THREE_COLOR {
base QOS_SCHEDULER_TYPE;
description
"Token bucket scheduler with two buckets, one filled at the
committed information rate (CIR) in bps, and the second filled
at the peak information rate (PIR) in bps when the first
bucket is full. The first bucket depth is
the committed burst size (bytes), and the second is the
excess burst size (bytes). Traffic is categorized in three
colors as follows: traffic that falls within the
the CIR is conforming, traffic that is greater than the CIR
but less than the PIR is exceeding, and traffic that is
greater than PIR is violating.";
}
// typedef statements
typedef queue-behavior {
type enumeration {
enum SHAPE {
description
"Packets that exceed the CIR should be queued into a
buffer. The depth of the buffer is specified to be
max-queue-depth-bytes or max-queue-depth-packets.
Packets are subsequently scheduled from this queue
to the specified output. Only packets that overflow
the buffer have the exceed action applied to them.";
}
enum POLICE {
description
"Packets that exceed the CIR should be immediately
treated as exceeding the defined rate of the scheduler
and have the exceed action applied to them.";
}
}
description
"Type definition for different queueing behaviours that
are available to a scheduler.";
}
// grouping statements
// data definition statements
// augment statements
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,269 @@
module openconfig-qos {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/qos";
prefix "oc-qos";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// include submodules
include openconfig-qos-interfaces;
include openconfig-qos-elements;
include openconfig-qos-mem-mgmt;
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
related to network quality-of-service.";
oc-ext:openconfig-version "2.1.0";
revision "2026-03-25" {
description
"Add parameters for packet trimming configuration";
reference "2.1.0";
}
revision "2026-01-24" {
description
"Bump version to 2.0.1";
reference "2.0.1";
}
revision "2026-01-16" {
description
"Revert percentage types to uint64 with appropriate
scoping/units";
reference "2.0.0";
}
revision "2025-12-16" {
description
"Bump version to 1.0.0";
reference "1.0.0";
}
revision "2023-10-13" {
description
"Fix revision statement date";
reference "0.11.2";
}
revision "2023-10-08" {
description
"Clarification on WRED weight in case it is not present";
reference "0.11.1";
}
revision "2023-09-15" {
description
"Add support for ECN counters";
reference "0.11.0";
}
revision "2023-07-26" {
description
"Add buffer management parameters in time unts (microseconds).
Make profiles reusable across LAGs and PHY of different speed";
reference "0.10.0";
}
revision "2023-04-25" {
description
"Clarify interface-ref usage.";
reference "0.9.1";
}
revision "2023-04-17" {
description
"Add support for relative RED min-threshold and max-threshold values.";
reference "0.9.0";
}
revision "2023-02-17" {
description
"Add queue identifier.";
reference "0.8.0";
}
revision "2023-02-08" {
description
"Remove incorrect output placement of interface-ref";
reference "0.7.0";
}
revision "2023-01-28" {
description
"Split groupings in interfaces for better leaf reuse.";
reference "0.6.1";
}
revision "2022-09-13" {
description
"Add queue octet drop counter.";
reference "0.6.0";
}
revision "2021-08-28" {
description
"Revision using latest revision of openconfig-qos-mem-mgmt submodule.";
reference "0.5.0";
}
revision "2021-06-28" {
description
"Revision to include buffer-allocation-profile-q-config
parameters in openconfig-qos-mem-mgmt submodule.";
reference "0.4.0";
}
revision "2021-04-28" {
description
"Revision updating buffer management and queue management
configuration.";
reference "0.3.0";
}
revision "2019-11-28" {
description
"Fix xpaths in when statements";
reference "0.2.3";
}
revision "2019-08-20" {
description
"Fix typo in classifiers container name";
reference "0.2.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2016-12-16" {
description
"Fix incorrect interface-ref placement";
reference "0.2.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// grouping statements
grouping qos-config {
description
"Configuration data for global QoS";
}
grouping qos-state {
description
"Operational state data for global QoS";
}
grouping qos-packet-trim-top {
description
"Top-level grouping for packet trimming.";
container packet-trim {
description
"Container for switch level packet trimming
parameters.";
container config {
description
"Configuration data for switch level packet
trimming parameters.";
uses packet-trim-config;
}
container state {
description
"Operational state data for switch level packet
trimming parameters.";
config false;
uses packet-trim-config;
}
}
}
grouping packet-trim-config {
description
"Top-level grouping for switch level packet
trimming parameters";
leaf symmetric-dscp {
type uint8;
description
"The DSCP value for the notification packet
(sometimes called a 'symmetric packet') sent back
to the source when a packet is trimmed.";
}
leaf fabric-priority {
type uint8;
description
"Traffic class used to transmit trimmed
packets.";
}
}
grouping qos-top {
description
"Top-level grouping for QoS model";
container qos {
description
"Top-level container for QoS data";
container config {
description
"Configuration data for global QoS";
uses qos-config;
}
container state {
description
"Operational state data for global QoS";
config false;
uses qos-config;
uses qos-state;
}
uses qos-interfaces-top;
uses qos-classifier-top;
uses qos-forwarding-group-top;
uses qos-queue-top;
uses qos-scheduler-top;
uses qos-buffer-profile-top;
uses qos-queue-mgmt-profile-top;
uses qos-packet-trim-top;
}
}
// data definition statements
uses qos-top;
// augment statements
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,833 @@
module openconfig-relay-agent {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/relay-agent";
prefix "oc-relay";
// import some basic types
import ietf-inet-types { prefix inet; }
import ietf-yang-types { prefix yang; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module describes a model for configuration and operational
state related to relay agents typically used for DHCP and BOOTP
packets. The supports both DHCP and DHCPv6 and device-wide and
per-interface settings.";
oc-ext:openconfig-version "0.1.2";
revision "2023-02-06" {
description
"Clarify usage of interface-ref.";
reference "0.1.2";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.1.1";
}
revision "2016-05-16" {
description
"Initial public release";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// grouping statements
grouping agent-information-ipv4-common-config {
description
"Common configuration data for DHCP relay option";
leaf enable {
type boolean;
default false;
description
"Enable sending the DHCP option for Relay Agent information
-- option 82.";
reference
"RFC 3046 - DHCP Relay Agent Information Option";
}
}
grouping agent-information-ipv4-common-state {
description
"Common operational state data for DHCP relay option";
}
grouping agent-information-ipv4-global-top {
description
"Top-level grouping for agent information data at global level";
container agent-information-option {
description
"Top-level container for relay agent information option
data";
container config {
description
"Configuration data for the relay agent information
option";
uses agent-information-ipv4-common-config;
}
container state {
config false;
description
"Operational state data for agent information at global
level";
uses agent-information-ipv4-common-config;
uses agent-information-ipv4-common-state;
}
}
}
grouping agent-information-ipv4-interface-config {
description
"Configuration data for DCHP relay option on interfaces";
leaf circuit-id {
type string;
description
"Encodes an agent-local identifier of the circuit from which
a DHCP client-to-server packet was received. It is intended
for use by agents in relaying DHCP responses back to the
proper circuit. The circuit id is an opaque value";
reference
"RFC 3046 - DHCP Relay Agent Information Option";
}
leaf remote-id {
type string;
description
"Provides a mechanism to identify the remote host end of
the circuit. The remote-id should be thought of as an
opaque value, but must be globally unique.";
reference
"RFC 3046 - DHCP Relay Agent Information Option";
}
}
grouping agent-information-ipv4-interface-state {
description
"Operational state data for DHCP relay option on interfaces";
leaf sent-circuit-id {
type string;
description
"Reports the circuit-id sent by the system to the DHCP
server.";
}
leaf sent-remote-id {
type string;
description
"Reports the remote-id value sent by the system to the DHCP
server";
}
}
grouping agent-information-ipv4-interface-top {
description
"Top-level grouping for relay agent information option data";
container agent-information-option {
description
"Top-level container for relay agent information option
data";
container config {
description
"Configuration data for the relay agent information
option";
uses agent-information-ipv4-common-config;
uses agent-information-ipv4-interface-config;
}
container state {
config false;
description
"Operational state data ";
uses agent-information-ipv4-common-config;
uses agent-information-ipv4-interface-config;
uses agent-information-ipv4-common-state;
uses agent-information-ipv4-interface-state;
}
}
}
grouping agent-options-ipv6-common-config {
description
"Configuration data for DHCPv6 options";
leaf enable-interface-id {
type boolean;
default false;
description
"Enables DHCPv6 OPTION_INTERFACE_ID (18) to identify the
interface on which the client message was received.";
reference
"IETF RFC 3315 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6)";
}
leaf enable-remote-id {
type boolean;
default false;
description
"Sets DHCPv6 OPTION_REMOTE_ID (37). This option is the
DHCPv6 equivalent for the IPv4 (DHCPv4) Relay Agent Option's
Remote-ID suboption as specified in RFC 3046. The remote-id
field may be used to encode a user name, remote IP address,
interface/port identifier, etc.";
reference
"IETF RFC 4649 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6) Relay Agent Remote-ID Option";
}
}
grouping agent-options-ipv6-common-state {
description
"Operational state data for DHCPv6 options";
}
grouping agent-options-ipv6-interface-config {
description
"Configuration data for DHCPv6 options";
leaf interface-id {
type string;
description
"Sets DHCPv6 OPTION_INTERFACE_ID (18) to identify the
interface on which the client message was received.";
reference
"IETF RFC 3315 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6)";
}
leaf remote-id {
type string;
description
"Sets DHCPv6 OPTION_REMOTE_ID (37). This option is the
DHCPv6 equivalent for the IPv4 (DHCPv4) Relay Agent Option's
Remote-ID suboption as specified in RFC 3046. The remote-id
field may be used to encode a user name, remote IP address,
interface/port identifier, etc.";
reference
"IETF RFC 4649 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6) Relay Agent Remote-ID Option";
}
}
grouping agent-options-ipv6-interface-state {
description
"Operational state data for DHCPv6 options";
leaf sent-interface-id {
type string;
description
"Reflects the DHCPv6 OPTION_INTERFACE_ID (18) sent to the
server by the system.";
reference
"IETF RFC 3315 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6)";
}
leaf sent-remote-id {
type string;
description
"Reflects the DHCPv6 OPTION_REMOTE_ID (37) sent to the
server by the system.";
reference
"IETF RFC 4649 - Dynamic Host Configuration Protocol for
IPv6 (DHCPv6) Relay Agent Remote-ID Option";
}
}
grouping agent-options-ipv6-global-top {
description
"Top-level grouping for DHCPv6 options on interfaces";
container options {
description
"Top-level container for DHCPv6 agent options on interfaces";
container config {
description
"Configuration data ";
uses agent-options-ipv6-common-config;
}
container state {
config false;
description
"Operational state data for DHCPv6 agent option on an
interface";
uses agent-options-ipv6-common-config;
uses agent-options-ipv6-common-state;
}
}
}
grouping agent-options-ipv6-interface-top {
description
"Top-level grouping for DHCPv6 options on interfaces";
container options {
description
"Top-level container for DHCPv6 agent options on interfaces";
container config {
description
"Configuration data ";
uses agent-options-ipv6-common-config;
uses agent-options-ipv6-interface-config;
}
container state {
config false;
description
"Operational state data for DHCPv6 agent option on an
interface";
uses agent-options-ipv6-common-config;
uses agent-options-ipv6-interface-config;
uses agent-options-ipv6-common-state;
uses agent-options-ipv6-interface-state;
}
}
}
grouping relay-agent-common-config {
description
"Configuration data for global level relay agent options,
common across address families";
leaf enable-relay-agent {
type boolean;
default false;
description
"Enables DHCP/BOOTP relay agent on all interfaces";
}
}
grouping relay-agent-common-state {
description
"Operational state data for global level relay agent, common
across address families";
}
grouping relay-agent-ipv4-config {
description
"Configuration data for DHCPv4 relay agents";
uses relay-agent-common-config;
}
grouping relay-agent-ipv4-state {
description
"Configuration data for DHCPv4 relay agents";
uses relay-agent-common-state;
}
grouping relay-agent-ipv4-top {
description
"Top-level grouping for global relay agent data";
container dhcp {
description
"Top-level container for global relay agent data";
container config {
description
"Configuration data for global DHCPv4";
uses relay-agent-ipv4-config;
}
container state {
config false;
description
"Operational state data global DHCPv4";
uses relay-agent-ipv4-config;
uses relay-agent-ipv4-state;
}
uses agent-information-ipv4-global-top;
uses relay-agent-ipv4-interfaces-top;
}
}
grouping relay-agent-ipv6-config {
description
"Configuration data for DHCPv6 relay agents";
uses relay-agent-common-config;
}
grouping relay-agent-ipv6-state {
description
"Configuration data for DHCPv6 relay agents";
uses relay-agent-common-state;
}
grouping relay-agent-ipv6-top {
description
"Top-level grouping for global relay agent data";
container dhcpv6 {
description
"Top-level container for global relay agent data";
container config {
description
"Configuration data for global DHCPv6";
uses relay-agent-ipv6-config;
}
container state {
config false;
description
"Operational state data global DHCPv6";
uses relay-agent-ipv6-config;
uses relay-agent-ipv6-state;
}
uses agent-options-ipv6-global-top;
uses relay-agent-ipv6-interfaces-top;
}
}
grouping relay-agent-common-stats {
description
"Common DHCP / BOOTP message statistics for
DHCPv4 and DHCPv6";
leaf total-dropped {
type yang:counter64;
description
"Total number of DHCP packets dropped by the relay agent";
}
leaf invalid-opcode {
type yang:counter64;
description
"Number of DHCP packets dropped due to an invalid opcode";
}
leaf invalid-options {
type yang:counter64;
description
"Number of DHCP packets dropped due to an invalid option";
}
}
grouping relay-agent-ipv4-stats {
description
"DHCPv4 relay agent message statistics";
leaf bootrequest-received {
type yang:counter64;
description
"BOOTREQUEST messages received by the relay agent";
}
leaf dhcp-decline-received {
type yang:counter64;
description
"DHCP DECLINE messages received by the relay agent";
}
leaf dhcp-discover-received {
type yang:counter64;
description
"DHCP DISCOVER messages received by the relay agent";
}
leaf dhcp-inform-received {
type yang:counter64;
description
"DHCP INFORM messages received by the relay agent";
}
leaf dhcp-release-received {
type yang:counter64;
description
"DHCP RELEASE messages received by the relay agent";
}
leaf dhcp-request-received {
type yang:counter64;
description
"DHCP REQUEST messages received by the relay agent";
}
leaf bootrequest-sent {
type yang:counter64;
description
"BOOTREQUEST messages forwarded by the relay agent";
}
leaf bootreply-sent {
type yang:counter64;
description
"BOOTREPLY messages forwarded by the relay agent";
}
leaf dhcp-offer-sent {
type yang:counter64;
description
"DHCP OFFER messages sent by the relay agent";
}
leaf dhcp-ack-sent {
type yang:counter64;
description
"DHCP ACK messages sent by the relay agent";
}
leaf dhcp-nack-sent {
type yang:counter64;
description
"DHCP NACK messages sent by the relay agent";
}
}
grouping relay-agent-ipv6-stats {
description
"DHCPv4 relay agent message statistics";
leaf dhcpv6-solicit-received {
type yang:counter64;
description
"Number of DHCPv6 SOLICIT messages received from clients
by the relay agent";
}
leaf dhcpv6-decline-received {
type yang:counter64;
description
"Number of DHCPv6 DECLINE messages received from
clients by the relay agent";
}
leaf dhcpv6-request-received {
type yang:counter64;
description
"Number of DHCPv6 request messages received from clients
by the relay agent";
}
leaf dhcpv6-release-received {
type yang:counter64;
description
"Number of DHCPv6 release messages received from clients
by the relay agent";
}
leaf dhcpv6-confirm-received {
type yang:counter64;
description
"Number of DHCPv6 confirm messages received from clients
by the relay agent";
}
leaf dhcpv6-rebind-received {
type yang:counter64;
description
"Number of DHCPv6 rebind messages received from clients
by the relay agent";
}
leaf dhcpv6-info-request-received {
type yang:counter64;
description
"Number of DHCPv6 information requests messages received from
clients by the relay agent";
}
leaf dhcpv6-relay-reply-received {
type yang:counter64;
description
"Number of DHCPv6 relay reply messages received from servers
by the relay agent";
}
leaf dhcpv6-adverstise-sent {
type yang:counter64;
description
"Number of DHCPv6 adverstise messages sent to clients by
the relay agent";
}
leaf dhcpv6-reply-sent {
type yang:counter64;
description
"Number of DHCPv6 reply messages sent to clients by
the relay agent";
}
leaf dhcpv6-reconfigure-sent {
type yang:counter64;
description
"Number of DHCPv6 reconfigure messages sent to clients by
the relay agent";
}
leaf dhcpv6-relay-forw-sent {
type yang:counter64;
description
"Number of DHCPv6 relay-forward messages sent to servers
by the relay agent";
}
}
grouping relay-agent-ipv4-interfaces-config {
description
"Configuration data for interfaces enabled for relaying";
leaf id {
type oc-if:interface-id;
description
"Name of the interface on which relay agent is active";
}
leaf enable {
type boolean;
description
"Enables the relay agent on the referenced interface.
At least one helper address should also be configured
for forwarding requested.";
}
leaf-list helper-address {
type inet:ip-address;
description
"List of IPv4 or IPv6 addresses of DHCP servers to which the
relay agent should forward DHCPv4 requests. The relay agent is
expected to forward DHCPv4/BOOTP requests to all listed
server addresses when DHCPv4 relaying is enabled globally, or
on the interface.";
}
}
grouping relay-agent-ipv4-interfaces-state {
description
"Operational state data for interfaces enabled for relaying";
container counters {
description
"Counters and statistics for relay agent operation.";
uses relay-agent-common-stats;
uses relay-agent-ipv4-stats;
}
}
grouping relay-agent-ipv4-interfaces-top {
description
"Top-level grouping for DHCPv4 relays on interfaces";
container interfaces {
description
"Enclosing container for the list of interface references.";
list interface {
key "id";
description
"List of interfaces on which the relay agent is
configured.
The interface referenced is based on the interface and
subinterface leaves within the interface-ref container -
which reference an entry in the /interfaces/interface list -
and should not rely on the value of the list key.";
leaf id {
type leafref {
path "../config/id";
}
description
"Reference to the interface list key";
}
container config {
description
"Configuration data for relay agent interfaces.";
uses relay-agent-ipv4-interfaces-config;
}
container state {
config false;
description
"Operational state data for relay agent interfaces.";
uses relay-agent-ipv4-interfaces-config;
uses relay-agent-ipv4-interfaces-state;
}
uses oc-if:interface-ref;
uses agent-information-ipv4-interface-top;
}
}
}
grouping relay-agent-ipv6-interfaces-config {
description
"Configuration data for interfaces enabled for relaying";
leaf id {
type oc-if:interface-id;
description
"Name of the interface on which relay agent is active";
}
leaf enable {
type boolean;
description
"Enables the relay agent on the referenced interface.
At least one helper address should also be configured
for forwarding requested.";
}
leaf-list helper-address {
type inet:ipv6-address;
description
"List of IPv6 addresses of DHCP servers to which the
relay agent should forward DHCPv6 requests. The relay agent
is expected to forward DHCPv4/BOOTP requests to all listed
server addresses when DHCPv6 relaying is enabled globally, or
on the interface.";
}
}
grouping relay-agent-ipv6-interfaces-state {
description
"Operational state data for interfaces enabled for relaying";
container counters {
description
"Counters and statistics for relay agent operation.";
uses relay-agent-common-stats;
uses relay-agent-ipv6-stats;
}
}
grouping relay-agent-ipv6-interfaces-top {
description
"Top-level grouping for DHCPv4 relays on interfaces";
container interfaces {
description
"Enclosing container for the list of interface references.";
list interface {
key "id";
description
"List of interfaces on which the relay agent is
configured.
The interface referenced is based on the interface and
subinterface leaves within the interface-ref container -
which reference an entry in the /interfaces/interface list -
and should not rely on the value of the list key.";
leaf id {
type leafref {
path "../config/id";
}
description
"Reference to the interface list key";
}
container config {
description
"Configuration data for relay agent interfaces.";
uses relay-agent-ipv6-interfaces-config;
}
container state {
config false;
description
"Operational state data for relay agent interfaces.";
uses relay-agent-ipv6-interfaces-config;
uses relay-agent-ipv6-interfaces-state;
}
uses oc-if:interface-ref;
uses agent-options-ipv6-interface-top;
}
}
}
grouping relay-agent-top {
description
"Top-level container for relay agent configuration and opstate
data.";
container relay-agent {
description
"Top level container for relay-agent configuration and
operational state data";
uses relay-agent-ipv4-top;
uses relay-agent-ipv6-top;
}
}
// data definition statements
uses relay-agent-top;
// augment statements
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,265 @@
module openconfig-spanning-tree-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/spanning-tree/types";
prefix "oc-stp-types";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines types related to the
spanning-tree protocol model.";
oc-ext:openconfig-version "0.4.1";
revision "2021-06-16" {
description
"Remove trailing whitespace";
reference "0.4.1";
}
revision "2021-02-19" {
description
"Correct range for bridge priority type.";
reference "0.4.0";
}
revision "2019-11-28" {
description
"Correct revision statement date for v0.3.0";
reference "0.3.1";
}
revision "2019-07-10" {
description
"Remove the time-since-last-topology-change leaf and
replace it with a timestamp of last topology change.";
reference "0.3.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2017-07-14" {
description
"Migrated to OpenConfig types; fixed missing applied state
in rapid-pvst";
reference "0.2.0";
}
revision "2016-10-03" {
description
"Initial public revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
identity STP_PROTOCOL {
description
"base identity for support spanning tree protocol";
}
identity RSTP {
base STP_PROTOCOL;
description
"Rapid Spanning Tree Protocol";
reference "IEEE 802.1D 17";
}
identity MSTP {
base STP_PROTOCOL;
description
"Multiple Spanning Tree Protocol";
reference "IEEE 802.1Q 13";
}
identity RAPID_PVST {
base STP_PROTOCOL;
description
"Rapid Per Vlan Spanning Tree Protocol";
}
identity STP_PORT_STATE {
description
"base identity for the different Spanning Tree Protocol port
states";
reference
"IEEE 802.1D 7.4 Port States and the active topology";
}
identity DISABLED {
base STP_PORT_STATE;
description
"A port that is manually isolated from the network";
}
identity LISTENING {
base STP_PORT_STATE;
description
"Processing BPDUs and building active toplogy";
}
identity LEARNING {
base STP_PORT_STATE;
description
"Building bridging tables; no forwarding of data";
}
identity BLOCKING {
base STP_PORT_STATE;
description
"A port that would cause a loop if it were sending data,
so it is only receiving BPDUs, untill a topology change
removes the possibliity of a loop";
}
identity FORWARDING {
base STP_PORT_STATE;
description
"Sending and receiving data, normal operation";
}
identity STP_EDGE_PORT {
description
"base identity for the different edge port modes";
reference
"IEEE 802.1D 17.13.1";
}
identity EDGE_ENABLE {
base STP_EDGE_PORT;
description
"Enable edge port for the bridge port";
}
identity EDGE_DISABLE {
base STP_EDGE_PORT;
description
"Disable edge port for the bridge port";
}
identity EDGE_AUTO {
base STP_EDGE_PORT;
description
"Enable edge port autodetction for the bridge port";
}
identity STP_PORT_ROLE {
description
"Base identity for the different Spanning Tree Protocol port
roles";
reference
"IEEE 802.1D 17.7 Port Role assignments";
}
identity ROOT {
base STP_PORT_ROLE;
description
"The port that receives the best BPDU on a bridge is the
root port";
}
identity DESIGNATED {
base STP_PORT_ROLE;
description
"A port is designated if it can send the best BPDU on the
segment to which it is connected.";
}
identity ALTERNATE {
base STP_PORT_ROLE;
description
"An alternate port receives more useful BPDUs from another
bridge and is a port blocked";
}
identity BACKUP {
base STP_PORT_ROLE;
description
"A backup port receives more useful BPDUs from the same
bridge it is on and is a port blocked";
}
// typedef statements
typedef stp-bridge-priority-type {
type uint16 {
range 0..61440;
}
default 32768;
description
"The manageable component of the Bridge Identifier. The bridge priority
determines which bridge is selected as the root bridge (lowest priority
value is selected as root). Valid values are in the range 0 through
61440, in steps of 4096.";
reference "IEEE 802.1D 17.13.7 Bridge Identifier Priority";
}
typedef stp-port-priority-type {
type uint8 {
range 1..240;
}
description
"The manageable component of the Port Identifier,
also known as the Port Priority";
reference
"IEEE 802.1D 17.13.10 Port Identifier Priority";
}
typedef stp-guard-type {
type enumeration {
enum ROOT {
description
"Enable root guard";
}
enum LOOP {
description
"Enable loop guard";
}
enum NONE {
description
"disable guard";
}
}
description
"Type definition for the different STP guard for the switch port";
reference "IEEE 802.1D 17.2";
}
typedef stp-link-type {
type enumeration {
enum P2P {
description
"Point-to-Point link";
}
enum SHARED {
description
"Shared link";
}
}
description
"Type definition for the different link types";
reference "IEEE 802.1D 17.2";
}
}

View File

@@ -0,0 +1,842 @@
module openconfig-spanning-tree {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/spanning-tree";
prefix "oc-stp";
import openconfig-spanning-tree-types { prefix oc-stp-types; }
import openconfig-interfaces { prefix oc-if; }
import openconfig-types { prefix oc-types; }
import openconfig-vlan-types { prefix oc-vlan-types; }
import openconfig-yang-types { prefix oc-yang; }
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
for the spanning tree protocol.";
oc-ext:openconfig-version "0.3.1";
revision "2019-11-28" {
description
"Correct revision statement date for v0.3.0";
reference "0.3.1";
}
revision "2019-07-10" {
description
"Remove the time-since-last-topology-change leaf and
replace it with a timestamp of last topology change.";
reference "0.3.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.2.1";
}
revision "2017-07-14" {
description
"Migrated to OpenConfig types; fixed missing applied state
in rapid-pvst";
reference "0.2.0";
}
revision "2016-10-03" {
description
"Initial public revision";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// grouping statements
grouping stp-interfaces-state {
description
"Grouping of STP operational data for bridge port";
leaf port-num {
type uint16;
description
"The port number of the bridge port";
reference "RFC4188 BRIDGE-MIB dot1dStpPort";
}
leaf role {
type identityref {
base oc-stp-types:STP_PORT_ROLE;
}
description
"The current role of the bridge port";
reference
"IEEE8021-MSTP-MIB ieee8021MstpPortRole";
}
leaf port-state {
type identityref {
base oc-stp-types:STP_PORT_STATE;
}
description
"The current state of the bridge port";
reference "RFC4188 BRIDGE-MIB dot1dStpPortState";
}
leaf designated-root-priority {
type oc-stp-types:stp-bridge-priority-type;
description
"The bridge priority of the bridge recorded as the
root in the configuration BPDUs transmitted by the designated
bridge for the segment to which the port is attached";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedRoot";
}
leaf designated-root-address {
type oc-yang:mac-address;
description
"The bridge address of the bridge recorded as the
root in the configuration BPDUs transmitted by the designated
bridge for the segment to which the port is attached";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedRoot";
}
leaf designated-cost {
type uint32;
description
"The path cost of the Designated Port of the
segment connected to this port";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedCost";
}
leaf designated-bridge-priority {
type oc-stp-types:stp-bridge-priority-type;
description
"The bridge priority of the bridge that this port considers
to be the designated bridge for this port's segment.";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedBridge";
}
leaf designated-bridge-address {
type oc-yang:mac-address;
description
"The bridge address of the bridge that this port considers
to be the designated bridge for this port's segment.";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedBridge";
}
leaf designated-port-priority {
type oc-stp-types:stp-port-priority-type;
description
"The Port priority of the port on the Designated
Bridge for this port's segment, two octet string";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedPort";
}
leaf designated-port-num {
type uint16;
description
"The Port number of the port on the Designated
Bridge for this port's segment, two octet string";
reference "RFC4188 BRIDGE-MIB dot1dStpPortDesignatedPort";
}
leaf forward-transisitions {
type oc-yang:counter64;
description
"The number of times this port has transitioned
from the Learning state to the Forwarding state";
reference "RFC4188 BRIDGE-MIB dot1dStpPortForwardTransitions";
}
container counters {
description
"The BPDU packet transmition statistics";
leaf bpdu-sent {
type oc-yang:counter64;
description
"The number of BPDU packet sent";
}
leaf bpdu-received {
type oc-yang:counter64;
description
"The number of BPDU packet received";
}
}
}
grouping stp-interfaces-config {
description
"Grouping of STP configuration for bridge port";
leaf name {
type oc-if:base-interface-ref;
description
"Reference to the STP ethernet interface";
}
leaf cost {
type uint32 {
range 1..200000000;
}
description
"The port's contribution, when it is the Root Port,
to the Root Path Cost for the Bridge";
reference
"IEEE 802.1D 17.13.11 PortPathCost";
}
leaf port-priority {
type oc-stp-types:stp-port-priority-type;
description
"The manageable component of the Port Identifier,
also known as the Port Priority";
reference
"IEEE 802.1D 17.13.10 Port Identifier Priority";
}
}
grouping stp-interfaces-top {
description
"Grouping of STP configuration and operation data for
bridge port";
container interfaces {
description
"Enclosing container for the list of interface references";
list interface {
key "name";
description
"List of interfaces on which STP is enable";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for STP on each interface";
uses stp-interfaces-config;
}
container state {
config false;
description
"Operational state data for STP on each interface";
uses stp-interfaces-config;
uses stp-interfaces-state;
}
}
}
}
grouping bridge-priority-config {
description
"Grouping for bridge priority";
leaf bridge-priority {
type oc-stp-types:stp-bridge-priority-type;
description
"The manageable component of the Bridge Identifier";
reference
"IEEE 802.1D 17.13.7 Bridge Identifier Priority";
}
}
grouping stp-common-state {
description
"Grouping for common STP operation data";
leaf bridge-address {
type oc-yang:mac-address;
description
"A unique 48-bit Universally Administered MAC Address
assigned to the bridge";
reference
"IEEE 802.1D 7.12.5 Unique identification of a bridge";
}
leaf designated-root-priority {
type oc-stp-types:stp-bridge-priority-type;
description
"The bridge priority of the root of the spanning
tree, as determined by the Spanning Tree Protocol,
as executed by this node";
reference
"RFC4188 BRIDGE-MIB dot1dStpDesignatedRoot";
}
leaf designated-root-address {
type oc-yang:mac-address;
description
"The bridge address of the root of the spanning
tree, as determined by the Spanning Tree Protocol,
as executed by this node";
reference
"RFC4188 BRIDGE-MIB dot1dStpDesignatedRoot";
}
leaf root-port {
type uint16;
description
"The port number of the port which offers the lowest
cost path from this bridge to the root bridge";
reference
"RFC4188 BRIDGE-MIB dot1dStpRootPort";
}
leaf root-cost {
type uint32;
description
"The cost of the path to the root as seen from this bridge";
reference
"RFC4188 BRIDGE-MIB dot1dStpRootCost";
}
leaf hold-time {
type uint8;
description
"This time value determines the interval length
during which no more than two Configuration bridge
PDUs shall be transmitted by this node";
reference
"RFC4188 BRIDGE-MIB dot1dStpHoldTime";
}
leaf topology-changes {
type oc-yang:counter64;
description
"The total number of topology changes detected by
this bridge since the management entity was last
reset or initialized";
reference
"RFC4188 BRIDGE-MIB dot1dStpTopChanges";
}
leaf last-topology-change {
type oc-types:timeticks64;
description
"The time at which the last topology change was
detected by the bridge entity. The value is
expressed relative to the Unix Epoch (Jan 1, 1970
00:00:00 UTC).";
}
}
grouping stp-timer-config {
description
"Grouping for common STP parameters";
leaf hello-time {
type uint8 {
range 1..10;
}
units "seconds";
description
"The interval between periodic transmissions of
configuration messages by designated ports";
reference
"IEEE 802.1D 17.13.6 Bridge Hello Time";
}
leaf max-age {
type uint8 {
range 6..40;
}
units "seconds";
description
"The maximum age of the information transmitted by the
bridge when it is the root bridge";
reference
"IEEE 802.1D 17.13.8 Bridge Max Age";
}
leaf forwarding-delay {
type uint8 {
range 4..30;
}
units "seconds";
description
"The delay used by STP bridges to transition root and
designated ports to forwarding";
reference
"IEEE 802.1D 17.13.5 Bridge Forward Delay";
}
leaf hold-count {
type uint8 {
range 1..10;
}
default 6;
description
"the maximum number of BPDUs per second that the
switch can send from an interface";
reference
"IEEE 802.1D 17.13.12 Transmit Hold Count";
}
}
grouping stp-rapid-pvst-config {
description
"Configuration parameters relating to rapid PVST";
leaf vlan-id {
type oc-vlan-types:vlan-id;
description
"Interface VLAN ID";
}
}
grouping stp-rapid-pvst-top {
description
"Top grouping for rapid per vlan spanning tree configuration
and operation data";
list vlan {
key "vlan-id";
description
"List of the vlans";
leaf vlan-id {
type leafref {
path "../config/vlan-id";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for each vlan";
uses stp-rapid-pvst-config;
uses stp-timer-config;
uses bridge-priority-config;
}
container state {
config false;
description
"Operational data for each vlan";
uses stp-rapid-pvst-config;
uses stp-timer-config;
uses bridge-priority-config;
uses stp-common-state;
}
uses stp-interfaces-top;
}
}
grouping mst-instance-config {
description
"Grouping for mstp instance configuration";
leaf mst-id {
type uint16 {
range "1..4094";
}
description
"In an MSTP Bridge, an MSTID, i.e., a value used to identify
a spanning tree (or MST) instance.";
reference
"IEEE8021-TC-MIB IEEE8021MstIdentifier";
}
leaf-list vlan {
type union {
type oc-vlan-types:vlan-id;
type oc-vlan-types:vlan-range;
}
description
"list of vlans mapped to the MST instance";
}
}
grouping mst-instance-top {
description
"Top level grouping for mstp instances";
list mst-instance {
key "mst-id";
description
"List of the mstp instances";
leaf mst-id {
type leafref {
path "../config/mst-id";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for MSTP instance";
uses mst-instance-config;
uses bridge-priority-config;
}
container state {
config false;
description
"Operational data for MSTP instance";
uses mst-instance-config;
uses bridge-priority-config;
uses stp-common-state;
}
uses stp-interfaces-top;
}
}
grouping mstp-config {
description
"Grouping for MSTP configuration data";
leaf name {
type string {
length "1..32";
}
description
"The Configuration Name in the MST Configuration Identifier";
reference
"IEEE 802.1Q 13.8 MST Configuration Identifier (MCID)";
}
leaf revision {
type uint32;
description
"The Revision Level in the MST Configuration Identifier";
reference
"IEEE 802.1Q 13.8 MST Configuration Identifier";
}
leaf max-hop {
type uint8 {
range 1..255;
}
description
"The max hop determines the number of bridges in an MST
region that a BPDU can traverse before it is discarded";
reference
"IEEE 802.1Q 13.26.4 BridgeTimes";
}
uses stp-timer-config;
}
grouping mstp-state {
description
"Operational state data for MSTP";
}
grouping stp-mstp-top {
description
"Top grouping for MSTP configuration and operation data";
container config {
description
"Configuration data for MSTP";
uses mstp-config;
}
container state {
config false;
description
"Operational data for MSTP";
uses mstp-config;
uses mstp-state;
}
container mst-instances {
description
"Configuration and operation data for MSTP instances";
uses mst-instance-top;
}
}
grouping stp-rstp-top {
description
"Top grouping for RSTP configuration and operation data";
container config {
description
"Configuration data for RSTP";
uses stp-timer-config;
uses bridge-priority-config;
}
container state {
config false;
description
"Operational state data for RSTP";
uses stp-timer-config;
uses bridge-priority-config;
uses stp-common-state;
}
uses stp-interfaces-top;
}
grouping stp-interface-common-config {
description
"Configuration data for interface specific STP features";
leaf name {
type oc-if:base-interface-ref;
description
"Reference to the STP Ethernet interface";
}
leaf edge-port {
type identityref {
base oc-stp-types:STP_EDGE_PORT;
}
description
"Configure the edge port state";
}
leaf link-type {
type oc-stp-types:stp-link-type;
description
"specifies the interface's link type";
}
leaf guard {
type oc-stp-types:stp-guard-type;
description
"Enable root guard or loop guard";
}
uses stp-bpdu-config;
}
grouping stp-interface-common-state {
description
"Operational state data for STP on interfaces";
}
grouping stp-interface-common-top {
description
"Top-level grouping for interface specific STP features";
list interface {
key "name";
description
"List of interfaces on which STP is enable";
leaf name {
type leafref {
path "../config/name";
}
description
"Reference to the list key";
}
container config {
description
"Configuration data for STP on each bridge port";
uses stp-interface-common-config;
}
container state {
config false;
description
"Operational state data for STP on each bridge port";
uses stp-interface-common-config;
uses stp-interface-common-state;
}
}
}
grouping stp-bpdu-config {
description
"Grouping for STP BPDU configuration";
leaf bpdu-guard {
type boolean;
description
"Enable edge port BPDU guard";
}
leaf bpdu-filter {
type boolean;
description
"Enable edge port BPDU filter";
}
}
grouping stp-global-config {
description
"Global spanning tree configuration";
leaf-list enabled-protocol {
type identityref {
base oc-stp-types:STP_PROTOCOL;
}
description
"List of the spanning tree protocols enabled on the
device";
}
leaf bridge-assurance {
type boolean;
description
"Enable bridge assurance to protect against unidirectional
link failure";
}
leaf etherchannel-misconfig-guard {
type boolean;
description
"EtherChannel guard detects a misconfigured EtherChannel
when interfaces on the switch are configured as an
EtherChannel while interfaces on the other device are not
or when not all the interfaces on the other device are in
the same EtherChannel.";
}
leaf bpduguard-timeout-recovery {
type uint8;
units "seconds";
description
"Amount of time, in seconds, the interface receiving BPDUs
is disabled. Once the timeout expires, the interface is
brought back into service.";
}
leaf loop-guard {
type boolean;
description
"The loop guard default setting for the bridge";
}
uses stp-bpdu-config;
}
grouping stp-global-state {
description
"Global operational state for STP";
}
grouping stp-global-base {
description
"Grouping for global spanning tree data";
container config {
description
"Global spanning tree configuration";
uses stp-global-config;
}
container state {
config false;
description
"Global spanning tree state";
uses stp-global-config;
uses stp-global-state;
}
}
grouping stp-top {
description
"Top-level grouping for spanning-tree model";
container stp {
description
"Top-level container for spanning tree configuration and
state data";
container global {
description
"Global configuration and state data";
uses stp-global-base;
}
container rstp {
description
"Rapid Spanning-tree protocol configuration and operation
data";
uses stp-rstp-top;
}
container mstp {
description
"Multi Spanning-tree protocol configuration and operation
data";
uses stp-mstp-top;
}
container rapid-pvst {
description
"Rapid per vlan Spanning-tree protocol configuration and
operational data";
uses stp-rapid-pvst-top;
}
container interfaces {
description
"Enclosing container for the list of interface references";
uses stp-interface-common-top;
}
}
}
// data definition statements
uses stp-top;
}

View File

@@ -0,0 +1,374 @@
module openconfig-system-controlplane {
yang-version "1";
namespace "http://openconfig.net/yang/system-controlplane";
prefix "oc-sys-copp";
import openconfig-extensions {
prefix oc-ext;
}
import openconfig-system {
prefix oc-sys;
}
import openconfig-acl {
prefix oc-acl;
}
import openconfig-qos {
prefix oc-qos;
}
organization
"OpenConfig working group";
contact
"www.openconfig.net";
description
"This module adds configuration and operational state relating to
policies for traffic destined to the system's control-plane.
Particularly, it allows for mechanisms to:
- apply an ACL that forwards or drops traffic towards the control-plane.
- classify traffic that is destined to the control-plane according to
a QoS classifier.
- schedule traffic that has been forwarded towards the control-plane,
to allow for policies such as rate limits to be applied.
The configured policies apply generically to all control-planes that
exist within the system, and should be mapped to the internal interfaces
via which packets are forwarded to control-plane modules.
When a packet is received at an input interface - it is classified into a
forwarding group which drains to a specific queue. If this input mapping
is sufficient, the CPU-facing interface uses the specified scheduler
to determine how to drain queues. If more granular remapping is required
(e.g., to classify control-plane traffic more granularly), a user specifies
an alternate classifier that is used to reclassify traffic into
a new set of forwarding-groups (and hence queues) that can subsequently
be scheduled by the specified scheduler.
The specified control-plane ACL is applied to traffic received by the
control-plane of the system.";
oc-ext:openconfig-version "0.2.0";
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
revision "2023-03-03" {
description
"Add missing state container to ACL.";
reference "0.2.0";
}
revision "2021-08-02" {
description
"Initial revision.";
reference "0.1.0";
}
grouping system-controlplane-top {
description
"Top-level structural grouping for control-plane traffic policies.";
container control-plane-traffic {
description
"Policies and configuration relating to the traffic destined towards
the system control-plane.";
container ingress {
description
"Control-plane traffic parameters relating to ingress traffic.
This refers to traffic that is being received by the system's
control plane from external-to-the-controlplane sources.";
uses system-controlplane-acl-common-top;
container qos {
description
"Configuration and operational state relating to QoS policies
that are applied to control-plane traffic.";
container classifier {
description
"Configuration and state parameters relating to the QoS
classifier that is applied to control plane traffic. A QoS
classifier - defined in /qos/classifiers specifies how traffic
is mapped to QoS queues. The classifier specified in this
container and corresponding state allows for traffic towards
the control-plane to be classified.";
container config {
description
"Configuration parameters relating to QoS classifier
applied to match control plane traffic.";
uses system-controlplane-qos-classifier-config;
}
container state {
config false;
description
"Operational state parameters relating to the QoS classifier
applied to match control plane traffic.";
uses system-controlplane-qos-classifier-config;
}
container terms {
config false;
description
"Operational state and counters relating to the classifier
applied to control-plane traffic.";
list term {
key "id";
description
"A list of the terms within the QoS classifier being
applied for control-plane traffic. Each term has
corresponding operational state parameters.";
leaf id {
type leafref {
path "../state/id";
}
description
"Reference to the identifier for the classifier term.";
}
container state {
config false;
description
"Operational state parameters relating to a term within
the applied control-plane classifier";
uses system-controlplane-qos-classifier-term-state;
uses oc-qos:qos-interface-classifier-match-counters-state;
}
}
}
}
container scheduler-policy {
description
"Configuration and operational state relating to the QoS
scheduler policy that is applied to control-plane traffic.
The scheduler policy determines how traffic, classified by
the specified control-plane classifier is rate-limited towards
the control-plane. The scheduler policy is defined in
/qos/scheduler-policies.";
container config {
description
"Configuration parameters relating to the scheduler-policy
that is to be applied control-plane traffic.";
uses system-controlplane-qos-scheduler-config;
}
container state {
config false;
description
"Operational state parameters relating to the scheduler policy
applied to the control-plane traffic.";
uses system-controlplane-qos-scheduler-config;
}
container scheduler-statistics {
config false;
description
"Operational state and counters relating to the
scheduler-policy applied to control plane traffic.";
list scheduler {
key "sequence";
description
"List of the schedulers that are part of the scheduler-policy
specified.";
leaf sequence {
type leafref {
path "../state/sequence";
}
description
"Reference to the sequence ID for the scheduler.";
}
container state {
description
"Operational state parameters relating to the scheduler
policy.";
uses system-controlplane-qos-scheduler-seq-state;
}
}
}
}
}
}
container egress {
description
"Control-plane traffic parameters relating to egress traffic.
This refers to traffic that is sent by the system's control
plane to external-to-the-controlplane destinations.";
uses system-controlplane-acl-common-top;
}
}
}
grouping system-controlplane-acl-common-top {
description
"Common structural grouping for ACL configuration and state for
control plane traffic.";
container acl {
description
"Configuration and operational state parameters relating to the
access control list applied to control-plane traffic.";
list acl-set {
key "set-name type";
description
"List of the ACL that is to be applied in the specific ingress
or egress context. The key of the list specifies the type of
traffic to be matched, along with a reference to an ACL
configured in the OpenConfig ACL model within the /acl hierarchy.";
leaf set-name {
type leafref {
path "../config/set-name";
}
description
"Reference to the name of the ACL-set to be applied.";
}
leaf type {
type leafref {
path "../config/type";
}
description
"Reference to the type of the ACL-set to be applied.";
}
container config {
description
"Configuration parameters relating to the ACL to be applied.";
uses system-controlplane-common-acl-config;
}
container state {
config false;
description
"Operational state parameters relating to the ACL to be applied.";
uses system-controlplane-common-acl-config;
}
uses oc-acl:interface-acl-entries-top;
}
}
}
grouping system-controlplane-common-acl-config {
description
"Grouping for ACL parameters relating to the system control-plane.";
leaf set-name {
type leafref {
path "/oc-acl:acl/oc-acl:acl-sets/oc-acl:acl-set/" +
"oc-acl:config/oc-acl:name";
}
description
"Reference to the ACL to be applied to traffic
in the specified context (ingress or egress).";
}
leaf type {
type leafref {
path "/oc-acl:acl/oc-acl:acl-sets/oc-acl:acl-set" +
"[oc-acl:name=current()/../set-name]" +
"/oc-acl:config/oc-acl:type";
}
description
"Reference to the ACL set type applied to traffic
in the specified context (ingress or egress).";
}
}
grouping system-controlplane-qos-classifier-config {
description
"Grouping for configuration parameters relating to QoS classifiers
for the system control-plane.";
leaf name {
type leafref {
path "/oc-qos:qos/oc-qos:classifiers/oc-qos:classifier/" +
"oc-qos:config/oc-qos:name";
}
description
"Reference to a classifier that is used to classify traffic
destined to the control-plane of the system.
This classifier determines how packets that match each terms
are classified into forwarding groups, and subsequently into
queues to be forwarded.";
}
}
grouping system-controlplane-qos-classifier-term-state {
description
"Grouping for control-plane traffic specific leaves required for
each configuration term.";
leaf id {
// Current location /system/control-plane/ingress/qos/classifier/
// terms/term/state/id
type leafref {
path "/oc-qos:qos/oc-qos:classifiers/" +
"oc-qos:classifier[oc-qos:name=current()/../../../../config/name]" +
"/oc-qos:terms/oc-qos:term/oc-qos:config/oc-qos:id";
}
description
"Reference to a term identifier within the configured control-plane
classifier.";
}
}
grouping system-controlplane-qos-scheduler-config {
description
"Grouping for configuration parameters relating to the QoS scheduler
policy for control-plane traffic.";
leaf name {
type leafref {
path "/oc-qos:qos/oc-qos:scheduler-policies/oc-qos:scheduler-policy/" +
"oc-qos:config/oc-qos:name";
}
description
"Reference to a scheduler policy that determines rate limits, or
shaping of packets towards the control-plane.";
}
}
grouping system-controlplane-qos-scheduler-seq-state {
description
"Grouping for operational state parameters relating to indivual
schedulers within the applied scheduler policy.";
leaf sequence {
type leafref {
path "/oc-qos:qos/oc-qos:scheduler-policies/oc-qos:scheduler-policy" +
"[oc-qos:name=current()/../../../../config/name]" +
"/oc-qos:schedulers/oc-qos:scheduler/oc-qos:config/" +
"oc-qos:sequence";
}
description
"Reference to a scheduler within the configured scheduler policy.";
}
uses oc-qos:qos-scheduler-common-state;
}
augment "/oc-sys:system" {
description
"Add control-plane configuration and state to the system model.";
uses system-controlplane-top;
}
}

View File

@@ -0,0 +1,673 @@
module openconfig-system-logging {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/system/logging";
prefix "oc-log";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
import openconfig-inet-types { prefix oc-inet; }
import openconfig-network-instance { prefix oc-ni; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
for common logging facilities on network systems.";
oc-ext:openconfig-version "0.7.0";
revision "2024-08-20" {
description
"Adding tls support for syslog.";
reference "0.7.0";
}
revision "2023-07-20" {
description
"adding VTY and local files as logging destinations";
reference "0.6.0";
}
revision "2023-05-04" {
description
"removing LOG_DESTINATION_TYPE identities";
reference "0.5.0";
}
revision "2022-12-29" {
description
"Add network-instance for remote logging servers";
reference "0.4.1";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.3.1";
}
revision "2017-09-18" {
description
"Updated to use OpenConfig types modules";
reference "0.3.0";
}
revision "2017-07-06" {
description
"Move to oc-inet types, add IETF attribution, add RADIUS
counters, changed password leaf names to indicate hashed";
reference "0.2.0";
}
revision "2017-01-29" {
description
"Initial public release";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// extension statements
// feature statements
// identity statements
identity SYSLOG_FACILITY {
description
"Base identity for Syslog message facilities.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity ALL {
base SYSLOG_FACILITY;
description
"All supported facilities";
}
identity KERNEL {
base SYSLOG_FACILITY;
description
"The facility for kernel messages";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity USER {
base SYSLOG_FACILITY;
description
"The facility for user-level messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity MAIL {
base SYSLOG_FACILITY;
description
"The facility for the mail system.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity SYSTEM_DAEMON {
base SYSLOG_FACILITY;
description
"The facility for the system daemons.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity AUTH {
base SYSLOG_FACILITY;
description
"The facility for security/authorization messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity SYSLOG {
base SYSLOG_FACILITY;
description
"The facility for messages generated internally by syslogd
facility.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity AUTHPRIV {
base SYSLOG_FACILITY;
description
"The facility for privileged security/authorization messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity NTP {
base SYSLOG_FACILITY;
description
"The facility for the NTP subsystem.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity AUDIT {
base SYSLOG_FACILITY;
description
"The facility for log audit messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity CONSOLE {
base SYSLOG_FACILITY;
description
"The facility for log alert messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL0 {
base SYSLOG_FACILITY;
description
"The facility for local use 0 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL1 {
base SYSLOG_FACILITY;
description
"The facility for local use 1 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL2 {
base SYSLOG_FACILITY;
description
"The facility for local use 2 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL3 {
base SYSLOG_FACILITY;
description
"The facility for local use 3 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL4 {
base SYSLOG_FACILITY;
description
"The facility for local use 4 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL5 {
base SYSLOG_FACILITY;
description
"The facility for local use 5 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL6 {
base SYSLOG_FACILITY;
description
"The facility for local use 6 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
identity LOCAL7 {
base SYSLOG_FACILITY;
description
"The facility for local use 7 messages.";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
// typedef statements
typedef syslog-severity {
type enumeration {
enum EMERGENCY {
description
"Emergency: system is unusable (0)";
}
enum ALERT {
description
"Alert: action must be taken immediately (1)";
}
enum CRITICAL {
description
"Critical: critical conditions (2)";
}
enum ERROR {
description
"Error: error conditions (3)";
}
enum WARNING {
description
"Warning: warning conditions (4)";
}
enum NOTICE {
description
"Notice: normal but significant condition(5)";
}
enum INFORMATIONAL {
description
"Informational: informational messages (6)";
}
enum DEBUG {
description
"Debug: debug-level messages (7)";
}
}
description
"Syslog message severities";
reference
"IETF RFC 5424 - The Syslog Protocol";
}
// grouping statements
grouping logging-selectors-config {
description
"Configuration data for logging selectors";
leaf facility {
type identityref {
base SYSLOG_FACILITY;
}
description
"Specifies the facility, or class of messages to log";
}
leaf severity {
type syslog-severity;
description
"Specifies that only messages of the given severity (or
greater severity) for the corresonding facility are logged";
}
}
grouping logging-selectors-state {
description
"Operational state data for logging selectors";
}
grouping logging-selectors-top {
description
"Top-level grouping for the logging selector list";
container selectors {
description
"Enclosing container ";
list selector {
key "facility severity";
description
"List of selectors for log messages";
leaf facility {
type leafref {
path "../config/facility";
}
description
"Reference to facility list key";
}
leaf severity {
type leafref {
path "../config/severity";
}
description
"Reference to severity list key";
}
container config {
description
"Configuration data ";
uses logging-selectors-config;
}
container state {
config false;
description
"Operational state data ";
uses logging-selectors-config;
uses logging-selectors-state;
}
}
}
}
grouping logging-console-config {
description
"Configuration data for console and vty logging";
}
grouping logging-console-state {
description
"Operational state data for console and vty logging";
}
grouping logging-console-top {
description
"Top-level grouping for console logging data";
container console {
description
"Top-level container for data related to console-based
logging";
container config {
description
"Configuration data for console logging";
uses logging-console-config;
}
container state {
config false;
description
"Operational state data for console logging";
uses logging-console-config;
uses logging-console-state;
}
uses logging-selectors-top;
}
}
grouping logging-remote-config {
description
"Configuration data for remote log servers";
leaf host {
type oc-inet:host;
description
"IP address or hostname of the remote log server";
}
leaf source-address {
type oc-inet:ip-address;
description
"Source IP address for packets to the log server";
}
leaf network-instance {
type oc-ni:network-instance-ref;
description
"The network instance used to reach the log server. If no
instance is specified, DEFAULT_INSTANCE is used.";
}
leaf remote-port {
type oc-inet:port-number;
default 514;
description
"Sets the destination port number for syslog UDP messages to
the server. The default for syslog is 514.";
}
leaf transport-security {
type boolean;
description
"Indicates if syslog transport layer security (TLS) is enabled.";
}
leaf tls-profile-id {
type string;
description
"The ID of this syslog client's TLS profile. TLS profiles are managed
using the gNSI Certz service or other certificate management service
provided by the system.";
reference
"https://github.com/openconfig/gnsi/tree/main/certz";
}
}
grouping logging-remote-state {
description
"Operational state data for remote log servers";
}
grouping logging-remote-top {
description
"Top-level grouping for remote log servers";
container remote-servers {
description
"Enclosing container for the list of remote log
servers";
list remote-server {
key "host";
description
"List of remote log servers";
leaf host {
type leafref {
path "../config/host";
}
description
"Reference to the host list key";
}
container config {
description
"Configuration data for remote log servers";
uses logging-remote-config;
}
container state {
config false;
description
"Operational state data for remote log servers";
uses logging-remote-config;
uses logging-remote-state;
}
uses logging-selectors-top;
}
}
}
grouping logging-file-config {
description
"Configuration data for logfile";
leaf filename-prefix {
type string {
length 0..255;
}
description
"A name used for the file. It is expected that an
implementation may append timestamp, serial-number or
other identifier to the filename.";
}
leaf path {
type string {
length 0..255;
}
description
"The fully specified path of the folder where the
logfile is stored. The path is implementation specific
and may include attributes such as a drive identifier.";
}
leaf rotate {
type uint32;
default 0;
description
"Used for logfile rotation.
Log files are rotated the number of times defined by
this leaf.
The default value of 1 indicates that there will be one
rotation file and one active file. A 0 value indicates
old versions are removed rather than rotated.";
}
leaf max-size {
type uint32;
default 1000;
description
"Used for logfile rotation.
Maximum size in Bytes, logfile may grow to. When logfile
reach this size it triggers log rotation. The log file need to
be save, closed, and new file open or future log storage.
If needed oldest logfile of same prefix shall be deleted to";
}
leaf max-open-time {
type uint32;
default 1440;
description
"Used for logfile rotation.
Maximum time, in minutes, the logfile can be open. When expires,
it triggers log rotation.
Actions are same ans when log file reaches its max-size.
it need to be closed, save, and new file open or future log
storage. If needed oldest logfile of same prefix shall be
deleted to ";
}
}
grouping logging-file-state {
description
"Operational state data for logfile";
leaf open-logfile {
type string{
length 0..511;
}
description
"the currently active/open filename prepended by folder path
and including suffix appended to filename-prefix by system";
}
}
grouping logging-files-top {
description
"Top-level grouping for local log files";
container files {
description
"Enclosing container for the list of log files";
list file {
key "path filename-prefix";
description
"List of logfiles";
leaf filename-prefix {
type leafref {
path "../config/filename-prefix";
}
description
"Reference to the logfiles list key";
}
leaf path {
type leafref {
path "../config/path";
}
description
"Reference to the logfiles list key";
}
container config {
description
"Configuration data for logfile";
uses logging-file-config;
}
container state {
config false;
description
"Operational state data for logfile servers";
uses logging-file-config;
uses logging-file-state;
}
uses logging-selectors-top;
}
}
}
grouping logging-vty-top {
description
"Top-level grouping for vty logging data";
container vty {
description
"Top-level container for data related to vty-based
logging (active sessions of ssh, telnet, etc )";
container config {
description
"Configuration data for vty logging";
uses logging-console-config;
}
container state {
config false;
description
"Operational state data for console logging";
uses logging-console-config;
uses logging-console-state;
}
uses logging-selectors-top;
}
}
grouping logging-top {
description
"Top-level grouping for logging data";
container logging {
description
"Top-level container for data related to logging / syslog";
uses logging-console-top;
uses logging-remote-top;
uses logging-files-top;
uses logging-vty-top;
}
}
// data definition statements
// augment statements
}

View File

@@ -0,0 +1,261 @@
module openconfig-system-terminal {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/system/terminal";
prefix "oc-sys-term";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
www.openconfig.net";
description
"This module defines configuration and operational state data
related to remote terminal services such as ssh and telnet.";
oc-ext:openconfig-version "0.4.0";
revision "2025-11-10" {
description
"Add a host-certificate leaf.";
reference "0.4.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "0.3.1";
}
revision "2017-09-18" {
description
"Updated to use OpenConfig types modules";
reference "0.3.0";
}
revision "2017-07-06" {
description
"Move to oc-inet types, add IETF attribution, add RADIUS
counters, changed password leaf names to indicate hashed";
reference "0.2.0";
}
revision "2017-01-29" {
description
"Initial public release";
reference "0.1.0";
}
// OpenConfig specific extensions for module metadata.
oc-ext:regexp-posix;
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// identity statements
// typedef statements
// grouping statements
grouping system-terminal-common-config {
description
"Common configuration data for terminal services";
leaf timeout {
type uint16;
units seconds;
description
"Set the idle timeout in seconds on terminal connections to
the system for the protocol.";
}
leaf rate-limit {
type uint16;
units "conn/min";
description
"Set a limit on the number of connection attempts per
minute to the system for the protocol.";
}
leaf session-limit {
type uint16;
description
"Set a limit on the number of simultaneous active terminal
sessions to the system for the protocol (e.g., ssh,
telnet, ...) ";
}
}
grouping system-terminal-common-state {
description
"Common operational state data for terminal services";
}
grouping system-terminal-common-top {
description
"Top-level grouping for common terminal service data";
container terminal-servers {
description
"Top-level container for terminal services";
container config {
description
"Configuration data for terminal services";
uses system-terminal-common-config;
}
container state {
config false;
description
"Operational state data ";
uses system-terminal-common-config;
uses system-terminal-common-state;
}
}
}
grouping system-ssh-server-config {
description
"Configuration data for system ssh configuration";
leaf enable {
type boolean;
default true;
description
"Enables the ssh server. The ssh server is enabled by
default.";
}
leaf protocol-version {
type enumeration {
enum V2 {
description
"Use SSH v2 only";
}
enum V1 {
description
"Use SSH v1 only";
}
enum V1_V2 {
description
"Use either SSH v1 or v2";
}
}
default V2;
description
"Set the protocol version for SSH connections to the system";
}
leaf host-certificate {
type string;
description
"SSH Host Certificate string. This is the full content of an openssh host certificate";
}
uses system-terminal-common-config;
}
grouping system-ssh-server-state {
description
"Operational state data for ssh server";
}
grouping system-ssh-server-top {
description
"Top-level grouping for ssh server data";
container ssh-server {
description
"Top-level container for ssh server";
container config {
description
"Configuration data for the system ssh server";
uses system-ssh-server-config;
}
container state {
config false;
description
"Operational state data for the system ssh server";
uses system-ssh-server-config;
uses system-ssh-server-state;
}
}
}
grouping system-telnet-server-config {
description
"Configuration data for telnet server";
leaf enable {
type boolean;
default false;
description
"Enables the telnet server. Telnet is disabled by
default";
}
uses system-terminal-common-config;
}
grouping system-telnet-server-state {
description
"Operational state data for telnet server";
}
grouping system-telnet-server-top {
description
"Top-level grouping for telnet server ";
container telnet-server {
description
"Top-level container for telnet terminal servers";
container config {
description
"Configuration data for telnet";
uses system-telnet-server-config;
}
container state {
config false;
description
"Operational state data for telnet";
uses system-telnet-server-config;
uses system-telnet-server-state;
}
}
}
// data definition statements
// augment statements
// rpc statements
// notification statements
}

View File

@@ -0,0 +1,115 @@
module openconfig-system-utilization {
yang-version "1";
namespace "http://openconfig.net/yang/system-utilization";
prefix "oc-sys-util";
import openconfig-extensions { prefix oc-ext; }
import openconfig-system { prefix oc-sys; }
import openconfig-platform { prefix oc-platform; }
organization
"OpenConfig working group";
contact
"www.openconfig.net";
description
"This module adds configuration and operational state for
system wide resource utilization thresholds.";
oc-ext:openconfig-version "0.1.0";
revision "2023-02-13" {
description
"Add system wide utilization thresholds.";
reference
"0.1.0";
}
grouping system-resource-utilization-config {
description
"Configuration data for resource utilization. The configuration added here should
apply across all of the components that matches the respective resource.
/components/component/*/utilization/resources/resource/name";
leaf name {
type string;
description
"Resource name within the system.";
}
uses oc-platform:resource-utilization-threshold-common;
}
grouping system-resource-utilization-state {
description
"State data for resource utilization.";
leaf-list active-component-list {
type leafref {
path "/oc-platform:components/oc-platform:component/oc-platform:config/oc-platform:name";
}
description
"List of references to each component which has this resource.";
}
}
grouping system-resource-utilization-top {
description
"Top level grouping for system wide configuration of resources for
all components.";
container "utilization" {
description
"System wide resource utilization configuration.";
container "resources" {
description
"Enclosing container for the resources in the entire system. The system
resource names should be aggregated from the following collections:
* /components/component/chassis/utilization/resources/resource
* /components/component/integrate-circuit/utilization/resources/resource
* /components/component/linecard/utilization/resources/resource.";
list "resource" {
key "name";
description
"The list of all resources across all platform components keyed by
resource name.";
leaf name {
type leafref {
path "../config/name";
}
description
"References the resource name.";
}
container "config" {
description
"Configuration data for resource utilization.";
uses system-resource-utilization-config;
}
container "state" {
config false;
description
"Operational state data for resource utilization.";
uses system-resource-utilization-config;
uses system-resource-utilization-state;
}
}
}
}
}
augment "/oc-sys:system" {
description
"Add system resource utilization.";
uses system-resource-utilization-top;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
module openconfig-vlan-types {
yang-version "1";
// namespace
namespace "http://openconfig.net/yang/vlan-types";
prefix "oc-vlan-types";
// import some basic types
import openconfig-extensions { prefix oc-ext; }
// meta
organization "OpenConfig working group";
contact
"OpenConfig working group
netopenconfig@googlegroups.com";
description
"This module defines configuration and state variables for VLANs,
in addition to VLAN parameters associated with interfaces";
oc-ext:openconfig-version "3.2.0";
revision "2022-05-24" {
description
"Remove module extension oc-ext:regexp-posix by making pattern regexes
conform to RFC6020/7950.
Types impacted:
- vlan-range
- qinq-id
- qinq-id-range";
reference "3.2.0";
}
revision "2020-06-30" {
description
"Add OpenConfig POSIX pattern extensions.";
reference "3.1.1";
}
revision "2019-01-31" {
description
"Add TPID_ANY wildcard match and a QinQ list type.";
reference "3.1.0";
}
revision "2018-11-21" {
description
"Add OpenConfig module metadata extensions.";
reference "3.0.1";
}
revision "2018-02-14" {
description
"Fix bug with name of 802.1ad identity.";
reference "3.0.0";
}
revision "2017-07-14" {
description
"Move top-level vlan data to network-instance; Update
identities to comply to style guide; fixed pattern
quoting; corrected trunk vlan types; added TPID config to
base interface.";
reference "2.0.0";
}
revision "2016-05-26" {
description
"OpenConfig public release";
reference "1.0.2";
}
// OpenConfig specific extensions for module metadata.
oc-ext:catalog-organization "openconfig";
oc-ext:origin "openconfig";
// extension statements
// feature statements
// identity statements
identity TPID_TYPES {
description
"Base identity for TPID values that can be matched or that override
the VLAN ethertype value";
}
identity TPID_0X8100 {
base TPID_TYPES;
description
"Default TPID value for 802.1q single-tagged VLANs.";
}
identity TPID_0X88A8 {
base TPID_TYPES;
description
"TPID value for 802.1ad provider bridging, QinQ or
stacked VLANs.";
}
identity TPID_0X9100 {
base TPID_TYPES;
description
"Alternate TPID value.";
}
identity TPID_0X9200 {
base TPID_TYPES;
description
"Alternate TPID value.";
}
identity TPID_ANY {
base TPID_TYPES;
description
"A wildcard that matches any of the generally used TPID values
for singly- or multiply-tagged VLANs. Equivalent to matching
any of TPID_0X8100, TPID_0X88A8, TPID_0X9100 and TPID_0x9200.
This value is only applicable where the TPID of a packet is
being matched.";
}
// typedef statements
// TODO: typedefs should be defined in a vlan-types.yang file.
typedef vlan-id {
type uint16 {
range 1..4094;
}
description
"Type definition representing a single-tagged VLAN";
}
typedef vlan-range {
type string {
// range specified as [lower]..[upper]
pattern '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|' +
'40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{1,2}|' +
'[1-9])';
oc-ext:posix-pattern '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|' +
'40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{1,2}|' +
'[1-9])$';
}
description
"Type definition representing a range of single-tagged
VLANs. A range is specified as x..y where x and y are
valid VLAN IDs (1 <= vlan-id <= 4094). The range is
assumed to be inclusive, such that any VLAN-ID matching
x <= VLAN-ID <= y falls within the range.";
}
typedef qinq-id {
type string {
pattern
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.' +
'((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])|\*)';
oc-ext:posix-pattern
'^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.' +
'((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])|\*)$';
}
description
"Type definition representing a single double-tagged/QinQ VLAN
identifier. The format of a QinQ VLAN-ID is x.y where X is the
'outer' VLAN identifier, and y is the 'inner' VLAN identifier.
Both x and y must be valid VLAN IDs (1 <= vlan-id <= 4094)
with the exception that y may be equal to a wildcard (*). In
cases where y is set to the wildcard, this represents all inner
VLAN identifiers where the outer VLAN identifier is equal to
x.";
}
typedef qinq-id-range {
type union {
type string {
// match cases where the range is specified as x..y.z
pattern
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.' +
'((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])|\*)';
oc-ext:posix-pattern
'^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.' +
'((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])|\*)$';
}
type string {
// match cases where the range is specified as x.y..z
pattern
'(\*|(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9]))\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])';
oc-ext:posix-pattern
'^(\*|(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9]))\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])\.\.' +
'(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
'[1-9][0-9]{1,2}|[1-9])$';
}
}
description
"A type definition representing a range of double-tagged/QinQ
VLAN identifiers. The format of a QinQ VLAN-ID range can be
specified in two formats. Where the range is outer VLAN IDs
the range is specified as x..y.z. In this case outer VLAN
identifiers meeting the criteria x <= outer-vlan-id <= y are
accepted if and only if the inner VLAN-ID is equal to y - or
any inner-tag if the wildcard is specified. Alternatively the
ange can be specified as x.y..z. In this case only VLANs with an
outer-vlan-id qual to x are accepted (x may again be the
wildcard). Inner VLANs are accepted if they meet the inequality
y <= inner-vlan-id <= z.";
}
typedef vlan-mode-type {
type enumeration {
enum ACCESS {
description "Access mode VLAN interface (No 802.1q header)";
}
enum TRUNK {
description "Trunk mode VLAN interface";
}
}
description
"VLAN interface mode (trunk or access)";
}
typedef vlan-ref {
type union {
type vlan-id;
type string;
// TODO: string should be changed to leafref to reference
// an existing VLAN. this is not allowed in YANG 1.0 but
// is expected to be in YANG 1.1.
// type leafref {
// path "vlan:vlans/vlan:vlan/vlan:config/vlan:name";
// }
}
description
"Reference to a VLAN by name or id";
}
typedef vlan-stack-action {
type enumeration {
enum PUSH {
description
"Push a VLAN onto the VLAN stack.";
}
enum POP {
description
"Pop a VLAN from the VLAN stack.";
}
enum SWAP {
description
"Swap the VLAN at the top of the VLAN stack.";
}
// TODO: add push-push, pop-pop, push-swap etc
}
description
"Operations that can be performed on a VLAN stack.";
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,327 @@
import json
import os
import re
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter
def style_header(cell):
cell.font = Font(name="Arial", bold=True, color="FFFFFF", size=10)
cell.fill = PatternFill("solid", start_color="2E4057")
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="medium", color="FFFFFF"),
right=Side(style="thin", color="FFFFFF")
)
def style_cell(cell, even):
cell.font = Font(name="Arial", size=9)
cell.fill = PatternFill("solid", start_color="EAF0FB" if even else "FFFFFF")
cell.alignment = Alignment(vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="thin", color="D0D0D0"),
right=Side(style="thin", color="D0D0D0")
)
def style_ok(cell, even):
style_cell(cell, even)
cell.font = Font(name="Arial", size=9, color="1E7E34", bold=True)
def style_err(cell, even):
style_cell(cell, even)
cell.font = Font(name="Arial", size=9, color="C0392B", bold=True)
def style_warn(cell, even):
style_cell(cell, even)
cell.font = Font(name="Arial", size=9, color="E67E22", bold=True)
def to_excel_value(val):
if val is None:
return None
if isinstance(val, (int, float, str, bool)):
return val
if isinstance(val, list):
parts = []
for item in val:
if isinstance(item, dict):
parts.append(" | ".join(f"{k}: {v}" for k, v in item.items()))
else:
parts.append(str(item))
return " ; ".join(parts)
if isinstance(val, dict):
return " | ".join(f"{k}: {v}" for k, v in val.items())
return str(val)
def get_irf_mode(data, intf_name):
for comp in data.get("openconfig-platform:components", {}).get("component", []):
if not comp.get("name", "").startswith("Switch"):
continue
for prop in comp.get("properties", {}).get("property", []):
if prop.get("name", "").startswith("irf-config-port"):
value = prop.get("state", {}).get("value", "")
if intf_name in value:
return "IRF"
return None
def get_component_for_interface(data, intf_name):
for comp in data.get("openconfig-platform:components", {}).get("component", []):
if comp.get("name") == intf_name:
return comp
return None
def parse_counters_cleared(description):
if not description:
return None
m = re.search(r'Counters Cleared:\s*([^,;"]+)', description, re.IGNORECASE)
return m.group(1).strip() if m else None
def has_errors(counter_value):
if counter_value is None:
return False
if isinstance(counter_value, (int, float)):
return counter_value > 0
if isinstance(counter_value, list):
return any(item.get("count", 0) > 0 for item in counter_value if isinstance(item, dict))
return False
def extract_error_details(counter_value):
"""Retourne un dict {type: count} depuis un compteur d'erreurs."""
if counter_value is None:
return {}
if isinstance(counter_value, (int, float)):
return {"errors": counter_value}
if isinstance(counter_value, list):
return {item["type"]: item.get("count", 0) for item in counter_value if isinstance(item, dict) and "type" in item}
return {}
def build_stp_map(data):
stp_map = {}
rstp = data.get("openconfig-spanning-tree:stp", {}).get("rstp", {})
for intf in rstp.get("interfaces", {}).get("interface", []):
name = intf.get("name", "")
state = intf.get("state", {}).get("port-state")
if name:
stp_map[name] = state
return stp_map
BASE_COUNTER_KEYS = [
"in-octets", "in-pkts", "in-unicast-pkts", "in-broadcast-pkts",
"in-multicast-pkts", "in-pauses-pkts", "in-drops",
"out-octets", "out-pkts", "out-unicast-pkts", "out-broadcast-pkts",
"out-multicast-pkts", "out-pauses-pkts", "out-drops",
]
def parse_file(data):
switch_name = data.get("switch-device", {}).get("name", "")
interfaces = data.get("openconfig-interfaces:interfaces", {}).get("interface", [])
stp_map = build_stp_map(data)
rows = []
for intf in interfaces:
name = intf.get("name", "")
state = intf.get("state", {})
eth_state = intf.get("ethernet", {}).get("state", {})
sv_state = intf.get("ethernet", {}).get("switched-vlan", {}).get("state", {})
counters = state.get("counters", {}) or {}
desc = state.get("description", "")
admin_status = state.get("admin-status")
oper_status = state.get("oper-status")
speed_kbps = eth_state.get("port-speed")
speed_mbps = int(speed_kbps / 1_000) if speed_kbps else None
duplex = eth_state.get("duplex-mode")
flow_ctrl = eth_state.get("enable-flow-control")
pvid = sv_state.get("native-vlan") if sv_state and sv_state.get("interface-mode") == "ACCESS" else None
mtu = state.get("mtu")
counters_cleared = parse_counters_cleared(desc)
mode = sv_state.get("interface-mode") if sv_state else None
if not mode:
mode = get_irf_mode(data, name)
stp_state = stp_map.get(name)
comp = get_component_for_interface(data, name)
media = form_factor = rx = tx = None
if comp:
comp_state = comp.get("state", {})
media = comp_state.get("connector-type")
if media and "LC" in str(media).upper():
form_factor = comp_state.get("form-factor")
transceiver = comp.get("oc-transceiver:transceiver", {}).get("state", {})
rx = transceiver.get("input-power", {}).get("instant") if transceiver.get("input-power") else None
tx = transceiver.get("output-power", {}).get("instant") if transceiver.get("output-power") else None
base_counters = {f"ctr_{k.replace('-','_')}": counters.get(k) for k in BASE_COUNTER_KEYS}
in_error_details = extract_error_details(counters.get("in-errors"))
out_error_details = extract_error_details(counters.get("out-errors"))
in_err_flag = has_errors(counters.get("in-errors"))
out_err_flag = has_errors(counters.get("out-errors"))
rows.append({
"switch_name": switch_name,
"interface": name,
"admin_status": admin_status,
"oper_status": oper_status,
"speed_mbps": speed_mbps,
"duplex": duplex,
"flow_control": flow_ctrl,
"pvid": pvid,
"media": media,
"type": form_factor,
"rx": rx,
"tx": tx,
"status": mode,
"stp_state": stp_state,
"mtu": mtu,
"counters_cleared": counters_cleared,
**base_counters,
"in_error_details": in_error_details,
"out_error_details": out_error_details,
"in_errors_flag": in_err_flag,
"out_errors_flag": out_err_flag,
})
return rows
BASE_HEADERS = [
"Switch Name", "Interface", "Admin Status", "Line Protocol Status",
"Speed (Mbps)", "Duplex", "Flow Control", "PVID",
"Media", "Type", "RX Power", "TX Power",
"Status", "STP State", "MTU", "Counters Cleared",
"In Octets", "In Pkts", "In Unicast", "In Broadcast",
"In Multicast", "In Pauses", "In Drops",
"Out Octets", "Out Pkts", "Out Unicast", "Out Broadcast",
"Out Multicast", "Out Pauses", "Out Drops",
"In Errors?", "Out Errors?"
]
BASE_KEYS = [
"switch_name", "interface", "admin_status", "oper_status",
"speed_mbps", "duplex", "flow_control", "pvid",
"media", "type", "rx", "tx",
"status", "stp_state", "mtu", "counters_cleared",
"ctr_in_octets", "ctr_in_pkts", "ctr_in_unicast_pkts", "ctr_in_broadcast_pkts",
"ctr_in_multicast_pkts", "ctr_in_pauses_pkts", "ctr_in_drops",
"ctr_out_octets", "ctr_out_pkts", "ctr_out_unicast_pkts", "ctr_out_broadcast_pkts",
"ctr_out_multicast_pkts", "ctr_out_pauses_pkts", "ctr_out_drops",
"in_errors_flag", "out_errors_flag"
]
IN_ERR_INSERT_BEFORE = "ctr_out_octets"
OUT_ERR_INSERT_BEFORE = "in_errors_flag"
def write_excel(all_rows, output_path):
all_in_types = []
all_out_types = []
for row in all_rows:
for t in row.get("in_error_details", {}).keys():
if t not in all_in_types:
all_in_types.append(t)
for t in row.get("out_error_details", {}).keys():
if t not in all_out_types:
all_out_types.append(t)
headers = list(BASE_HEADERS)
keys = list(BASE_KEYS)
in_insert_idx = keys.index(IN_ERR_INSERT_BEFORE)
for i, t in enumerate(all_in_types):
headers.insert(in_insert_idx + i, f"In: {t}")
keys.insert(in_insert_idx + i, f"__in_err__{t}")
out_insert_idx = keys.index(OUT_ERR_INSERT_BEFORE)
for i, t in enumerate(all_out_types):
headers.insert(out_insert_idx + i, f"Out: {t}")
keys.insert(out_insert_idx + i, f"__out_err__{t}")
for row in all_rows:
for t in all_in_types:
row[f"__in_err__{t}"] = row.get("in_error_details", {}).get(t)
for t in all_out_types:
row[f"__out_err__{t}"] = row.get("out_error_details", {}).get(t)
status_col = keys.index("admin_status")
oper_col = keys.index("oper_status")
stp_col = keys.index("stp_state")
wb = Workbook()
ws = wb.active
ws.title = "Interfaces Detail"
ws.freeze_panes = "A2"
ws.row_dimensions[1].height = 30
for col_idx, header in enumerate(headers, 1):
cell = ws.cell(row=1, column=col_idx, value=header)
style_header(cell)
for row_idx, row in enumerate(all_rows, 2):
even = (row_idx % 2 == 0)
for col_idx, key in enumerate(keys, 1):
val = row.get(key)
cell = ws.cell(row=row_idx, column=col_idx)
i = col_idx - 1 # 0-based
if key == "in_errors_flag" or key == "out_errors_flag":
cell.value = "OUI ⚠" if val else "NON"
style_err(cell, even) if val else style_ok(cell, even)
continue
if key.startswith("__in_err__") or key.startswith("__out_err__"):
cell.value = to_excel_value(val)
if val is not None and val > 0:
style_err(cell, even)
else:
style_cell(cell, even)
continue
cell.value = to_excel_value(val)
if i == status_col:
style_ok(cell, even) if str(val).upper() == "UP" else (style_err(cell, even) if val else style_cell(cell, even))
elif i == oper_col:
style_ok(cell, even) if str(val).upper() == "UP" else (style_err(cell, even) if val else style_cell(cell, even))
elif i == stp_col:
v = str(val).upper() if val else ""
if v == "FORWARDING": style_ok(cell, even)
elif v in ("BLOCKING", "DISCARDING"): style_err(cell, even)
elif v: style_warn(cell, even)
else: style_cell(cell, even)
else:
style_cell(cell, even)
col_widths = [max(len(h) + 2, 10) for h in headers]
for row in all_rows:
for col_idx, key in enumerate(keys):
val = str(row.get(key) or "")
col_widths[col_idx] = min(max(col_widths[col_idx], len(val) + 2), 40)
for col_idx, width in enumerate(col_widths, 1):
ws.column_dimensions[get_column_letter(col_idx)].width = width
ws.auto_filter.ref = f"A1:{get_column_letter(len(headers))}1"
wb.save(output_path)
print(f"Excel généré : {output_path}")
def main(output_dir, output_xlsx):
all_data = []
for filename in sorted(os.listdir(output_dir)):
if filename.endswith(".json") and "current" in filename:
with open(os.path.join(output_dir, filename), "r", encoding="utf-8") as f:
all_data.append(json.load(f))
if not all_data:
print("Aucun fichier JSON trouvé.")
return
all_rows = []
for data in all_data:
all_rows.extend(parse_file(data))
write_excel(all_rows, output_xlsx)
print(f"\nExcel généré : {output_xlsx}")
return output_xlsx
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,217 @@
import json
import os
import re
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter
BLUE_DARK = "2E4057"
BLUE_LIGHT = "EAF0FB"
GREY = "F5F5F5"
def style_title(cell):
cell.font = Font(name="Arial", bold=True, color="FFFFFF", size=11)
cell.fill = PatternFill("solid", start_color=BLUE_DARK)
cell.alignment = Alignment(horizontal="center", vertical="center")
cell.border = Border(bottom=Side(style="medium", color="FFFFFF"))
def style_header(cell):
cell.font = Font(name="Arial", bold=True, color="FFFFFF", size=10)
cell.fill = PatternFill("solid", start_color="4A6FA5")
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="medium", color="FFFFFF"),
right=Side(style="thin", color="FFFFFF")
)
def style_label(cell):
cell.font = Font(name="Arial", bold=True, size=9)
cell.fill = PatternFill("solid", start_color=GREY)
cell.alignment = Alignment(vertical="center")
cell.border = Border(
bottom=Side(style="thin", color="D0D0D0"),
right=Side(style="thin", color="D0D0D0")
)
def style_value(cell, even=True):
cell.font = Font(name="Arial", size=9)
cell.fill = PatternFill("solid", start_color=BLUE_LIGHT if even else "FFFFFF")
cell.alignment = Alignment(vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="thin", color="D0D0D0"),
right=Side(style="thin", color="D0D0D0")
)
def style_up(cell):
style_value(cell)
cell.font = Font(name="Arial", size=9, color="1E7E34", bold=True)
def style_down(cell):
style_value(cell)
cell.font = Font(name="Arial", size=9, color="C0392B", bold=True)
def parse_irf_members(data):
"""
Parse all Switch... components and return a list of dicts, one per member.
Each dict: {member_id, priority, links: [{name, neighbor, state, ports:[]}]}
"""
members = []
for comp in data.get("openconfig-platform:components", {}).get("component", []):
name = comp.get("name", "")
if not name.startswith("Switch"):
continue
props = {}
for prop in comp.get("properties", {}).get("property", []):
pname = prop.get("name", "")
pval = prop.get("state", {}).get("value", "")
props[pname] = pval
m = re.search(r'\d+', name)
member_id = m.group() if m else name
priority = props.get("irf-priority", "")
links = []
link_keys = sorted([k for k in props if re.match(r'irf-link-\d+', k)])
for lk in link_keys:
val = props[lk]
neighbor = state = ""
nm = re.search(r'Neighbor:\s*(\S+)', val)
sm = re.search(r'State:\s*(\S+)', val)
if nm: neighbor = nm.group(1)
if sm: state = sm.group(1).upper()
link_idx = re.search(r'\d+', lk).group()
port_keys = sorted([
k for k in props
if re.match(rf'irf-config-port{link_idx}', k)
])
ports = [props[pk] for pk in port_keys if props[pk]]
links.append({
"link_name": lk,
"neighbor": neighbor,
"state": state,
"ports": ports
})
members.append({
"member_id": member_id,
"priority": priority,
"links": links
})
members.sort(key=lambda x: x["member_id"])
return members
def write_sheet(ws, switch_name, members):
ws.freeze_panes = "A2"
ws.merge_cells("A1:F1")
title = ws["A1"]
title.value = f"Stack IRF — {switch_name}"
style_title(title)
ws.row_dimensions[1].height = 28
headers = ["Membre", "Priorité", "Lien IRF", "Membre voisin", "État", "Ports configurés"]
for col, h in enumerate(headers, 1):
cell = ws.cell(row=2, column=col, value=h)
style_header(cell)
ws.row_dimensions[2].height = 22
row = 3
for member in members:
member_id = member["member_id"]
priority = member["priority"]
links = member["links"]
if not links:
data_row = [member_id, priority, "", "", "", ""]
for col, val in enumerate(data_row, 1):
cell = ws.cell(row=row, column=col, value=val)
style_label(cell) if col <= 2 else style_value(cell, row % 2 == 0)
ws.row_dimensions[row].height = 18
row += 1
continue
for li, link in enumerate(links):
ports_str = "\n".join(link["ports"]) if link["ports"] else ""
nb_ports = max(len(link["ports"]), 1)
if li == 0:
ws.cell(row=row, column=1, value=member_id)
ws.cell(row=row, column=2, value=priority)
if len(links) > 1:
ws.merge_cells(
start_row=row, start_column=1,
end_row=row + len(links) - 1, end_column=1
)
ws.merge_cells(
start_row=row, start_column=2,
end_row=row + len(links) - 1, end_column=2
)
style_label(ws.cell(row=row, column=1))
style_label(ws.cell(row=row, column=2))
ws.cell(row=row, column=3, value=link["link_name"])
ws.cell(row=row, column=4, value=link["neighbor"])
state_cell = ws.cell(row=row, column=5, value=link["state"])
if link["state"] == "UP":
style_up(state_cell)
elif link["state"] in ("DOWN", ""):
style_down(state_cell)
else:
style_value(state_cell, row % 2 == 0)
ws.cell(row=row, column=6, value=ports_str)
for col in [3, 4, 6]:
style_value(ws.cell(row=row, column=col), row % 2 == 0)
ws.row_dimensions[row].height = 18 * nb_ports
row += 1
widths = [10, 10, 16, 12, 16, 70]
for col, w in enumerate(widths, 1):
ws.column_dimensions[get_column_letter(col)].width = w
def sanitize_sheet_name(name):
"""Excel sheet names: max 31 chars, no special chars."""
name = re.sub(r'[\\/*?:\[\]]', '_', name)
return name[:31]
def main(output_dir, output_xlsx):
wb = Workbook()
wb.remove(wb.active)
found = False
for filename in sorted(os.listdir(output_dir)):
if not (filename.endswith(".json") and "current" in filename):
continue
found = True
with open(os.path.join(output_dir, filename), "r", encoding="utf-8") as f:
data = json.load(f)
switch_name = data.get("switch-device", {}).get("name", filename)
members = parse_irf_members(data)
if len(members) > 1:
ws = wb.create_sheet(title=sanitize_sheet_name(switch_name))
write_sheet(ws, switch_name, members)
if not found:
print("Aucun fichier JSON trouvé.")
return
wb.save(output_xlsx)
print(f"\nExcel généré : {output_xlsx}")
return output_xlsx
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,267 @@
import json
import os
import re
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter
def normalize_interface(name):
name_map = {
"XGE": "Ten-GigabitEthernet",
"GE": "GigabitEthernet",
"HGE": "HundredGigE",
"FGE": "FortyGigE",
"BAGG": "Bridge-Aggregation"
}
match = re.match(r'([A-Za-z]+)(.+)', name)
if not match:
return name
prefix, suffix = match.groups()
prefix = prefix.upper()
full = name_map.get(prefix, prefix)
return f"{full}{suffix}"
def extract_mac_from_member(member_line):
match = re.search(r'([0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4})', member_line)
return match.group(1) if match else None
def extract_port_from_member(member_line):
# ex : "XGE1/0/49 S 32768 3 2 {ACDEF}",
# ex : "XGE1/0/49(R) S 32768 3 2 {ACDEF}"
match = re.search(r'^\s*([A-Za-z0-9/]+)', member_line)
return match.group(1) if match else None
def get_switch_macs(data):
macs = set()
for comp in data.get("openconfig-platform:components", {}).get("component", []):
if comp.get("name", "").startswith("CPU"):
mac = comp.get("state", {}).get("base-mac-address")
if mac:
macs.add(str(mac).upper())
return macs
def parse_description_field(description, field):
"""Extract port_channel number or description text from state description string."""
if not description:
return None
if field == "port_channel":
m = re.search(r'link-aggregation group\s+(\d+)', description, re.IGNORECASE)
return m.group(1) if m else None
if field == "description":
m = re.search(r'Description:\s*([^;"\n]+)', description)
return m.group(1).strip() if m else None
return None
def get_irf_mode(data, intf_name):
"""Check IRF config ports to determine interface mode if switched-vlan is absent."""
for comp in data.get("openconfig-platform:components", {}).get("component", []):
if not comp.get("name", "").startswith("Switch"):
continue
for prop in comp.get("properties", {}).get("property", []):
if prop.get("name", "").startswith("irf-config-port"):
value = prop.get("state", {}).get("value", "")
if intf_name in value:
return "IRF"
return None
def get_bridge_info(interfaces, bridge_name):
"""Return (nb_liens, nb_liens_up, members_macs) for a Bridge-Aggregation interface."""
for intf in interfaces:
if intf.get("name") == bridge_name:
agg = intf.get("openconfig-if-aggregate:aggregation", {}).get("state", {})
members = agg.get("member", [])
nb = int((len(members) - 2) / 2) if len(members) >= 2 else 0
nb_up = 0
remote_macs = []
in_remote = False
for m in members:
if m == "Remote":
in_remote = True
continue
if m == "Local":
in_remote = False
continue
if not in_remote:
interface = extract_port_from_member(m)
if interface:
interface = normalize_interface(interface)
for intf_check in interfaces:
if intf_check.get("name") == interface:
oper_status = intf_check.get("state", {}).get("oper-status")
admin_status = intf_check.get("state", {}).get("admin-status")
if oper_status == "UP" and admin_status == "UP":
nb_up += 1
break
if in_remote:
mac = extract_mac_from_member(m)
if mac:
remote_macs.append(mac.upper())
return nb, nb_up, remote_macs
return None, None, []
def build_mac_to_switch(all_files_data):
"""Build global mapping {mac_upper: switch_name} from all parsed files."""
mapping = {}
for data in all_files_data:
switch_name = data.get("switch-device", {}).get("name", "")
for mac in get_switch_macs(data):
mapping[mac.upper()] = switch_name
return mapping
def parse_file(data, mac_to_switch):
switch_name = data.get("switch-device", {}).get("name", "")
switch_macs = get_switch_macs(data)
interfaces = data.get("openconfig-interfaces:interfaces", {}).get("interface", [])
fdb_mac_by_interface = {}
for ni in data.get("openconfig-network-instance:network-instances", {}).get("network-instance", []):
for entry in ni.get("fdb", {}).get("mac-table", {}).get("entries", {}).get("entry", []):
intf_ref = entry.get("interface", {}).get("interface-ref", {}).get("config", {})
intf_name = intf_ref.get("interface")
mac = entry.get("mac-address")
if intf_name and mac:
fdb_mac_by_interface.setdefault(intf_name, []).append(mac)
rows = []
for intf in interfaces:
name = intf.get("name", "")
eth_state = intf.get("ethernet", {}).get("state", {})
state_desc = intf.get("state", {}).get("description", "")
admin_status = intf.get("state", {}).get("admin-status")
oper_status = intf.get("state", {}).get("oper-status")
speed_kbps = eth_state.get("port-speed")
speed_mbps = speed_kbps / 1_000 if speed_kbps else None
port_channel_num = parse_description_field(state_desc, "port_channel")
description = parse_description_field(state_desc, "description")
# Mode
sv_state = intf.get("ethernet", {}).get("switched-vlan", {}).get("state", {})
mode = sv_state.get("interface-mode") if sv_state else None
if not mode:
mode = get_irf_mode(data, name)
# Bridge info
nb_liens, nb_liens_up, remote_macs = (None, None, [])
if name.startswith("Bridge-Aggregation"):
nb_liens, nb_liens_up, remote_macs = get_bridge_info(interfaces, name)
if mode=="ACCESS":
remote_macs = fdb_mac_by_interface.get(name, [])
# Switch destination via MAC lookup
switch_destinations = []
for mac in remote_macs:
dest = mac_to_switch.get(mac.upper(), mac)
switch_destinations.append(dest)
rows.append({
"switch_name": switch_name,
"switch_macs": ", ".join(sorted(switch_macs)),
"interface": name,
"admin_status": admin_status,
"oper_status": oper_status,
"speed_mbps": speed_mbps,
"port_channel": port_channel_num,
"description": description,
"mode": mode,
"nb_liens": nb_liens,
"nb_liens_up": nb_liens_up,
"mac_destination": ", ".join(sorted(set(remote_macs))),
"switch_destination": ", ".join(sorted(set(switch_destinations))),
})
return rows
HEADERS = [
"Switch Name", "MAC du Switch", "Interface", "Admin Status",
"Line Protocol Status", "Speed (Mbps)", "Port Channel",
"Description", "Mode", "Nb Liens", "Nb Liens Up",
"MAC Destination", "Switch Destination"
]
COL_KEYS = [
"switch_name", "switch_macs", "interface", "admin_status",
"oper_status", "speed_mbps", "port_channel",
"description", "mode", "nb_liens", "nb_liens_up",
"mac_destination", "switch_destination"
]
def style_header(cell):
cell.font = Font(name="Arial", bold=True, color="FFFFFF", size=10)
cell.fill = PatternFill("solid", start_color="2E4057")
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="medium", color="FFFFFF"),
right=Side(style="thin", color="FFFFFF")
)
def style_row(cell, even):
cell.font = Font(name="Arial", size=9)
cell.fill = PatternFill("solid", start_color="EAF0FB" if even else "FFFFFF")
cell.alignment = Alignment(vertical="center", wrap_text=True)
cell.border = Border(
bottom=Side(style="thin", color="D0D0D0"),
right=Side(style="thin", color="D0D0D0")
)
def write_excel(all_rows, output_path):
wb = Workbook()
ws = wb.active
ws.title = "Interfaces"
ws.freeze_panes = "A2"
ws.row_dimensions[1].height = 30
for col_idx, header in enumerate(HEADERS, 1):
cell = ws.cell(row=1, column=col_idx, value=header)
style_header(cell)
for row_idx, row in enumerate(all_rows, 2):
even = (row_idx % 2 == 0)
for col_idx, key in enumerate(COL_KEYS, 1):
val = row.get(key)
cell = ws.cell(row=row_idx, column=col_idx, value=val)
style_row(cell, even)
# Auto column widths
col_widths = [len(h) + 2 for h in HEADERS]
for row in all_rows:
for col_idx, key in enumerate(COL_KEYS):
val = str(row.get(key) or "")
col_widths[col_idx] = min(max(col_widths[col_idx], len(val) + 2), 50)
for col_idx, width in enumerate(col_widths, 1):
ws.column_dimensions[get_column_letter(col_idx)].width = width
# Auto-filter
ws.auto_filter.ref = f"A1:{get_column_letter(len(HEADERS))}1"
wb.save(output_path)
print(f"Excel généré : {output_path}")
def main(output_dir, output_xlsx):
all_data = []
for filename in os.listdir(output_dir):
if filename.endswith(".json") and "current" in filename:
with open(os.path.join(output_dir, filename), "r", encoding="utf-8") as f:
all_data.append(json.load(f))
if not all_data:
print("Aucun fichier JSON trouvé.")
return
mac_to_switch = build_mac_to_switch(all_data)
all_rows = []
for data in all_data:
all_rows.extend(parse_file(data, mac_to_switch))
write_excel(all_rows, output_xlsx)
return output_xlsx
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,380 @@
import json
import math
import os
import re
import base64
from collections import defaultdict
from pyvis.network import Network
def image_to_data_uri(path):
with open(path, "rb") as f:
data = base64.b64encode(f.read()).decode("utf-8")
ext = path.rsplit(".", 1)[-1].lower()
mime = {"png": "image/png", "jpg": "image/jpeg", "svg": "image/svg+xml"}.get(ext, "image/png")
return f"data:{mime};base64,{data}"
def kbps_to_gbps(kbps):
if kbps is None:
return None
return int(kbps / 1_000_000)
def extract_mac_from_member(member_line):
match = re.search(r'([0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4})', member_line)
return match.group(1) if match else None
def process_json_files(output_dir):
results = []
info = []
for filename in os.listdir(output_dir):
if not filename.endswith(".json") or "current" not in filename:
continue
filepath = os.path.join(output_dir, filename)
with open(filepath, "r", encoding="utf-8") as f:
data = json.load(f)
switch = data.get("switch-device", {}).get("name", [])
mac_switch_actu = set()
components = (
data.get("openconfig-platform:components", {}).get("component", [])
)
for comp in components:
if comp.get("name", "").startswith("CPU"):
mac = comp.get("state", {}).get("base-mac-address")
if mac:
mac_switch_actu.add(str(mac))
info.append((
list(mac_switch_actu),
switch
))
interfaces = (
data.get("openconfig-interfaces:interfaces", {}).get("interface", [])
)
for intf in interfaces:
bridge = intf.get("name", "")
if not bridge.startswith("Bridge-Aggregation"):
continue
port_speed_kbps = (
intf.get("ethernet", {}).get("state", {}).get("port-speed")
)
speed_gbps = kbps_to_gbps(port_speed_kbps)
members = (
intf.get("openconfig-if-aggregate:aggregation", {})
.get("state", {})
.get("member", [])
)
if len(members) <= 2:
continue
in_remote = False
macs_distantes = set()
for member in members:
if member == "Remote":
in_remote = True
continue
if member == "Local":
in_remote = False
continue
if in_remote:
mac = extract_mac_from_member(member)
if mac:
macs_distantes.add(mac)
for mac_distant in macs_distantes:
results.append((
list(mac_switch_actu),
switch,
bridge,
speed_gbps,
mac_distant
))
return results, info
def create_link(results, info):
links = []
for i in results:
switch_distant = None
for j in info:
if i[4].upper() in j[0]:
switch_distant = j[1]
break
else :
switch_distant = i[4].upper()
info.append(([i[4].upper()], i[4].upper()))
break
nom_lien = "BAGG" + re.search(r"\d+", i[2]).group()
links.append((i[1], switch_distant, f"{nom_lien} {i[3]}Gb"))
return links
def main(output_dir, output_file_html):
results, info = process_json_files(output_dir)
edges = create_link(results, info)
switches = []
for i in info:
switches.append(i[1])
icon_switch = image_to_data_uri("src/icons/switch.png")
net = Network(height="1000px", width="100%", bgcolor="#ffffff", font_color="black")
for sw in switches: net.add_node(sw, label=sw, shape="image", image=icon_switch, size=25)
for src, tgt, lbl in edges:
net.add_edge(src, tgt, label=lbl)
options = {
"physics": {
"enabled": True,
"barnesHut": {
"gravitationalConstant": -30000,
"centralGravity": 1,
"springLength": 600,
"springConstant": 0.05,
"damping": 1,
"avoidOverlap": 0
},
"minVelocity": 0,
"maxVelocity": 0
},
"interaction": {
"dragNodes": True,
"hideEdgesOnDrag": False,
"hideNodesOnDrag": False,
"zoomView": True,
"hover": True
},
"edges": {
"smooth": False,
"color": {
"color": "#79C4E7",
"highlight": "#ff6600",
"hover": "#ff0000"
},
"width": 1,
"hoverWidth": 4,
"selectionWidth": 3
}
}
net.set_options(json.dumps(options))
net.write_html(output_file_html)
css_finding = '</head>'
css_replacement = '''
<style>
.tooltip-wrap {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 4px;
}
.tooltip-wrap label { margin: 0; }
.tip-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
background: #888;
color: white;
border-radius: 50%;
font-size: 11px;
font-weight: bold;
cursor: help;
user-select: none;
flex-shrink: 0;
}
#tooltip-bubble {
display: none;
position: fixed;
background: #222;
color: #fff;
font-size: 12px;
font-family: Arial, sans-serif;
line-height: 1.5;
border-radius: 6px;
padding: 8px 11px;
max-width: 220px;
z-index: 999999;
pointer-events: none;
box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
</style>
</head>'''
body_finding = '</body>'
body_replacement = '''
<!-- Bulle tooltip globale -->
<div id="tooltip-bubble"></div>
<div style="position:fixed;top:10px;left:10px;z-index:999;display:flex;gap:10px;">
<button id="togglePhysics">Activer/Désactiver physique</button>
<button id="toggleTree">Mode Tree</button>
</div>
<div style="position:fixed;bottom:10px;left:10px;z-index:999;background:white;padding:12px;border-radius:8px;font-family:Arial;min-width:180px;">
<div style="margin-bottom:6px;">
<div class="tooltip-wrap">
<label>Gravitational</label>
<span class="tip-icon"
data-tip="Force de répulsion entre les nœuds. Plus la valeur est négative, plus ils s\'éloignent les uns des autres.">?</span>
</div>
<input id="grav" type="range" min="-100000" max="-1000" value="-30000" style="width:100%">
</div>
<div style="margin-bottom:6px;">
<div class="tooltip-wrap">
<label>Central Gravity</label>
<span class="tip-icon"
data-tip="Force qui attire tous les nœuds vers le centre. Une valeur élevée maintient le réseau compact.">?</span>
</div>
<input id="central" type="range" min="0" max="1" step="0.05" value="1" style="width:100%">
</div>
<div style="margin-bottom:6px;">
<div class="tooltip-wrap">
<label>Spring Length</label>
<span class="tip-icon"
data-tip="Longueur idéale des liens entre nœuds. Une valeur plus grande espace davantage les nœuds connectés.">?</span>
</div>
<input id="springLen" type="range" min="50" max="1000" value="600" style="width:100%">
</div>
<div style="margin-bottom:6px;">
<div class="tooltip-wrap">
<label>Spring Constant</label>
<span class="tip-icon"
data-tip="Rigidité des liens. Valeur élevée = stabilisation rapide mais graphe rigide.">?</span>
</div>
<input id="springConst" type="range" min="0.01" max="1" step="0.01" value="0.05" style="width:100%">
</div>
<div style="margin-bottom:6px;">
<div class="tooltip-wrap">
<label>Damping</label>
<span class="tip-icon"
data-tip="Amortissement du mouvement. À 1 les nœuds s\'arrêtent vite, à 0 ils oscillent longtemps.">?</span>
</div>
<input id="damping" type="range" min="0" max="1" step="0.01" value="1" style="width:100%">
</div>
<div style="margin-bottom:8px;">
<div class="tooltip-wrap">
<label><input type="checkbox" id="avoid"> Avoid Overlap</label>
<span class="tip-icon"
data-tip="Empêche les nœuds de se superposer.">?</span>
</div>
</div>
<button id="applyPhysics">Apply</button>
</div>
<div style="position:fixed;bottom:10px;right:10px;z-index:999;background:white;padding:10px;border-radius:8px;">
<button id="exportPng">Export PNG</button>
</div>
<script>
(function () {
const bubble = document.getElementById("tooltip-bubble");
document.querySelectorAll(".tip-icon").forEach(function (el) {
el.addEventListener("mouseenter", function (e) {
bubble.textContent = el.getAttribute("data-tip");
bubble.style.display = "block";
bubble.style.left = (e.clientX + 14) + "px";
bubble.style.top = (e.clientY + 14) + "px";
});
el.addEventListener("mousemove", function (e) {
bubble.style.left = (e.clientX + 14) + "px";
bubble.style.top = (e.clientY + 14) + "px";
});
el.addEventListener("mouseleave", function () {
bubble.style.display = "none";
});
});
})();
</script>
<script>
window.addEventListener("load", function () {
document.getElementById("exportPng").onclick = function () {
if (typeof network === "undefined") { console.error("network non trouvé"); return; }
const canvas = network.canvas.frame.canvas;
const imgURL = canvas.toDataURL("image/png");
const link = document.createElement("a");
link.href = imgURL;
link.download = "network.png";
link.click();
};
});
</script>
<script>
(function () {
function applyPhysics() {
if (typeof network === "undefined") return;
network.setOptions({
physics: {
enabled: true,
barnesHut: {
gravitationalConstant: parseFloat(document.getElementById("grav").value),
centralGravity: parseFloat(document.getElementById("central").value),
springLength: parseFloat(document.getElementById("springLen").value),
springConstant: parseFloat(document.getElementById("springConst").value),
damping: parseFloat(document.getElementById("damping").value),
avoidOverlap: document.getElementById("avoid").checked ? 0.2 : 0
}
}
});
}
document.getElementById("applyPhysics").onclick = applyPhysics;
})();
</script>
<script>
(function () {
let treeEnabled = false;
document.getElementById("togglePhysics").onclick = function () {
if (typeof network === "undefined") return;
network.setOptions({
physics: { enabled: !network.physics.physicsEnabled },
layout: { hierarchical: { enabled: false } }
});
};
document.getElementById("toggleTree").onclick = function () {
if (typeof network === "undefined") return;
treeEnabled = !treeEnabled;
if (treeEnabled) {
network.setOptions({
physics: false,
layout: { hierarchical: { enabled: true, direction: "UD", sortMethod: "directed",
levelSeparation: 3000, nodeSpacing: 150, treeSpacing: 200 } }
});
} else {
network.setOptions({
layout: { hierarchical: { enabled: false } },
physics: { enabled: true }
});
}
};
})();
</script>
</body>'''
with open(output_file_html, "r", encoding="utf-8") as file:
content = file.read()
content = content.replace(css_finding, css_replacement)
content = content.replace(body_finding, body_replacement)
with open(output_file_html, "w", encoding="utf-8") as file:
file.write(content)
return output_file_html

View File

@@ -1,641 +0,0 @@
import os
import re
import json
import glob
import sys
from datetime import datetime
class InterfaceParser:
"""
Parse les données de la commande 'display interface' pour extraire les informations des interfaces.
"""
def parse(self, content: str) -> dict:
interfaces = {}
current_interface = None
lines = content.split('\n')
for line in lines:
line = line.strip()
if re.match(r'^(?!\s)(?:interface\s*)?(?:[A-Za-z-]*Ethernet|Bridge-Aggregation|Vlan-interface)\d+', line):
current_interface = line
interfaces[current_interface] = {
"name": current_interface,
"current_state": None,
"description": None,
"speed_mode": None,
"pvid": None,
"port_channel": None,
"bridge_name": None,
"type": None,
"access_vlan": None,
"trunk_vlans": [],
"ip_address": None,
"shutdown": False,
"config_description": None,
"nb_liens": None,
"mac_destination": None
}
continue
if current_interface and line:
if line.startswith('Current state:'):
interfaces[current_interface]["current_state"] = line.split(':', 1)[1].strip()
elif line.startswith('Description:'):
description = line.split(':', 1)[1].strip()
if description and description != f"{current_interface} Interface":
interfaces[current_interface]["description"] = description
else:
interfaces[current_interface]["description"] = None
elif 'speed mode' in line.lower():
speed_match = re.search(r'(\d+(?:\.\d+)?)\s*(Gbps|Mbps|kbps)[^\w]*speed\s+mode', line, re.I)
if speed_match:
speed_value = speed_match.group(1)
speed_unit = speed_match.group(2)
interfaces[current_interface]["speed_mode"] = f"{speed_value}{speed_unit}"
elif 'pvid' in line.lower():
pvid_match = re.search(r'pvid[:\s]*(\d+)', line, re.I)
if pvid_match:
interfaces[current_interface]["pvid"] = int(pvid_match.group(1))
elif 'port channel' in line.lower() or 'channel group' in line.lower():
pc_match = re.search(r'(?:port channel|channel group)[:\s]*(\d+)', line, re.I)
if pc_match:
interfaces[current_interface]["port_channel"] = int(pc_match.group(1))
elif 'member of bridge-aggregation' in line.lower():
ba_match = re.search(r'member of bridge-aggregation\s*(\d+)', line, re.I)
if ba_match:
interfaces[current_interface]["port_channel"] = int(ba_match.group(1))
return interfaces
class LinkAggregationParser:
"""
Parse les données de la commande 'display link-aggregation verbose'.
Extrait les comptes de liens, les mappages MAC et les mappages de pont.
"""
def _convert_port_name(self, port_name: str) -> str:
"""Convertit le nom du port en un format standardisé."""
port_name = re.sub(r'\([A-Z]\)', '', port_name)
patterns = [
(r'^XGE(\d+/\d+/\d+)$', r'Ten-GigabitEthernet\1'),
(r'^GE(\d+/\d+/\d+)$', r'GigabitEthernet\1'),
(r'^FE(\d+/\d+/\d+)$', r'HundredGigE\1'),
(r'^TE(\d+/\d+/\d+)$', r'TenGigabitEthernet\1'),
]
for pattern, replacement in patterns:
if re.match(pattern, port_name):
return re.sub(pattern, replacement, port_name)
return port_name
def parse(self, content: str) -> tuple[dict, dict, dict]:
link_counts = {}
mac_mappings = {}
bridge_mappings = {}
lines = content.split('\n')
current_aggregate = None
current_section = None
local_ports = []
remote_ports = []
for line in lines:
line = line.strip()
if line.startswith('Aggregate Interface:'):
interface_match = re.search(r'Aggregate Interface:\s*(.+)', line)
if interface_match:
current_aggregate = interface_match.group(1).strip()
link_counts[current_aggregate] = 0
local_ports = []
remote_ports = []
continue
if line.startswith('Local:'):
current_section = 'local'
continue
if line.startswith('Remote:'):
current_section = 'remote'
continue
if line.startswith('Aggregate Interface:'):
interface_match = re.search(r'Aggregate Interface:\s*(.+)', line)
if interface_match:
current_aggregate = interface_match.group(1).strip()
if current_aggregate and current_section == 'local' and line:
port_match = re.match(r'^([A-Za-z]+\d+/\d+/\d+(?:\([A-Z]\))?)\s+', line)
if port_match:
if not any(keyword in line for keyword in ['Port', 'Status', 'Priority', 'Index', 'Oper-Key', 'Flag']):
local_port = port_match.group(1)
local_ports.append(local_port)
link_counts[current_aggregate] += 1
if current_aggregate and current_section == 'remote' and line:
remote_match = re.match(r'^([A-Za-z]+\d+/\d+/\d+(?:\([A-Z]\))?)\s+\d+\s+\d+\s+\d+\s+0x[0-9a-fA-F]+,\s*([0-9a-fA-F-]+)', line)
if remote_match:
if not any(keyword in line for keyword in ['Actor', 'Priority', 'Index', 'Oper-Key', 'SystemID', 'Flag']):
remote_port = remote_match.group(1)
system_id = remote_match.group(2)
remote_ports.append((remote_port, system_id))
if current_aggregate and local_ports and remote_ports and \
(line.startswith('Aggregate Interface:') or line == lines[-1].strip()):
min_length = min(len(local_ports), len(remote_ports))
for i in range(min_length):
local_port = local_ports[i]
remote_port, system_id = remote_ports[i]
interface_name = self._convert_port_name(local_port)
mac_mappings[interface_name] = system_id
bridge_mappings[interface_name] = current_aggregate
if line.startswith('Aggregate Interface:'):
current_aggregate = None
local_ports = []
remote_ports = []
current_section = None
if current_aggregate and local_ports and remote_ports:
min_length = min(len(local_ports), len(remote_ports))
for i in range(min_length):
local_port = local_ports[i]
remote_port, system_id = remote_ports[i]
interface_name = self._convert_port_name(local_port)
mac_mappings[interface_name] = system_id
bridge_mappings[interface_name] = current_aggregate
for interface, count in link_counts.items():
if 'Bridge-Aggregation' in interface:
link_counts[interface] = count
return link_counts, mac_mappings, bridge_mappings
class ConfigurationParser:
"""
Parse les données de la commande 'display current-configuration'.
Extrait les configurations des interfaces et les configurations générales du commutateur.
"""
def _parse_vlan_ranges(self, vlan_string: str) -> list:
"""Parse un string de VLAN et renvoie une liste de VLANs uniques."""
vlans = set()
parts = vlan_string.split()
i = 0
while i < len(parts):
if i + 2 < len(parts) and parts[i + 1].lower() == 'to':
try:
start_vlan = int(parts[i])
end_vlan = int(parts[i + 2])
vlans.update(range(start_vlan, end_vlan + 1))
i += 3
except ValueError:
i += 1
else:
try:
vlans.add(int(parts[i]))
except ValueError:
pass
i += 1
return sorted(list(vlans))
def parse(self, content: str) -> tuple[dict, dict]:
interfaces_config = {}
switch_config = {
"version": None,
"lldp": {"enabled": False, "details": {}},
"stp": {"enabled": False, "details": {}},
"ssh": {"enabled": False, "details": {}},
"snmp_contact": None,
"ntp_server": [],
"users": [],
"vlans": []
}
lines = content.split('\n')
current_interface = None
current_section = None
i = 0
while i < len(lines):
line = lines[i]
line_stripped = line.strip()
if line_stripped.startswith('version '):
switch_config["version"] = line_stripped.split('version ', 1)[1].strip()
elif 'lldp enable' in line_stripped.lower():
switch_config["lldp"]["enabled"] = True
elif line_stripped.startswith('lldp '):
switch_config["lldp"]["details"][line_stripped] = True
elif 'stp enable' in line_stripped.lower() or 'spanning-tree' in line_stripped.lower():
switch_config["stp"]["enabled"] = True
switch_config["stp"]["details"][line_stripped] = True
elif 'ssh server enable' in line_stripped.lower() or 'ssh user' in line_stripped.lower():
switch_config["ssh"]["enabled"] = True
switch_config["ssh"]["details"][line_stripped] = True
elif line_stripped.startswith('snmp-agent sys-info contact'):
switch_config["snmp_contact"] = line_stripped.split('contact', 1)[1].strip().strip('"')
elif line_stripped.startswith('ntp-service unicast-server'):
ntp_server = line_stripped.split('unicast-server', 1)[1].strip()
switch_config["ntp_server"].append(ntp_server)
elif line_stripped.startswith('local-user '):
username = line_stripped.split('local-user ', 1)[1].strip()
switch_config["users"].append(username)
elif line_stripped.startswith('vlan '):
vlan_info = line_stripped.split('vlan ', 1)[1].strip()
if "vlans" not in switch_config:
switch_config["vlans"] = []
if 'to' in vlan_info:
parts = vlan_info.split(' to ')
if len(parts) == 2:
start_vlan = int(parts[0])
end_vlan = int(parts[1])
for vlan_id in range(start_vlan, end_vlan + 1):
if vlan_id not in switch_config["vlans"]:
switch_config["vlans"].append(vlan_id)
else:
vlan_id = int(vlan_info)
if vlan_id not in switch_config["vlans"]:
switch_config["vlans"].append(vlan_id)
elif line_stripped.startswith('interface '):
interface_match = re.match(r'^interface\s+(.+)', line_stripped)
if interface_match:
current_interface = interface_match.group(1).strip()
interfaces_config[current_interface] = {
"name": current_interface,
"type": "access",
"access_vlan": None,
"trunk_vlans": [],
"ip_address": None,
"shutdown": False,
"port_channel": None,
"description": None
}
current_section = "interface"
elif current_section == "interface" and current_interface:
if line_stripped != '' and not line.startswith(' ') and not line.startswith('\t'):
if not line_stripped.startswith('interface '):
current_interface = None
current_section = None
continue
else:
interface_match = re.match(r'^interface\s+(.+)', line_stripped)
if interface_match:
current_interface = interface_match.group(1).strip()
interfaces_config[current_interface] = {
"name": current_interface,
"type": "access",
"access_vlan": None,
"trunk_vlans": [],
"ip_address": None,
"shutdown": False,
"port_channel": None,
"description": None
}
elif line.startswith(' ') or line.startswith('\t'):
command = line.strip()
if command.startswith('description '):
interfaces_config[current_interface]["description"] = command.split('description ', 1)[1].strip()
elif command == 'shutdown':
interfaces_config[current_interface]["shutdown"] = True
elif command.startswith('ip address '):
ip_info = command.split('ip address ', 1)[1].strip()
interfaces_config[current_interface]["ip_address"] = ip_info
elif 'link-aggregation' in command.lower() or 'port-group' in command.lower():
pc_match = re.search(r'(\d+)', command)
if pc_match:
interfaces_config[current_interface]["port_channel"] = int(pc_match.group(1))
elif command.startswith('port access vlan '):
vlan_id = int(command.split('port access vlan ', 1)[1].strip())
interfaces_config[current_interface]["type"] = "access"
interfaces_config[current_interface]["access_vlan"] = vlan_id
elif command.startswith('port link-type trunk'):
interfaces_config[current_interface]["type"] = "trunk"
elif command.startswith('port trunk permit vlan '):
interfaces_config[current_interface]["type"] = "trunk"
vlan_info = command.split('port trunk permit vlan ', 1)[1].strip()
if vlan_info == "all":
interfaces_config[current_interface]["trunk_vlans"] = "all"
else:
trunk_vlans = self._parse_vlan_ranges(vlan_info)
interfaces_config[current_interface]["trunk_vlans"].extend(trunk_vlans)
elif command.startswith('undo port trunk permit vlan '):
vlan_info = command.split('undo port trunk permit vlan ', 1)[1].strip()
if vlan_info == "all":
interfaces_config[current_interface]["trunk_vlans"] = []
else:
vlans_to_remove = self._parse_vlan_ranges(vlan_info)
current_trunk = interfaces_config[current_interface]["trunk_vlans"]
if current_trunk != "all":
for vlan in vlans_to_remove:
if vlan in current_trunk:
current_trunk.remove(vlan)
elif command.startswith('port trunk pvid vlan '):
interfaces_config[current_interface]["type"] = "trunk"
pvid = int(command.split('port trunk pvid vlan ', 1)[1].strip())
trunk_vlans = interfaces_config[current_interface]["trunk_vlans"]
if trunk_vlans != "all" and pvid not in trunk_vlans:
trunk_vlans.append(pvid)
i += 1
if isinstance(switch_config["vlans"], list):
switch_config["vlans"] = sorted(list(set(switch_config["vlans"])))
for interface in interfaces_config.values():
if isinstance(interface["trunk_vlans"], list):
interface["trunk_vlans"] = sorted(list(set(interface["trunk_vlans"])))
return interfaces_config, switch_config
class DeviceInfoParser:
"""
Parse les données de la commande 'display device manuinfo' pour extraire les adresses MAC.
"""
def parse(self, content: str) -> list[str]:
mac_addresses = []
lines = content.split('\n')
current_slot_cpu = None
for line in lines:
line = line.strip()
if re.match(r'^\s*Slot\s+\d+\s+CPU\s+0\s*:', line, re.I):
current_slot_cpu = line.strip()
continue
if current_slot_cpu and line.startswith('MAC_ADDRESS'):
mac_match = re.search(r'MAC_ADDRESS\s*:\s*([A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4})', line)
if mac_match:
mac_address = mac_match.group(1)
mac_addresses.append(mac_address)
if line.startswith('Slot') and 'CPU' in line and current_slot_cpu:
if line.strip() != current_slot_cpu:
current_slot_cpu = None
return mac_addresses
class LogFileProcessor:
"""
Manage le parsing d'un fichier journal unique, en coordonnant différents analyseurs
et en fusionnant leurs résultats dans une structure JSON unifiée.
"""
def __init__(self):
self.interface_parser = InterfaceParser()
self.link_agg_parser = LinkAggregationParser()
self.config_parser = ConfigurationParser()
self.device_info_parser = DeviceInfoParser()
def _extract_sections(self, file_content: str) -> dict:
"""Extrait les sections pertinentes du contenu du fichier journal en fonction des motifs définis."""
sections = {}
current_section = None
lines = file_content.splitlines()
section_patterns = {
"display_interface": re.compile(r"^=+\s*display interface\s*=+$", re.I),
"display_link_aggregation_verbose": re.compile(r"^=+\s*display link-aggregation verbose\s*=+$", re.I),
"display_current_configuration": re.compile(r"^=+\s*display current-configuration\s*=+$", re.I),
"display_device_manuinfo": re.compile(r"^=+\s*display device manuinfo\s*=+$", re.I)
}
for line in lines:
line_strip = line.strip()
matched_section = None
for section_name, pattern in section_patterns.items():
if pattern.match(line_strip):
matched_section = section_name
break
if matched_section:
current_section = matched_section
sections[current_section] = []
continue
if re.match(r"^=+$", line_strip):
current_section = None
continue
if current_section:
sections[current_section].append(line)
for key in sections:
sections[key] = "\n".join(sections[key])
return sections
def _extract_switch_name(self, content: str) -> str | None:
"""Extrait le nom du commutateur à partir du contenu du fichier journal."""
sysname_match = re.search(r"(?m)^\s*sysname\s+(.+)$", content)
if sysname_match:
return sysname_match.group(1).strip()
return None
def _merge_configuration_into_interfaces(self, interfaces: dict, interfaces_config: dict):
"""Merge les détails de configuration dans les données d'interface analysées."""
for interface_name, config in interfaces_config.items():
if interface_name in interfaces:
interfaces[interface_name].update({
"type": config["type"],
"access_vlan": config["access_vlan"],
"trunk_vlans": config["trunk_vlans"],
"ip_address": config["ip_address"],
"shutdown": config["shutdown"],
"config_description": config["description"],
})
if config["port_channel"] is not None:
interfaces[interface_name]["port_channel"] = config["port_channel"]
else:
interfaces[interface_name] = {
"name": interface_name,
"current_state": None,
"description": None,
"speed_mode": None,
"pvid": None,
"port_channel": config["port_channel"],
"type": config["type"],
"access_vlan": config["access_vlan"],
"trunk_vlans": config["trunk_vlans"],
"ip_address": config["ip_address"],
"shutdown": config["shutdown"],
"config_description": config["description"],
"nb_liens": None,
"mac_destination": None
}
def _merge_link_aggregation_counts(self, interfaces: dict, link_counts: dict):
"""Merge le nombre de link aggregation dans les données d'interface."""
for interface_name, count in link_counts.items():
if interface_name in interfaces:
interfaces[interface_name]["nb_liens"] = count
def _merge_mac_mappings(self, interfaces: dict, mac_mappings: dict):
"""Merge les mappages d'adresses MAC dans les données d'interface."""
for interface_name, mac_address in mac_mappings.items():
if interface_name in interfaces:
interfaces[interface_name]["mac_destination"] = mac_address
else:
interfaces[interface_name] = {
"name": interface_name,
"current_state": None,
"description": None,
"speed_mode": None,
"pvid": None,
"port_channel": None,
"type": None,
"access_vlan": None,
"trunk_vlans": [],
"ip_address": None,
"shutdown": False,
"config_description": None,
"nb_liens": None,
"mac_destination": mac_address
}
def _merge_bridge_mappings(self, interfaces: dict, bridge_mappings: dict):
"""Merge les bridge agreggation dans les interfaces existantes."""
for interface_name, bridge_name in bridge_mappings.items():
if interface_name in interfaces:
interfaces[interface_name]["bridge_name"] = bridge_name
def process_file(self, filepath: str) -> dict | None:
"""
Gère le parsing d'un fichier journal unique pour extraire et consolider les données des appareils réseau.
Renvoie un dictionnaire contenant des métadonnées et des données analysées, ou None en cas d'erreur.
"""
try:
with open(filepath, 'r', encoding='latin-1', errors='ignore') as f:
content = f.read()
sections = self._extract_sections(content)
if not sections:
return None
mac_addresses = []
if "display_device_manuinfo" in sections:
mac_addresses = self.device_info_parser.parse(sections["display_device_manuinfo"])
result = {
"metadata": {
"filename": os.path.basename(filepath),
"switch_name": self._extract_switch_name(content),
"extraction_date": datetime.now().isoformat(),
"sections_found": list(sections.keys()),
"mac_addresses": mac_addresses
},
"data": {}
}
interfaces = {}
if "display_interface" in sections:
interfaces = self.interface_parser.parse(sections["display_interface"])
if "display_current_configuration" in sections:
try:
interfaces_config, switch_config = self.config_parser.parse(sections["display_current_configuration"])
self._merge_configuration_into_interfaces(interfaces, interfaces_config)
result["data"]["switch_config"] = switch_config
except Exception as e:
print(f" - Error parsing current-configuration for {filepath}: {e}", file=sys.stderr)
result["data"]["switch_config"] = {
"version": None, "lldp": {"enabled": False, "details": {}},
"stp": {"enabled": False, "details": {}}, "ssh": {"enabled": False, "details": {}},
"snmp_contact": None, "ntp_server": [], "users": [], "vlans": []
}
if "display_link_aggregation_verbose" in sections:
try:
link_counts, mac_mappings, bridge_mappings = self.link_agg_parser.parse(sections["display_link_aggregation_verbose"])
self._merge_link_aggregation_counts(interfaces, link_counts)
self._merge_mac_mappings(interfaces, mac_mappings)
self._merge_bridge_mappings(interfaces, bridge_mappings)
except Exception as e:
print(f" - Error parsing link-aggregation verbose for {filepath}: {e}", file=sys.stderr)
result["data"]["interfaces"] = interfaces
return result
except Exception as e:
print(f"Error processing file {filepath}: {e}", file=sys.stderr)
return None
class DataExporter:
"""
Gère l'export des données traitées vers un fichier JSON.
"""
def export(self, data: dict, output_filepath: str):
try:
output_dir = os.path.dirname(output_filepath)
if output_dir and not os.path.exists(output_dir):
os.makedirs(output_dir)
with open(output_filepath, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
print(f"Data saved to: {output_filepath}")
except Exception as e:
print(f"Error saving data to {output_filepath}: {e}", file=sys.stderr)
class MainApplication:
"""
Application principale pour coordonner le traitement des fichiers journaux,
l'export des données et la gestion des erreurs.
"""
def __init__(self):
self.processor = LogFileProcessor()
self.exporter = DataExporter()
def run(self, log_file_pattern: str):
current_dir = os.getcwd()
log_files = glob.glob(os.path.join(current_dir, log_file_pattern))
if not log_files:
print(f"No log files found matching pattern: {log_file_pattern}", file=sys.stderr)
return
results = {}
success_count = 0
for log_file in sorted(log_files):
result = self.processor.process_file(log_file)
if result:
results[os.path.basename(log_file)] = result
success_count += 1
output_file = "./src/data.json"
self.exporter.export(results, output_file)
def process_file_return_json(filepath: str) -> dict | None:
"""
Fonction autonome pour traiter un fichier unique et renvoyer un objet JSON,
utile pour les appels externes.
"""
processor = LogFileProcessor()
return processor.process_file(filepath)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python extract_json.py <log_file_pattern>")
else:
app = MainApplication()
app.run(sys.argv[1])

View File

@@ -1,254 +0,0 @@
import sys
import os
from pathlib import Path
from typing import Dict, List, Optional, Any
from dataclasses import dataclass
from contextlib import redirect_stdout
from scripts.extract_json import process_file_return_json
@dataclass
class BridgeInfo:
"""Informations sur un bridge."""
nb_liens: int
speed: str
@classmethod
def from_interface_data(cls, interface_data: Dict[str, Any]) -> 'BridgeInfo':
"""Crée une instance à partir des données d'interface."""
return cls(
nb_liens=interface_data.get("nb_liens", 0),
speed=interface_data.get("speed_mode", "unknown")
)
@dataclass
class InterfaceInfo:
"""Informations sur une interface réseau."""
name: str
mac_destination: Optional[str]
bridge_name: Optional[str]
@classmethod
def from_interface_data(cls, interface_data: Dict[str, Any]) -> 'InterfaceInfo':
"""Crée une instance à partir des données d'interface."""
return cls(
name=interface_data.get("name", ""),
mac_destination=interface_data.get("mac_destination"),
bridge_name=interface_data.get("bridge_name")
)
@dataclass
class DeviceInfo:
"""Informations sur un équipement réseau."""
switch_name: str
mac_addresses: List[str]
interfaces: Dict[str, Any]
@property
def mac_addresses_upper(self) -> List[str]:
"""Retourne les adresses MAC en majuscules."""
return [mac.upper() for mac in self.mac_addresses]
@property
def mac_addresses_str(self) -> str:
"""Retourne les adresses MAC formatées en une chaîne."""
return ','.join(self.mac_addresses_upper)
class LogDataExtractor:
"""Classe pour extraire les données des fichiers de log."""
@staticmethod
def extract_log_data(filename: str) -> Optional[Dict[str, Any]]:
"""Extrait les informations du fichier de log et retourne un dictionnaire."""
try:
data = process_file_return_json(filename)
return data if data else None
except Exception as e:
print(f"Erreur lors du traitement de {filename} : {e}")
sys.exit(1)
@classmethod
def create_device_info(cls, filename: str) -> Optional[DeviceInfo]:
"""Crée un objet DeviceInfo à partir d'un fichier de log."""
data = cls.extract_log_data(filename)
if not data:
return None
metadata = data.get("metadata", {})
return DeviceInfo(
switch_name=metadata.get("switch_name", "unknown"),
mac_addresses=metadata.get("mac_addresses", []),
interfaces=data.get("data", {}).get("interfaces", {})
)
class BridgeAnalyzer:
"""Classe pour analyser les informations de bridge."""
@staticmethod
def extract_bridge_info(interfaces: Dict[str, Any]) -> Dict[str, BridgeInfo]:
"""Extrait les informations de bridge des interfaces."""
bridge_info = {}
for interface_name, interface_data in interfaces.items():
if interface_name.startswith("Bridge-Aggregation"):
bridge_info[interface_name] = BridgeInfo.from_interface_data(interface_data)
return bridge_info
@staticmethod
def get_bridge_details(bridge_info: Dict[str, BridgeInfo], bridge_name: str) -> tuple[str, int]:
"""Récupère les détails d'un bridge spécifique."""
bridge = bridge_info.get(bridge_name, BridgeInfo(0, "unknown"))
return bridge.speed, bridge.nb_liens
class NetworkFormatter:
"""Classe pour formater les sorties réseau."""
@staticmethod
def format_device_output(device_info: DeviceInfo, interface_info: InterfaceInfo,
speed: str, nb_liens: int) -> str:
"""Formate la sortie pour un équipement."""
mac_dest = interface_info.mac_destination.upper() if interface_info.mac_destination else ""
return (f"{device_info.switch_name} [{device_info.mac_addresses_str}] "
f"{interface_info.name} -> {mac_dest} "
f"[{interface_info.bridge_name},{speed},{nb_liens}]")
class CoeurAnalyzer:
"""Classe pour analyser les équipements coeur."""
def __init__(self):
self.mac_coeur = ""
def set_mac_coeur(self, mac_addresses: List[str]) -> None:
"""Met les MAC du coeur dans une variable d'instance."""
self.mac_coeur = ', '.join(mac_addresses)
def analyze(self, filename: str) -> None:
"""Analyse l'extraction json du fichier log du coeur."""
device_info = LogDataExtractor.create_device_info(filename)
if not device_info:
return
# Stocker les MAC du coeur pour les switches
self.set_mac_coeur(device_info.mac_addresses_upper)
bridge_info = BridgeAnalyzer.extract_bridge_info(device_info.interfaces)
for interface_data in device_info.interfaces.values():
interface_info = InterfaceInfo.from_interface_data(interface_data)
if interface_info.mac_destination:
speed, nb_liens = BridgeAnalyzer.get_bridge_details(
bridge_info, interface_info.bridge_name
)
output = NetworkFormatter.format_device_output(
device_info, interface_info, speed, nb_liens
)
print(output)
class SwitchAnalyzer:
"""Classe pour analyser les switches."""
def __init__(self, coeur_analyzer: CoeurAnalyzer):
self.coeur_analyzer = coeur_analyzer
def analyze(self, filename: str) -> None:
"""Analyse l'extraction json du fichier log d'un switch."""
device_info = LogDataExtractor.create_device_info(filename)
if not device_info:
return
bridge_info = BridgeAnalyzer.extract_bridge_info(device_info.interfaces)
for interface_data in device_info.interfaces.values():
interface_info = InterfaceInfo.from_interface_data(interface_data)
if (interface_info.mac_destination and
interface_info.mac_destination.upper() in self.coeur_analyzer.mac_coeur):
speed, nb_liens = BridgeAnalyzer.get_bridge_details(
bridge_info, interface_info.bridge_name
)
output = NetworkFormatter.format_device_output(
device_info, interface_info, speed, nb_liens
)
print(output)
class NetworkAnalysisOrchestrator:
"""Classe principale pour orchestrer l'analyse réseau."""
def __init__(self, base_dir: Path = None):
if base_dir is None:
base_dir = Path(__file__).parent.parent
self.base_dir = Path(base_dir)
self.log_dir = self.base_dir / 'logs'
self.output_file = self.base_dir / 'data.txt'
self.coeur_analyzer = CoeurAnalyzer()
self.switch_analyzer = SwitchAnalyzer(self.coeur_analyzer)
def _get_log_files(self, exclude_filename: str) -> List[Path]:
"""Récupère tous les fichiers de log sauf celui exclu."""
if not self.log_dir.exists():
return []
return [
log_file for log_file in self.log_dir.glob('*.log')
if log_file.name != exclude_filename
]
def run_analysis(self, filename: str) -> None:
"""Lance l'analyse du coeur et des switches à partir d'un fichier log coeur donné."""
coeur_log_path = self.log_dir / filename
if not coeur_log_path.exists():
print(f"Erreur: Le fichier {coeur_log_path} n'existe pas")
return
# Rediriger la sortie vers le fichier
with open(self.output_file, 'w', encoding='utf-8') as f:
with redirect_stdout(f):
print("Coeur:")
self.coeur_analyzer.analyze(str(coeur_log_path))
print("Switches:")
switch_files = self._get_log_files(filename)
for switch_file in switch_files:
self.switch_analyzer.analyze(str(switch_file))
class FormatMain:
"""Classe principale pour le module format."""
def __init__(self, base_dir: Path = None):
self.orchestrator = NetworkAnalysisOrchestrator(base_dir)
def run_analysis(self, filename: str) -> None:
"""Point d'entrée public pour l'analyse."""
self.orchestrator.run_analysis(filename)
def main(filename: str = None) -> None:
"""Fonction principale."""
if filename is None:
if len(sys.argv) != 2:
print("Usage: python format.py <filename>")
sys.exit(1)
filename = sys.argv[1]
format_main = FormatMain()
format_main.run_analysis(filename)
if __name__ == "__main__":
main()

File diff suppressed because it is too large Load Diff

View File

@@ -1,358 +0,0 @@
import re
import sys
from collections import defaultdict
from pathlib import Path
from typing import List, Optional, Tuple
from dataclasses import dataclass
from scripts.format import FormatMain
@dataclass
class NetworkDevice:
"""Classe de base pour représenter un équipement réseau."""
name: str
macs: List[str]
interface: str
dest_mac: str
bridge: str
vitesse: str
nb_liens: str
def __post_init__(self):
"""Validation et nettoyage des données après initialisation."""
if isinstance(self.macs, str):
self.macs = [mac.strip() for mac in self.macs.split(',')]
self.bridge = self.bridge.strip()
self.vitesse = self.vitesse.strip()
self.nb_liens = self.nb_liens.strip()
@property
def macs_str(self) -> str:
"""Retourne les MACs sous forme de chaîne formatée."""
return ','.join(self.macs)
def to_formatted_string(self) -> str:
"""Retourne une représentation formatée de l'équipement."""
return f"{self.name} [{self.macs_str}] {self.interface} -> {self.dest_mac} [{self.bridge},{self.vitesse},{self.nb_liens}]"
@dataclass
class Coeur(NetworkDevice):
"""Classe représentant un équipement coeur."""
pass
@dataclass
class Switch(NetworkDevice):
"""Classe représentant un switch."""
pass
class NetworkFileParser:
"""Classe pour parser les fichiers de configuration réseau."""
ENCODINGS = ['utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'latin-1', 'cp1252', 'iso-8859-1']
PATTERNS = [
r'(\S+)\s+\[([^\]]+)\]\s+(\S+)\s+->\s+([A-Fa-f0-9:-]+)\s*\[([^,]+),([^,]+),([^\]]+)\]',
r'(\S+)\s+\[([^\]]+)\]\s+(\S+)\s*->\s*([A-Fa-f0-9:-]+)\s*\[([^,]+),([^,]+),([^\]]+)\]',
r'(\w+)\s*\[([^\]]+)\]\s*(\w+)\s*->\s*([A-Fa-f0-9:-]+)\s*\[([^,]+),([^,]+),([^\]]+)\]'
]
def __init__(self, file_path: str):
self.file_path = Path(file_path)
def _read_file_with_encoding(self) -> Optional[str]:
"""Lit le fichier en essayant différents encodages."""
for encoding in self.ENCODINGS:
try:
return self.file_path.read_text(encoding=encoding)
except (UnicodeDecodeError, UnicodeError):
continue
except FileNotFoundError:
return None
return None
def _parse_line(self, line: str, device_class) -> Optional[NetworkDevice]:
"""Parse une ligne et retourne un objet NetworkDevice."""
line = line.strip()
if not line:
return None
for pattern in self.PATTERNS:
match = re.match(pattern, line)
if match:
return device_class(
name=match.group(1),
macs=match.group(2),
interface=match.group(3),
dest_mac=match.group(4),
bridge=match.group(5),
vitesse=match.group(6),
nb_liens=match.group(7)
)
print(f" -> Aucun pattern ne correspond à cette ligne: {line}")
return None
def parse(self) -> Tuple[List[Coeur], List[Switch]]:
"""Parse le fichier et retourne les coeurs et switches."""
content = self._read_file_with_encoding()
if content is None:
return [], []
sections = content.split('Switches:')
if len(sections) < 2:
return [], []
coeur_section = sections[0].replace('Coeur:', '').strip()
switches_section = sections[1].strip()
coeurs = []
for line in coeur_section.split('\n'):
coeur = self._parse_line(line, Coeur)
if coeur:
coeurs.append(coeur)
switches = []
for line in switches_section.split('\n'):
switch = self._parse_line(line, Switch)
if switch:
switches.append(switch)
return coeurs, switches
class NetworkDeviceGrouper:
"""Classe pour grouper les équipements réseau."""
@staticmethod
def group_coeurs_by_dest_mac(coeurs: List[Coeur]) -> List[Coeur]:
"""Groupe les coeurs par adresse MAC de destination."""
grouped = defaultdict(list)
for coeur in coeurs:
key = (coeur.dest_mac, coeur.name, coeur.macs_str,
coeur.bridge, coeur.vitesse, coeur.nb_liens)
grouped[key].append(coeur)
result = []
for key, group in grouped.items():
dest_mac, name, macs_str, bridge, vitesse, nb_liens = key
interfaces = [item.interface for item in group]
result.append(Coeur(
name=name,
macs=macs_str.split(','),
interface='-'.join(interfaces),
dest_mac=dest_mac,
bridge=bridge,
vitesse=vitesse,
nb_liens=nb_liens
))
return result
@staticmethod
def group_switches_by_local_mac(switches: List[Switch]) -> List[Switch]:
"""Groupe les switches par adresse MAC locale."""
grouped = defaultdict(list)
for switch in switches:
key = (switch.name, switch.macs_str, switch.dest_mac,
switch.bridge, switch.vitesse, switch.nb_liens)
grouped[key].append(switch)
result = []
for key, group in grouped.items():
name, macs_str, dest_mac, bridge, vitesse, nb_liens = key
interfaces = [item.interface for item in group]
result.append(Switch(
name=name,
macs=macs_str.split(','),
interface='-'.join(interfaces),
dest_mac=dest_mac,
bridge=bridge,
vitesse=vitesse,
nb_liens=nb_liens
))
return result
class MermaidDiagramGenerator:
"""Classe pour générer les diagrammes Mermaid."""
def __init__(self, coeurs: List[Coeur], switches: List[Switch]):
self.coeurs = coeurs
self.switches = switches
def _find_matching_switch(self, coeur: Coeur) -> Optional[Switch]:
"""Trouve le switch correspondant à un coeur."""
for switch in self.switches:
if coeur.dest_mac in switch.macs:
return switch
return None
def _format_bridge_label(self, bridge: str, vitesse: str) -> str:
"""Formate le label du bridge."""
bridge_formatted = bridge.replace('Bridge-Aggregation', 'BAGG')
return f"{bridge_formatted}<br/>{vitesse}"
def generate_links_diagram(self) -> str:
"""Génère un diagramme Mermaid des liaisons."""
if not self.coeurs or not self.switches:
return "Aucune donnée à afficher"
mermaid_lines = ["graph LR"]
total_devices = min(len(self.coeurs), len(self.switches))
for i, coeur in enumerate(self.coeurs):
target_switch = self._find_matching_switch(coeur)
label = self._format_bridge_label(coeur.bridge, coeur.vitesse)
if target_switch:
if i < total_devices // 2:
line = f' Coeur(("{coeur.name}")) <-->|{label}| {target_switch.name}'
else:
line = f' {target_switch.name} <-->|{label}| Coeur(("{coeur.name}"))'
mermaid_lines.append(line)
else:
line = f' Coeur(("{coeur.name}")) <-->|{label}| {coeur.dest_mac}["📄manquant {coeur.dest_mac}"]'
mermaid_lines.append(line)
mermaid_lines.append(f' class {coeur.dest_mac} error;')
return '\n'.join(mermaid_lines)
class FileWriter:
"""Classe pour l'écriture de fichiers."""
@staticmethod
def write_mermaid_diagram(mermaid_code: str, output_path: Path) -> None:
"""Sauvegarde le diagramme Mermaid."""
try:
output_path.parent.mkdir(parents=True, exist_ok=True)
content = [
"# Diagramme des liaisons Coeur-Switch\n",
"```mermaid\n",
"---\n",
"config:\n",
" theme: 'base'\n",
" themeVariables:\n",
" primaryColor: '#25bb75ff'\n",
" primaryTextColor: '#ffffff'\n",
" primaryBorderColor: '#000000ff'\n",
" lineColor: '#f82929ff'\n",
" secondaryColor: '#5e0c1aff'\n",
" tertiaryColor: '#ffffff'\n",
"---\n",
mermaid_code,
"\nclass Coeur coeur;\n",
"classDef coeur fill:#0590e6;\n",
"classDef error fill:#e64c05;\n",
"\n```\n"
]
output_path.write_text(''.join(content), encoding='utf-8')
print(f"✅ Diagramme Mermaid généré : {output_path}")
except Exception as e:
print(f"Erreur lors de la sauvegarde: {e}")
@staticmethod
def write_grouped_file(coeurs: List[Coeur], switches: List[Switch], output_path: Path) -> None:
"""Écrit les équipements groupés dans un fichier."""
try:
lines = ["Coeur:\n"]
lines.extend(f"{coeur.to_formatted_string()}\n" for coeur in coeurs)
lines.append("Switches:\n")
lines.extend(f"{switch.to_formatted_string()}\n" for switch in switches)
output_path.write_text(''.join(lines), encoding='utf-8')
except Exception as e:
print(f"Erreur lors de la sauvegarde: {e}")
@staticmethod
def write_links_file(coeurs: List[Coeur], switches: List[Switch], output_path: Path) -> None:
"""Écrit les liens entre coeurs et switches."""
try:
lines = []
for coeur in coeurs:
matching_switch = None
for switch in switches:
if coeur.dest_mac in switch.macs:
matching_switch = switch
break
if matching_switch:
coeur_info = f"{coeur.name} [{coeur.macs_str}] {coeur.interface} [{coeur.bridge},{coeur.vitesse},{coeur.nb_liens}]"
switch_info = f"{matching_switch.name} [{matching_switch.macs_str}] {matching_switch.interface} [{matching_switch.bridge},{matching_switch.vitesse},{matching_switch.nb_liens}]"
lines.append(f"{coeur_info} -> {switch_info}\n")
else:
lines.append(f"{coeur.name} [{coeur.macs_str}] {coeur.interface} -> Aucune correspondance de switch pour MAC {coeur.dest_mac}\n")
output_path.write_text(''.join(lines), encoding='utf-8')
except Exception as e:
print(f"Erreur lors de l'écriture des liens: {e}")
class NetworkAnalyzer:
"""Classe principale pour l'analyse réseau."""
def __init__(self, base_dir: Path = None):
if base_dir is None:
base_dir = Path(__file__).parent.parent
self.base_dir = Path(base_dir)
self.data_file = self.base_dir / 'data.txt'
self.output_dir = self.base_dir / 'output'
self.mermaid_file = self.output_dir / 'mermaid.md'
def analyze(self, filename: str) -> None:
"""Analyse complète du réseau."""
# Exécute l'analyse initiale
FormatMain().run_analysis(filename)
# Parse le fichier
parser = NetworkFileParser(self.data_file)
coeurs, switches = parser.parse()
if not coeurs and not switches:
print("Impossible de lire le fichier ou format incorrect")
return
# Groupe les équipements
grouper = NetworkDeviceGrouper()
grouped_coeurs = grouper.group_coeurs_by_dest_mac(coeurs)
grouped_switches = grouper.group_switches_by_local_mac(switches)
# Écrit les fichiers de sortie
writer = FileWriter()
writer.write_grouped_file(grouped_coeurs, grouped_switches, self.data_file)
writer.write_links_file(grouped_coeurs, grouped_switches, self.data_file)
# Génère le diagramme Mermaid
diagram_generator = MermaidDiagramGenerator(grouped_coeurs, grouped_switches)
mermaid_code = diagram_generator.generate_links_diagram()
writer.write_mermaid_diagram(mermaid_code, self.mermaid_file)
def main():
"""Fonction principale."""
if len(sys.argv) != 2:
print("Usage: python mermaid.py <filename>")
sys.exit(1)
analyzer = NetworkAnalyzer()
analyzer.analyze(filename=sys.argv[1])
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,535 @@
from dataclasses import dataclass, field
from typing import List
@dataclass
class MacAddress:
"""Entrée de table MAC"""
mac: str
vlan: str
state: str
port: str
aging: str
@dataclass
class Arp:
"""Entrée de table ARP"""
ip: str
mac: str
vlan: str
interface: str
aging: str
type: str
@dataclass
class Route:
"""Entrée de table de routage"""
destination: str
protocol: str
preference: str
cost: str
nexthop: str
interface: str
@dataclass
class FIB:
"""Entrée de table de commutation (FIB)"""
destination: str
nexthop: str
flag: str
interface: str
label: str
@dataclass
class SlotInfo:
"""Informations d'un slot"""
slot: int
uptime: str = None
board_type: str = None
release_version: str = None
patch_version: str = None
reboot_cause: str = None
@dataclass
class VersionInfo:
"""Informations de version"""
version: str = None
release: str = None
model: str = None
uptime: str = None
boot_image: str = None
boot_version: str = None
boot_release: str = None
slots: List[SlotInfo] = None
def __post_init__(self):
if self.slots is None:
self.slots = []
@dataclass
class ComponentInfo:
"""Informations d'un composant (fan, power)"""
type: str
id: int
device_name: str = None
device_serial_number: str = None
manufacturing_date: str = None
vendor_name: str = None
@dataclass
class SlotManuInfo:
"""Informations de fabrication d'un slot"""
slot: int
cpu: int = 0
device_name: str = None
device_serial_number: str = None
mac_address: str = None
manufacturing_date: str = None
vendor_name: str = None
product_number: str = None
components: List[ComponentInfo] = None
def __post_init__(self):
if self.components is None:
self.components = []
@dataclass
class ManuInfo:
"""Informations de fabrication du device"""
slots: List[SlotManuInfo] = None
def __post_init__(self):
if self.slots is None:
self.slots = []
@dataclass
class Power:
"""Entrée d'alimentation"""
slot: int
power_id: str
state: str
mode: str
@dataclass
class Fan:
"""Informations d'un ventilateur"""
fan_id: str = None
state: str = None
airflow_direction: str = None
prefer_airflow_direction: str = None
@dataclass
class SlotFanInfo:
"""Informations des ventilateurs d'un slot"""
slot: int
fans: List[Fan] = None
def __post_init__(self):
if self.fans is None:
self.fans = []
@dataclass
class Sensor:
"""Informations d'un capteur de température"""
sensor: str
temperature: str
@dataclass
class SlotEnvInfo:
"""Informations environnementales d'un slot"""
slot: int
sensors: List[Sensor] = None
def __post_init__(self):
if self.sensors is None:
self.sensors = []
@dataclass
class EnvironmentInfo:
"""Informations environnementales du device"""
unit: str = None
slots: List[SlotEnvInfo] = None
def __post_init__(self):
if self.slots is None:
self.slots = []
@dataclass
class SlotBootInfo:
"""Informations de boot d'un slot"""
slot: int
current: List[str] = None
main: List[str] = None
backup: List[str] = None
def __post_init__(self):
if self.current is None:
self.current = []
if self.main is None:
self.main = []
if self.backup is None:
self.backup = []
@dataclass
class IrfMember:
"""Membre IRF"""
member_id: int
role: str
priority: int
@dataclass
class IrfLink:
"""Lien IRF"""
state: str
neighbor: int
@dataclass
class IrfTopology:
"""Entrée de topologie IRF"""
member_id: int
links: List[IrfLink] = None
def __post_init__(self):
if self.links is None:
self.links = []
@dataclass
class IrfConfiguration:
"""Configuration IRF d'un membre"""
member_id: int
irf_port1: List[str] = None
irf_port2: List[str] = None
def __post_init__(self):
if self.irf_port1 is None:
self.irf_port1 = []
if self.irf_port2 is None:
self.irf_port2 = []
@dataclass
class CpuUsage:
"""Utilisation CPU"""
sec5: float = None
min1: float = None
min5: float = None
@dataclass
class CpuProcessInfo:
"""Informations CPU et processus"""
slot: int
cpu: CpuUsage = None
raw_table: List[str] = None
def __post_init__(self):
if self.cpu is None:
self.cpu = CpuUsage()
if self.raw_table is None:
self.raw_table = []
@dataclass
class ProcessInfo:
"""Informations des processus"""
slot: int
raw_table: List[str] = None
def __post_init__(self):
if self.raw_table is None:
self.raw_table = []
@dataclass
class Memory:
"""Informations mémoire d'un slot"""
slot: int
total: int
used: int
free: int
free_ratio: float
@dataclass
class TransceiverDiag:
"""Diagnostic d'un transceiver"""
temp: float
voltage: float
bias: float
rx_power: float
tx_power: float
@dataclass
class Transceiver:
"""Informations d'un transceiver"""
interface: str
current: TransceiverDiag = None
@dataclass
class TransceiverInterface:
"""Informations d'interface d'un transceiver"""
interface: str
status: str = None
transceiver_type: str = None
connector_type: str = None
wavelength_nm: int = None
digital_diagnostic_monitoring: str = None
vendor_name: str = None
ordering_name: str = None
vendor_part_number: str = None
@dataclass
class Log:
"""Entrée de log"""
raw: List[str]
@dataclass
class Multicast:
"""Entrée brute"""
raw: str
@dataclass
class Qos:
"""Entrée brute"""
raw: str
@dataclass
class Aaa:
"""Entrée brute"""
raw: str
@dataclass
class StpGlobal:
"""Informations STP globales"""
mode: str = None
bridge_id: str = None
priority: str = None
bridge_times: str = None
root_id: str = None
root_port_id: str = None
bpdu_protection: str = None
tc_received: int = None
last_tc: str = None
@dataclass
class StpPort:
"""Informations STP d'un port"""
port_id_full: int
port_name: str
status: str
protocol: str = None
role: str = None
port_id: str = None
edged: str = None
mst_bpdu: str = None
rapid_transition: str = None
vlans_mapped: int = None
port_times: str = None
bpdu_sent: int = None
bpdu_received: int = None
@dataclass
class StpInfo:
"""Informations STP"""
global_info: StpGlobal = None
ports: List[StpPort] = None
def __post_init__(self):
if self.global_info is None:
self.global_info = StpGlobal()
if self.ports is None:
self.ports = []
@dataclass
class InterfaceCounter:
"""Compteur d'interface"""
raw: str
@dataclass
class NetworkInterface:
"""Interface réseau H3C"""
name: str
state: str = None
protocol_state: str = None
description: str = None
bandwidth_kbps: int = None
speed_duplex: str = None
media: str = None
hardware: str = None
flow_control: str = None
mtu: str = None
jumbo: bool = False
link_type: str = None
pvid: str = None
ip_address: str = None
vlan_passing: list = field(default_factory=list)
vlan_permitted: list = field(default_factory=list)
untagged_vlan: str = None
counters_cleared_time: str = None
counters: list = field(default_factory=list)
def __post_init__(self):
if self.vlan_passing is None:
self.vlan_passing = []
if self.vlan_permitted is None:
self.vlan_permitted = []
if self.counters is None:
self.counters = []
@dataclass
class LinkAggregation:
"""Informations d'agrégation de liens"""
interface: str
mode: str = None
loadsharing: str = None
local: list = field(default_factory=list)
remote: list = field(default_factory=list)
def __post_init__(self):
if self.local is None:
self.local = []
if self.remote is None:
self.remote = []
@dataclass
class ConfigVlan:
id: str
name: str = None
description: str = None
@dataclass
class ConfigIrfPort:
id: str
members: list = field(default_factory=list)
def __post_init__(self):
if self.members is None:
self.members = []
@dataclass
class ConfigInterface:
name: str
description: str = None
shutdown: bool = False
link_mode: str = None
link_type: str = None
ip_address: str = None
dhcp: dict = None
vlans_permitted: list = field(default_factory=list)
access_vlan: str = None
aggregation_group: str = None
packet_filter: list = field(default_factory=list)
stp_disabled: bool = False
raw: list = field(default_factory=list)
def __post_init__(self):
if self.dhcp is None:
self.dhcp = {}
if self.vlans_permitted is None:
self.vlans_permitted = []
if self.packet_filter is None:
self.packet_filter = []
if self.raw is None:
self.raw = []
@dataclass
class ConfigAcl:
id: str
type: str = None
description: str = None
rules: list = field(default_factory=list)
def __post_init__(self):
if self.rules is None:
self.rules = []
@dataclass
class ConfigUser:
name: str
user_class: str = None
password_hash: str = None
service_type: List[str] = None
roles: list = field(default_factory=list)
def __post_init__(self):
if self.service_type is None:
self.service_type = []
if self.roles is None:
self.roles = []
@dataclass
class ConfigSnmp:
engine_id: str = None
communities_read: list = field(default_factory=list)
contact: str = None
location: str = None
version: str = None
groups: list = field(default_factory=list)
trap_targets: list = field(default_factory=list)
users: list = field(default_factory=list)
mib_views: list = field(default_factory=list)
def __post_init__(self):
if self.communities_read is None:
self.communities_read = []
if self.groups is None:
self.groups = []
if self.trap_targets is None:
self.trap_targets = []
if self.users is None:
self.users = []
if self.mib_views is None:
self.mib_views = []
@dataclass
class DeviceConfiguration:
hostname: str = None
version: str = None
release: str = None
clock: dict = None
dhcp: dict = None
lldp: dict = None
ssh: dict = None
sftp: dict = None
scp: dict = None
ntp: dict = None
stp: dict = None
snmp: ConfigSnmp = None
vlans: List[ConfigVlan] = None
irf_ports: List[ConfigIrfPort] = None
interfaces: List[ConfigInterface] = None
acls: List[ConfigAcl] = None
routes_statiques: List[str] = None
local_users: List[ConfigUser] = None
header_legal: List[str] = None
header_motd: List[str] = None
def __post_init__(self):
if self.clock is None:
self.clock = {}
if self.dhcp is None:
self.dhcp = {}
if self.lldp is None:
self.lldp = {}
if self.ssh is None:
self.ssh = {}
if self.sftp is None:
self.sftp = {}
if self.scp is None:
self.scp = {}
if self.ntp is None:
self.ntp = {}
if self.stp is None:
self.stp = {}
if self.snmp is None:
self.snmp = ConfigSnmp()
if self.vlans is None:
self.vlans = []
if self.irf_ports is None:
self.irf_ports = []
if self.interfaces is None:
self.interfaces = []
if self.acls is None:
self.acls = []
if self.routes_statiques is None:
self.routes_statiques = []
if self.local_users is None:
self.local_users = []
if self.header_legal is None:
self.header_legal = []
if self.header_motd is None:
self.header_motd = []

View File

@@ -1,448 +0,0 @@
import os
import re
import sys
import json
import logging
from typing import Dict, List, Optional, Union, Any
from dataclasses import dataclass
from pathlib import Path
import pandas as pd
from openpyxl import load_workbook
from scripts.extract_json import process_file_return_json
mac_coeur=[]
@dataclass
class Config:
"""Configuration centralisée pour l'application."""
LOGS_DIR: str = './src/logs'
OUTPUT_DIR: str = './src/output'
DATA_JSON_PATH: str = './src/data.json'
OUTPUT_FILE_NAME: str = 'uplink_report.xlsx'
@property
def output_file_path(self) -> str:
return os.path.join(self.OUTPUT_DIR, self.OUTPUT_FILE_NAME)
@dataclass
class InterfaceResult:
"""Résultat d'analyse d'une interface."""
switch: str
logfile: str
interface: str
status: str
speed_gbps: Optional[Union[int, float, str]]
port_channel: Optional[str]
description: str
issues: str
mac_local: Optional[List[str]]
mac_destination: Optional[str]
bridge_name: Optional[str]
bridge_speed: Optional[Union[int, float, str]]
nb_liens: Optional[int]
@dataclass
class LCInterfaceResult:
"""Résultat d'analyse d'une interface LC."""
switch: str
interface: str
status: str
speed_gbps: Optional[Union[int, float, str]]
port_channel: Optional[str]
description: str
type_lien: str
nb_liens: Optional[int]
bridge_utilise: Optional[str]
mac_destination: Optional[str]
switch_destination: str
class InterfaceAnalyzer:
"""Analyseur d'interfaces réseau."""
CORE_INTERLINK_PATTERN = re.compile(r'/0/(49|50)$')
SPEED_PATTERN = re.compile(r"(\d+(?:\.\d+)?)\s*Gbps", re.I)
SHORT_NAME_PATTERN = re.compile(r'(\d+/\d+/\d+)$')
INTERCORE_PATTERN = re.compile(r'[1-4]/0/4[3-8]$')
CORE_INTERFACE_PATTERN = re.compile(r'/0/(4[89]|50)$')
@classmethod
def is_core_interlink(cls, interface_name: str) -> bool:
"""Détermine si l'interface est un lien inter-cœur."""
return cls.CORE_INTERLINK_PATTERN.search(interface_name) is not None
@classmethod
def is_intercore_link(cls, interface_name: str) -> bool:
"""Détermine si l'interface est un lien inter-cœur (LC)."""
return cls.INTERCORE_PATTERN.search(interface_name) is not None
@classmethod
def guess_speed(cls, speed_mode: Optional[str], interface_name: Optional[str] = None) -> Optional[Union[int, float, str]]:
"""Devine la vitesse d'une interface."""
if speed_mode:
match = cls.SPEED_PATTERN.match(speed_mode)
if match:
return float(match.group(1))
if interface_name and cls.CORE_INTERFACE_PATTERN.search(interface_name):
if "Ten-GigabitEthernet" in interface_name:
return 10
elif "GigabitEthernet" in interface_name:
return 1
elif "HundredGigE" in interface_name:
return 100
elif "M-GigabitEthernet" in interface_name:
return "?"
return None
@classmethod
def extract_short_name(cls, interface_name: str) -> str:
"""Extrait le nom court d'une interface."""
match = cls.SHORT_NAME_PATTERN.search(interface_name)
return match.group(1) if match else interface_name
@classmethod
def identify_issues(cls, info: Dict[str, Any], speed: Optional[Union[int, float, str]]) -> List[str]:
"""Identifie les problèmes potentiels d'une interface."""
issues = []
if info.get("current_state") is not None:
if info.get("current_state", "").upper() != "UP":
issues.append("DOWN")
if isinstance(speed, (int, float)) and speed < 10:
issues.append(f"Poss. goulot ({speed} Gbps)")
if info.get("port_channel"):
issues.append(f"Membre Port-Channel {info['port_channel']}")
return issues
class SwitchLogAnalyzer:
"""Analyseur de logs de switchs."""
def __init__(self, config: Config):
self.config = config
self.analyzer = InterfaceAnalyzer()
self.logger = self._setup_logger()
def _setup_logger(self) -> logging.Logger:
"""Configure le logger."""
logger = logging.getLogger(__name__)
if not logger.handlers:
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
return logger
def analyze_switch_log(
self,
filename: str,
switch_name: str,
interfaces: Dict[str, Any],
mac_addresses: Optional[List[str]] = None,
is_core: bool = False,
filter_mac_destination: bool = True
) -> List[InterfaceResult]:
"""Analyse les interfaces d'un switch."""
results = []
for iface_name, info in interfaces.items():
if not self._should_process_interface(info, filter_mac_destination, is_core, iface_name):
continue
result = self._create_interface_result(
filename, switch_name, iface_name, info, interfaces, mac_addresses
)
results.append(result)
return results
def _should_process_interface(
self,
info: Dict[str, Any],
filter_mac_destination: bool,
is_core: bool,
iface_name: str
) -> bool:
"""Détermine si une interface doit être traitée."""
global mac_coeur
if filter_mac_destination and info.get("mac_destination") not in mac_coeur:
return False
if is_core and not self.analyzer.is_core_interlink(iface_name):
return False
return True
def _create_interface_result(
self,
filename: str,
switch_name: str,
iface_name: str,
info: Dict[str, Any],
interfaces: Dict[str, Any],
mac_addresses: Optional[List[str]]
) -> InterfaceResult:
"""Crée un résultat d'interface."""
mac_destination = info.get("mac_destination")
bridge_name = info.get("bridge_name")
bridge_info = interfaces.get(bridge_name, {}) if bridge_name else {}
speed = self.analyzer.guess_speed(info.get("speed_mode"), iface_name)
bridge_speed = self.analyzer.guess_speed(bridge_info.get("speed_mode"), bridge_name)
issues = self.analyzer.identify_issues(info, speed)
description = info.get("description") or info.get("config_description") or ""
return InterfaceResult(
switch=switch_name,
logfile=filename,
interface=iface_name,
status=info.get("current_state", "unknown"),
speed_gbps=speed,
port_channel=info.get("port_channel"),
description=description,
issues=", ".join(issues) if issues else "RAS",
mac_local=mac_addresses,
mac_destination=mac_destination,
bridge_name=bridge_name,
bridge_speed=bridge_speed,
nb_liens=bridge_info.get("nb_liens")
)
def analyze_lc_log(self, filename: str, switch_name: str, interfaces: Dict[str, Any]) -> List[LCInterfaceResult]:
"""Analyse les interfaces LC."""
results = []
for iface_name, info in interfaces.items():
if not info or not isinstance(info, dict):
continue
result = self._create_lc_interface_result(filename, switch_name, iface_name, info)
results.append(result)
return results
def _create_lc_interface_result(
self,
filename: str,
switch_name: str,
iface_name: str,
info: Dict[str, Any]
) -> LCInterfaceResult:
"""Crée un résultat d'interface LC."""
speed = self.analyzer.guess_speed(info.get("speed_mode"), iface_name)
type_lien = "Lien inter-coeur" if self.analyzer.is_intercore_link(iface_name) else "Vers Accès"
description = info.get("description") or info.get("config_description") or ""
nb_liens = info.get("nb_liens") if iface_name.startswith("Bridge-Aggregation") else None
bridge_utilise = None if iface_name.startswith("Bridge-Aggregation") else info.get("bridge_name")
mac_destination = None if iface_name.startswith("Bridge-Aggregation") else info.get("mac_destination")
return LCInterfaceResult(
switch=switch_name,
interface=iface_name,
status=info.get("current_state", "unknown"),
speed_gbps=speed,
port_channel=info.get("port_channel"),
description=description,
type_lien=type_lien,
nb_liens=nb_liens,
bridge_utilise=bridge_utilise,
mac_destination=mac_destination,
switch_destination=""
)
class ExcelReportGenerator:
"""Générateur de rapports Excel."""
def __init__(self, config: Config):
self.config = config
self.logger = logging.getLogger(__name__)
def generate_report(self, uplink_results: List[InterfaceResult], lc_results: List[LCInterfaceResult]) -> None:
"""Génère le rapport Excel."""
df_uplink = self._create_uplink_dataframe(uplink_results)
df_lc = self._create_lc_dataframe(lc_results)
os.makedirs(self.config.OUTPUT_DIR, exist_ok=True)
self._write_excel_file(df_uplink, df_lc)
self._format_excel_file()
print(f"✅ Rapport Excel généré : {self.config.output_file_path}")
def _create_uplink_dataframe(self, results: List[InterfaceResult]) -> pd.DataFrame:
"""Crée le DataFrame pour les uplinks."""
data = []
for result in results:
data.append({
"switch": result.switch,
"logfile": result.logfile,
"interface": result.interface,
"status": result.status,
"speed_gbps": result.speed_gbps,
"port_channel": result.port_channel,
"description": result.description,
"issues": result.issues,
"mac_local": result.mac_local,
"mac_destination": result.mac_destination,
"bridge_name": result.bridge_name,
"bridge_speed": result.bridge_speed,
"nb_liens": result.nb_liens
})
return pd.DataFrame(data)
def _create_lc_dataframe(self, results: List[LCInterfaceResult]) -> pd.DataFrame:
"""Crée le DataFrame pour les interfaces LC."""
data = []
for result in results:
data.append({
"Switch": result.switch,
"Interface": result.interface,
"Status": result.status,
"Vitesse (Gbps)": result.speed_gbps,
"Port-Channel": result.port_channel,
"Description": result.description,
"Type de lien": result.type_lien,
"Nb liens": result.nb_liens,
"Bridge utilisé": result.bridge_utilise,
"MAC destination": result.mac_destination,
"Switch destination": result.switch_destination
})
return pd.DataFrame(data)
def _write_excel_file(self, df_uplink: pd.DataFrame, df_lc: pd.DataFrame) -> None:
"""Écrit le fichier Excel."""
with pd.ExcelWriter(self.config.output_file_path, engine='openpyxl') as writer:
df_uplink.to_excel(writer, index=False, sheet_name="Uplinks")
df_lc.to_excel(writer, index=False, sheet_name="LC_Interfaces")
def _format_excel_file(self) -> None:
"""Met en forme le fichier Excel."""
wb = load_workbook(self.config.output_file_path)
self._add_formulas(wb)
self._format_columns(wb)
wb.save(self.config.output_file_path)
def _add_formulas(self, workbook) -> None:
"""Ajoute les formules Excel."""
ws = workbook["LC_Interfaces"]
for row in range(2, 400):
formula = (
f'=IF(J{row}="","",IFERROR(INDEX(Uplinks!A$2:A$400,'
f'MATCH(TRUE,ISNUMBER(SEARCH(J{row},Uplinks!I$2:I$400)),0)),""))'
)
ws[f'K{row}'] = formula
def _format_columns(self, workbook) -> None:
"""Met en forme les colonnes."""
column_widths = {
"LC_Interfaces": [15, 25, 25, 15, 12, 45, 15, 10, 22, 20, 20],
"Uplinks": [15, 30, 25, 7, 12, 12, 30, 22, 47, 15, 20, 13, 10]
}
for sheet_name, widths in column_widths.items():
ws = workbook[sheet_name]
for col_idx, width in enumerate(widths, start=1):
ws.column_dimensions[chr(64 + col_idx)].width = width
class UplinkReportGenerator:
"""Générateur principal de rapports d'uplink."""
def __init__(self, config: Optional[Config] = None):
self.config = config or Config()
self.analyzer = SwitchLogAnalyzer(self.config)
self.report_generator = ExcelReportGenerator(self.config)
self.logger = logging.getLogger(__name__)
def generate_report(self, lc_filename_prefix: str) -> None:
"""Génère le rapport complet."""
try:
uplink_results, lc_results = self._process_log_files(lc_filename_prefix)
self.report_generator.generate_report(uplink_results, lc_results)
except Exception as e:
self.logger.error(f"Erreur lors de la génération du rapport : {e}")
raise
def _process_log_files(self, lc_filename_prefix: str) -> tuple[List[InterfaceResult], List[LCInterfaceResult]]:
"""Traite tous les fichiers de logs."""
global mac_coeur
uplink_results = []
lc_results = []
log_files = self._get_log_files()
for filename in log_files:
try:
data = self._process_single_log_file(filename)
if not data:
continue
interfaces = data.get("data", {}).get("interfaces", {})
switch_name = data.get("metadata", {}).get("switch_name", "unknown")
if filename.startswith(lc_filename_prefix):
mac_coeur = data.get("metadata", {}).get("mac_addresses", [])
mac_coeur = [mac.lower() for mac in mac_coeur]
lc_results.extend(self.analyzer.analyze_lc_log(filename, switch_name, interfaces))
else:
mac_addresses = data.get("metadata", {}).get("mac_addresses", [])
uplink_results.extend(
self.analyzer.analyze_switch_log(
filename, switch_name, interfaces,
mac_addresses=mac_addresses,
filter_mac_destination=True
)
)
except Exception as e:
self.logger.error(f"Erreur lors du traitement de {filename}: {e}")
continue
return uplink_results, lc_results
def _get_log_files(self) -> List[str]:
"""Récupère la liste des fichiers de logs."""
if not os.path.exists(self.config.LOGS_DIR):
raise FileNotFoundError(f"Le répertoire {self.config.LOGS_DIR} n'existe pas")
return [f for f in os.listdir(self.config.LOGS_DIR) if f.endswith('.log')]
def _process_single_log_file(self, filename: str) -> Optional[Dict[str, Any]]:
"""Traite un fichier de log individuel."""
filepath = os.path.join(self.config.LOGS_DIR, filename)
return process_file_return_json(filepath)
def main():
"""Fonction principale."""
if len(sys.argv) < 2:
print("Usage: python parse_uplinks.py <fichier_log_coeur> (sans chemin)")
sys.exit(1)
lc_filename_prefix = sys.argv[1]
try:
generator = UplinkReportGenerator()
generator.generate_report(lc_filename_prefix)
except Exception as e:
print(f"❌ Erreur : {e}")
sys.exit(1)
if __name__ == "__main__":
main()