-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DNS] yang model for static DNS (#13834)
- Why I did it Add SONiC YANG model for DNS to provide the possibility to configure static DNS entries in Config DB. - How I did it Added sonic-dns.yang file that contains the YANG model for the static DNS configuration. - How to verify it This PR extends YANG model tests to cover DNS configuration. To run the test sonic_yang_models-1.0-py3-none-any.whl should be compiled.
- Loading branch information
1 parent
a81ffeb
commit a82e45a
Showing
6 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/sonic-yang-models/tests/yang_model_tests/tests/dns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"DNS_NAMESERVER_TEST" : { | ||
"desc": "DNS nameserver configuration in DNS_NAMESERVER table." | ||
}, | ||
"DNS_NAMESERVER_TEST_INVALID_IP" : { | ||
"desc": "DNS nameserver configuration with invalid IP value in DNS_NAMESERVER table.", | ||
"eStr": "Invalid value" | ||
}, | ||
"DNS_NAMESERVER_TEST_MAX_IP_NUMBER" : { | ||
"desc": "DNS nameserver configuration exceeds the maximum IPs in DNS_NAMESERVER table.", | ||
"eStr": "Too many elements." | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/sonic-yang-models/tests/yang_model_tests/tests_config/dns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"DNS_NAMESERVER_TEST": { | ||
"sonic-dns:sonic-dns": { | ||
"sonic-dns:DNS_NAMESERVER": { | ||
"DNS_NAMESERVER_LIST": [ | ||
{ | ||
"ip": "192.168.1.1" | ||
}, | ||
{ | ||
"ip": "fe80:1000:2000:3000::1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"DNS_NAMESERVER_TEST_INVALID_IP": { | ||
"sonic-dns:sonic-dns": { | ||
"sonic-dns:DNS_NAMESERVER": { | ||
"DNS_NAMESERVER_LIST": [ | ||
{ | ||
"ip": "1.x.2.x" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"DNS_NAMESERVER_TEST_MAX_IP_NUMBER": { | ||
"sonic-dns:sonic-dns": { | ||
"sonic-dns:DNS_NAMESERVER": { | ||
"DNS_NAMESERVER_LIST": [ | ||
{ | ||
"ip": "192.168.1.1" | ||
}, | ||
{ | ||
"ip": "fe80:1000:2000:3000::2" | ||
}, | ||
{ | ||
"ip": "192.168.1.3" | ||
}, | ||
{ | ||
"ip": "fe80:1000:2000:3000::4" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module sonic-dns { | ||
|
||
namespace "http://github.com/sonic-net/sonic-dns"; | ||
yang-version 1.1; | ||
prefix dns; | ||
|
||
import ietf-inet-types { | ||
prefix inet; | ||
} | ||
|
||
organization | ||
"SONiC"; | ||
|
||
contact | ||
"SONiC"; | ||
|
||
description "DNS YANG module for SONiC OS"; | ||
|
||
revision 2023-02-14 { | ||
description "Initial version"; | ||
} | ||
|
||
container sonic-dns { | ||
|
||
container DNS_NAMESERVER { | ||
|
||
description "DNS_NAMESERVER part of config_db.json"; | ||
|
||
list DNS_NAMESERVER_LIST { | ||
max-elements 3; | ||
description "List of nameservers IPs"; | ||
|
||
key "ip"; | ||
|
||
leaf ip { | ||
description "IP as DHCP_SERVER"; | ||
type inet:ip-address; | ||
} | ||
} /* end of list DNS_NAMESERVER_LIST */ | ||
|
||
} /* end of container DNS_NAMESERVER */ | ||
|
||
} /* end of container sonic-dns */ | ||
|
||
} /* end of module sonic-dns */ |