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

add minpoll&maxpoll for NTP server in sonic-ntp.yang #16310

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,11 @@
"NTP_SERVER": {
"0.debian.pool.ntp.org": {},
"23.92.29.245": {},
"2001:aa:aa::aa": {}
"2001:aa:aa::aa": {},
"122.22.22.22": {
"minpoll": "7",
"maxpoll": "12"
}
},
"SYSLOG_SERVER" : {
"10.13.14.17": {
Expand Down
41 changes: 41 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/ntp.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,46 @@
"desc": "CONFIGURE NON-EXISTING MGMT INTERFACE AS NTP SOURCE INTERFACE.",
"eStrKey": "InvalidValue",
"eStr": ["src"]
},
"NTP_SERVER_WITH_DEFAULT_MINPOLL_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH DEFAULT VALUES OF MINPOLL AND MAXPOLL."
},
"NTP_SERVER_WITH_MIN_MINPOLL_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MIN VALUE FOR MINPOLL."
},
"NTP_SERVER_WITH_MINPOLL_MAX_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MAX VALUE FOR MAXPOLL."
},
"NTP_SERVER_NEG_WITHOUT_MINPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MAXPOLL BUT WITHOUT MINPOLL."
},
"NTP_SERVER_NEG_WITHOUT_MINPOLL_INVALID_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITHOUT MINPOLL AND INVALID MAXPOLL.",
"eStr": ["maxpoll has to be larger than minpoll."]
},
"NTP_SERVER_NEG_WITHOUT_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MINPOLL BUT WITHOUT MAXPOLL."
},
"NTP_SERVER_NEG_WITHOUT_MAXPOLL_INVALID_MINPOLL": {
"desc": "CONFIGURE NTP SERVER WITHOUT MAXPOLL AND INVALID MINPOLL.",
"eStr": ["maxpoll has to be larger than minpoll."]
},
"NTP_SERVER_NEG_MINPOLL_EQUAL_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MINPOLL EQUAL TO MAXPOLL.",
"eStr": ["maxpoll has to be larger than minpoll."]
},
"NTP_SERVER_NEG_MINPOLL_LARGER_THAN_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH MINPOLL LARGER THAN MAXPOLL.",
"eStr": ["maxpoll has to be larger than minpoll."]
},
"NTP_SERVER_NEG_INVALID_MINPOLL": {
"desc": "CONFIGURE NTP SERVER WITH INVALID MINPOLL VALUE.",
"eStrKey": "Range",
"eStr": "3..17"
},
"NTP_SERVER_NEG_INVALID_MAXPOLL": {
"desc": "CONFIGURE NTP SERVER WITH INVALID MAXPOLL VALUE.",
"eStrKey": "Range",
"eStr": "3..17"
}
}
139 changes: 139 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/ntp.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,144 @@
]
}
}
},
"NTP_SERVER_WITH_DEFAULT_MINPOLL_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "6",
"maxpoll": "10"
}
]
}
}
},
"NTP_SERVER_WITH_MIN_MINPOLL_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "3",
"maxpoll": "4"
}
]
}
}
},
"NTP_SERVER_WITH_MINPOLL_MAX_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "12",
"maxpoll": "17"
}
]
}
}
},
"NTP_SERVER_NEG_WITHOUT_MINPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"maxpoll": "11"
}
]
}
}
},
"NTP_SERVER_NEG_WITHOUT_MINPOLL_INVALID_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"maxpoll": "5"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between this test case and the one above?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, never mind, I see that since the default minpoll is 6, this returns an error.

}
]
}
}
},
"NTP_SERVER_NEG_WITHOUT_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "7"
}
]
}
}
},
"NTP_SERVER_NEG_WITHOUT_MAXPOLL_INVALID_MINPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "12"
}
]
}
}
},
"NTP_SERVER_NEG_MINPOLL_EQUAL_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "7",
"maxpoll": "7"
}
]
}
}
},
"NTP_SERVER_NEG_MINPOLL_LARGER_THAN_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "17",
"maxpoll": "16"
}
]
}
}
},
"NTP_SERVER_NEG_INVALID_MINPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "1",
"maxpoll": "16"
}
]
}
}
},
"NTP_SERVER_NEG_INVALID_MAXPOLL": {
"sonic-ntp:sonic-ntp": {
"sonic-ntp:NTP_SERVER": {
"NTP_SERVER_LIST": [
{
"server_address": "10.11.12.13",
"minpoll": "17",
"maxpoll": "18"
}
]
}
}
}
}
29 changes: 29 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-ntp.yang
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ module sonic-ntp {
leaf server_address {
type inet:host;
}

leaf minpoll {
must "(current()/../maxpoll > current())" {
error-message "maxpoll has to be larger than minpoll.";
}
default 6;
type uint8 {
range "3..17";
}
description
"The minimum poll interval used in this association.";
reference
"RFC 5905: Network Time Protocol Version 4: Protocol and Algorithms Specification";
}

leaf maxpoll {
must "(current()/../minpoll < current())" {
error-message "maxpoll has to be larger than minpoll.";
}
default 10;
type uint8 {
range "3..17";
}
description
"The maximum poll interval used in this association.";
reference
"RFC 5905: Network Time Protocol Version 4: Protocol and Algorithms Specification";
}

} /* end of list NTP_SERVER_LIST */

} /* end of container NTP_SERVER */
Expand Down