Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/snmp.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,37 @@
"SNMP_USER_PRIV_LONG_ENCRYPT_PASS_NEG_TEST": {
"desc": "Load SNMP user with user type Priv with long encryption password",
"eStrKey": "Range"
},
"SNMP_AGENT_ADDRESS_CONFIG": {
"desc": "Load SNMP agent address config"
},
"SNMP_AGENT_ADDRESS_CONFIG_IPV6": {
"desc": "Load SNMP agent address config"
},
"SNMP_AGENT_ADDRESS_CONFIG_MGMT_VRF": {
"desc": "Load SNMP agent address config with mgmt vrf"
},
"SNMP_AGENT_ADDRESS_CONFIG_NO_VRF": {
"desc": "Load SNMP agent address config with no vrf",
"eStr": ["Missing required element"]
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_PORT": {
"desc": "Load SNMP agent address config with invalid port",
"eStrKey": "InvalidValue"
},
"SNMP_AGENT_ADDRESS_CONFIG_DUPLICATE_IP_PORT": {
"desc": "Load two SNMP agent address config same ip and port",
"eStr": ["Unique data leaf(s)"]
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_IPV4_ADDRESS": {
"desc": "Load SNMP agent address config with invalid IPv4 address",
"eStrKey": "InvalidValue",
"eStr": ["ip"]
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_IPV6_ADDRESS": {
"desc": "Load SNMP agent address config with invalid IPV6 address",
"eStrKey": "InvalidValue",
"eStr": ["ip"]
}
}

108 changes: 108 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/snmp.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,5 +502,113 @@
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "161",
"vrf_name": ""
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_IPV6": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "fd00::1",
"port": "161",
"vrf_name": ""
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_MGMT_VRF": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "161",
"vrf_name": "mgmt"
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_NO_VRF": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "161"
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_PORT": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "65536",
"vrf_name": "mgmt"
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_DUPLICATE_IP_PORT": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "161",
"vrf_name": "mgmt"
},
{
"agent_ip": "10.0.0.1",
"port": "161",
"vrf_name": ""
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_IPV4_ADDRESS": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "340.1.1.10",
"port": "161",
"vrf_name": ""
}
]
}
}
},
"SNMP_AGENT_ADDRESS_CONFIG_INVALID_IPV6_ADDRESS": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "2001:aa:aa:aa",
"port": "161",
"vrf_name": ""
}
]
}
}
}
}
36 changes: 36 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-snmp.yang
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module sonic-snmp {
prefix ssnmp;
yang-version 1.1;

import ietf-inet-types {
prefix inet;
}
import sonic-vrf {
prefix vrf;
}

organization
"SONiC";
Expand Down Expand Up @@ -156,5 +162,35 @@ module sonic-snmp {
}
}
}
container SNMP_AGENT_ADDRESS_CONFIG {
list SNMP_AGENT_ADDRESS_LIST {
key "agent_ip port vrf_name";
unique "agent_ip port";
description "List of SNMP agent listening IP Addresses and ports.";

leaf agent_ip {
type inet:ip-address;
description "SNMP agent listening IP";
}
leaf port {
type inet:port-number;
description "SNMP agent listening port number";
}
leaf vrf_name {
type union {
type string {
pattern '';
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jun 23, 2023

Choose a reason for hiding this comment

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

pattern

@ganglyu @wen587 I find empty string is weird. Is it going to impact gnmi path, impact json representation of ConfigDB? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason for empty string is because config CLI adds key in CONFIG_TABLE with empty string for vrf if it is not specified in the CLI argument.
https://github.com/sonic-net/sonic-utilities/blob/49fc3896a0ef907ff337467a3e04d2501ef850fd/config/main.py#L3084

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GNMI path can support it, need GCU to confirm.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GCU can support it.

}
type string {
pattern 'mgmt';
}
type string {
pattern "Vrf[a-zA-Z0-9_-]+";
}
}
description "VRF name";
}
}
}
}
}