[ssip]: Add YANG model (#10992)
- Why I did it To implement Syslog Source IP feature based on HLD: https://github.com/sonic-net/SONiC/pull/1002 - How I did it Added the relevant yang model - How to verify it Added unit test Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
This commit is contained in:
parent
e9fee8635c
commit
9b59ee0e79
@ -426,9 +426,21 @@
|
|||||||
"2001:aa:aa::aa": {}
|
"2001:aa:aa::aa": {}
|
||||||
},
|
},
|
||||||
"SYSLOG_SERVER" : {
|
"SYSLOG_SERVER" : {
|
||||||
"10.13.14.17": {},
|
"10.13.14.17": {
|
||||||
"20.1.1.1": {},
|
"source": "1.1.1.1",
|
||||||
"2001:aa:aa::aa": {}
|
"port": "514",
|
||||||
|
"vrf": "default"
|
||||||
|
},
|
||||||
|
"20.1.1.1": {
|
||||||
|
"source": "1.1.1.1",
|
||||||
|
"port": "514",
|
||||||
|
"vrf": "mgmt"
|
||||||
|
},
|
||||||
|
"2001:aa:aa::aa": {
|
||||||
|
"source": "1111::1111",
|
||||||
|
"port": "514",
|
||||||
|
"vrf": "Vrf_blue"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"CABLE_LENGTH": {
|
"CABLE_LENGTH": {
|
||||||
"AZURE": {
|
"AZURE": {
|
||||||
|
@ -1,4 +1,27 @@
|
|||||||
{
|
{
|
||||||
|
"SYSLOG_SERVER_VALID": {
|
||||||
|
"desc": "Configure SYSLOG_SERVER."
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_SOURCE": {
|
||||||
|
"desc": "Configure invalid SOURCE in SYSLOG_SERVER.",
|
||||||
|
"eStrKey": "InvalidValue"
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_SOURCE_IP_FAMILY_MISMATCH": {
|
||||||
|
"desc": "Configure SOURCE IP family mismatch in SYSLOG_SERVER.",
|
||||||
|
"eStrKey": "Must"
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_PORT": {
|
||||||
|
"desc": "Configure invalid PORT in SYSLOG_SERVER.",
|
||||||
|
"eStrKey": "InvalidValue"
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_VRF": {
|
||||||
|
"desc": "Configure invalid VRF in SYSLOG_SERVER.",
|
||||||
|
"eStrKey": "InvalidValue"
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_DISABLED_MGMT_VRF": {
|
||||||
|
"desc": "Configure disabled management VRF in SYSLOG_SERVER.",
|
||||||
|
"eStrKey": "Must"
|
||||||
|
},
|
||||||
"SYSLOG_SERVER_TEST": {
|
"SYSLOG_SERVER_TEST": {
|
||||||
"desc": "Load syslog server table with ipv4 address as syslog servers."
|
"desc": "Load syslog server table with ipv4 address as syslog servers."
|
||||||
},
|
},
|
||||||
@ -14,5 +37,4 @@
|
|||||||
"desc": "Load syslog server table with invalid ipv6 address as syslog server.",
|
"desc": "Load syslog server table with invalid ipv6 address as syslog server.",
|
||||||
"eStrKey": "InvalidValue"
|
"eStrKey": "InvalidValue"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -1,4 +1,113 @@
|
|||||||
{
|
{
|
||||||
|
"SYSLOG_SERVER_VALID": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"source": "1.1.1.1",
|
||||||
|
"port": "514",
|
||||||
|
"vrf": "default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"server_address": "200.0.0.1",
|
||||||
|
"source": "1.1.1.1",
|
||||||
|
"port": "514",
|
||||||
|
"vrf": "mgmt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"server_address" : "2000::1",
|
||||||
|
"source": "1111::1111",
|
||||||
|
"port": "514",
|
||||||
|
"vrf": "Vrf-Data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sonic-mgmt_vrf:sonic-mgmt_vrf": {
|
||||||
|
"sonic-mgmt_vrf:MGMT_VRF_CONFIG": {
|
||||||
|
"sonic-mgmt_vrf:vrf_global": {
|
||||||
|
"mgmtVrfEnabled": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sonic-vrf:sonic-vrf": {
|
||||||
|
"sonic-vrf:VRF": {
|
||||||
|
"VRF_LIST": [
|
||||||
|
{
|
||||||
|
"name": "Vrf-Data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_SOURCE": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"source": "invalid_value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_SOURCE_IP_FAMILY_MISMATCH": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"source": "1111::1111"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_PORT": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"port": "65536"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_INVALID_VRF": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"vrf": "invalid_value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SYSLOG_SERVER_DISABLED_MGMT_VRF": {
|
||||||
|
"sonic-syslog:sonic-syslog": {
|
||||||
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
"SYSLOG_SERVER_LIST": [
|
||||||
|
{
|
||||||
|
"server_address": "100.0.0.1",
|
||||||
|
"vrf": "mgmt"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sonic-mgmt_vrf:sonic-mgmt_vrf": {
|
||||||
|
"sonic-mgmt_vrf:MGMT_VRF_CONFIG": {
|
||||||
|
"sonic-mgmt_vrf:vrf_global": {
|
||||||
|
"mgmtVrfEnabled": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"SYSLOG_SERVER_TEST": {
|
"SYSLOG_SERVER_TEST": {
|
||||||
"sonic-syslog:sonic-syslog": {
|
"sonic-syslog:sonic-syslog": {
|
||||||
"sonic-syslog:SYSLOG_SERVER": {
|
"sonic-syslog:SYSLOG_SERVER": {
|
||||||
|
@ -9,22 +9,72 @@ module sonic-syslog {
|
|||||||
prefix inet;
|
prefix inet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import sonic-mgmt_vrf {
|
||||||
|
prefix mvrf;
|
||||||
|
}
|
||||||
|
|
||||||
|
import sonic-vrf {
|
||||||
|
prefix vrf;
|
||||||
|
}
|
||||||
|
|
||||||
|
description "Syslog YANG Module for SONiC OS: remote syslog logging";
|
||||||
|
|
||||||
|
revision 2022-04-18 {
|
||||||
|
description "Initial revision.";
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef vrf-device {
|
||||||
|
description "Represents syslog VRF device";
|
||||||
|
type enumeration {
|
||||||
|
enum default;
|
||||||
|
enum mgmt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container sonic-syslog {
|
container sonic-syslog {
|
||||||
|
|
||||||
container SYSLOG_SERVER {
|
container SYSLOG_SERVER {
|
||||||
|
|
||||||
description "SYSLOG SERVER part of config_db.json";
|
description "SYSLOG_SERVER part of config_db.json";
|
||||||
|
|
||||||
list SYSLOG_SERVER_LIST {
|
list SYSLOG_SERVER_LIST {
|
||||||
|
|
||||||
key "server_address";
|
key "server_address";
|
||||||
|
|
||||||
leaf server_address {
|
leaf server_address {
|
||||||
description "syslog server ip address";
|
description "Syslog server IP address";
|
||||||
type inet:ip-address;
|
type inet:ip-address;
|
||||||
}
|
}
|
||||||
} /* end of list SYSLOG_SERVER_LIST */
|
|
||||||
|
|
||||||
} /* end of container SYSLOG_SERVER */
|
leaf source {
|
||||||
|
description "Syslog source IP address";
|
||||||
|
type inet:ip-address;
|
||||||
|
must "(contains(current(), '.') and contains(../server_address, '.'))
|
||||||
|
or (contains(current(), ':') and contains(../server_address, ':'))";
|
||||||
|
}
|
||||||
|
|
||||||
|
leaf port {
|
||||||
|
description "Syslog server UDP port";
|
||||||
|
type inet:port-number;
|
||||||
|
}
|
||||||
|
|
||||||
|
leaf vrf {
|
||||||
|
description "Syslog VRF device";
|
||||||
|
type union {
|
||||||
|
type leafref {
|
||||||
|
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
|
||||||
|
}
|
||||||
|
type vrf-device;
|
||||||
|
}
|
||||||
|
must "(current() != 'mgmt')
|
||||||
|
or (/mvrf:sonic-mgmt_vrf/mvrf:MGMT_VRF_CONFIG/mvrf:vrf_global/mvrf:mgmtVrfEnabled = 'true')";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* end of list SYSLOG_SERVER_LIST */
|
||||||
|
}
|
||||||
|
/* end of container SYSLOG_SERVER */
|
||||||
}
|
}
|
||||||
|
/* end of container sonic-syslog */
|
||||||
}
|
}
|
||||||
|
/* end of module sonic-syslog */
|
||||||
|
Reference in New Issue
Block a user