Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YANG][SNMP]: Add YANG model for SNMP_AGENT_ADDRESS_CONFIG table #15587

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 35 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,40 @@
"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_EMPTY_PORT_NUMBER": {
"desc": "Load SNMP agent address config with empty port number"
},
"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"]
}
}

121 changes: 121 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,126 @@
]
}
}
},
"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_EMPTY_PORT_NUMBER": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_AGENT_ADDRESS_CONFIG": {
"SNMP_AGENT_ADDRESS_LIST": [
{
"agent_ip": "10.0.0.1",
"port": "",
"vrf_name": "mgmt"
}
]
}
}
},
"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": ""
}
]
}
}
}
}
43 changes: 43 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,42 @@ 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 union {
type string {
pattern '';
}
type inet:port-number;
}
default "";
description "SNMP agent listening port number";
}
leaf vrf_name {
type union {
type string {
pattern '';
Copy link
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
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
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
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_-]+";
}
}
default "";
description "VRF name";
}
}
}
}
}