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-models]: YANG model changes for INTERFACE, VLAN_INTERFACE, LOOP… #36

Merged
merged 2 commits into from
Feb 9, 2020
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
19 changes: 18 additions & 1 deletion src/sonic-yang-mgmt/tests/yang-model-tests/yangModelTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def __init__(self, tests, yangDir, jsonFile):
'InvalidValue': ['Invalid value'],
'LeafRef': ['Leafref', 'non-existing'],
'When': ['When condition', 'not satisfied'],
'Pattern': ['pattern', 'does not satisfy']
'Pattern': ['pattern', 'does not satisfy'],
'None': ['']
}

self.ExceptionTests = {
Expand Down Expand Up @@ -100,6 +101,22 @@ def __init__(self, tests, yangDir, jsonFile):
'ACL_RULE_WRONG_INNER_ETHER_TYPE': {
'desc': 'Configure INNER_ETHER_TYPE as 0x080C in ACL_RULE.',
'eStr': self.defaultYANGFailure['Pattern']
},
'INTERFACE_IPPREFIX_PORT_MUST_CONDITION_FALSE': {
praveen-li marked this conversation as resolved.
Show resolved Hide resolved
'desc': 'Interface Ip-prefix port-name must condition failure.',
'eStr': self.defaultYANGFailure['Must']
},
'INTERFACE_IPPREFIX_PORT_MUST_CONDITION_TRUE': {
'desc': 'Interface Ip-prefix port-name must condition pass.',
'eStr': self.defaultYANGFailure['None']
},
'VLAN_INTERFACE_IPPREFIX_MUST_CONDITION_FALSE': {
'desc': 'Vlan Interface Ip-prefix must condition failure.',
'eStr': self.defaultYANGFailure['Must']
},
'LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE': {
'desc': 'Loopback Ip-prefix port-name must condition failure.',
'eStr': self.defaultYANGFailure['Must']
}
}

Expand Down
104 changes: 103 additions & 1 deletion src/sonic-yang-mgmt/tests/yang-model-tests/yangTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_INTERFACE": {
"VLAN_INTERFACE_LIST": [{
"vlan_name": "Vlan100"
}],
"VLAN_INTERFACE_IPPREFIX_LIST": [{
"vlan_name": "Vlan100",
"ip-prefix": "2a04:5555:66:7777::1/64",
"scope": "global",
Expand Down Expand Up @@ -142,7 +145,10 @@
"sonic-interface:sonic-interface": {
"sonic-interface:INTERFACE": {
"INTERFACE_LIST": [{
"interface": "Ethernet8",
"port_name": "Ethernet8"
}],
"INTERFACE_IPPREFIX_LIST": [{
"port_name": "Ethernet8",
"ip-prefix": "",
"scope": "global",
"family": "IPv4"
Expand Down Expand Up @@ -427,6 +433,102 @@
}
},

"VLAN_INTERFACE_IPPREFIX_MUST_CONDITION_FALSE": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_INTERFACE": {
"VLAN_INTERFACE_IPPREFIX_LIST": [{
"vlan_name": "Vlan100",
"ip-prefix": "2a04:5555:66:7777::1/64",
"scope": "global",
"family": "IPv6"
}]
},
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlan_name": "Vlan100",
"description": "server_vlan"
}]
}
}
},

"LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": {
"sonic-loopback-interface:sonic-loopback-interface": {
"sonic-loopback-interface:LOOPBACK_INTERFACE": {
"LOOPBACK_INTERFACE_IPPREFIX_LIST": [{
"loopback_interface_name": "lo1",
"ip-prefix": "2a04:5555:66:7777::1/64",
"scope": "global",
"family": "IPv6"
}]
}
}
},

"INTERFACE_IPPREFIX_PORT_MUST_CONDITION_FALSE": {
"sonic-interface:sonic-interface": {
"sonic-interface:INTERFACE": {
"INTERFACE_LIST": [{
"port_name": "Ethernet9"
}],
"INTERFACE_IPPREFIX_LIST": [{
"port_name": "Ethernet8",
"ip-prefix": "10.0.0.1/30",
"scope": "global",
"family": "IPv4"
}]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"port_name": "Ethernet8",
"alias": "eth8",
"description": "Ethernet8",
"speed": 25000,
"mtu": 9000,
"admin_status": "up"
},
{
"port_name": "Ethernet9",
"alias": "eth9",
"description": "Ethernet9",
"speed": 25000,
"mtu": 9000,
"admin_status": "up"
}]
}
}
},

"INTERFACE_IPPREFIX_PORT_MUST_CONDITION_TRUE": {
"sonic-interface:sonic-interface": {
"sonic-interface:INTERFACE": {
"INTERFACE_LIST": [{
"port_name": "Ethernet8"
}],
"INTERFACE_IPPREFIX_LIST": [{
"port_name": "Ethernet8",
"ip-prefix": "10.0.0.1/30",
"scope": "global",
"family": "IPv4"
}]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"port_name": "Ethernet8",
"alias": "eth8",
"description": "Ethernet8",
"speed": 25000,
"mtu": 9000,
"admin_status": "up"
}]
}
}
},

"ACL_RULE_ARP_TYPE_ICMPV6_CODE_MISMATCH": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
Expand Down
36 changes: 33 additions & 3 deletions src/sonic-yang-mgmt/yang-models/sonic-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,45 @@ module sonic-interface {
}

container sonic-interface {

container INTERFACE {

description "INTERFACE part of config_db.json";

list INTERFACE_LIST {

key "interface ip-prefix";
description "INTERFACE part of config_db.json with vrf";

key "port_name";

leaf port_name {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
}
}

leaf vrf_name {
type string {
pattern "Vrf[a-zA-Z0-9_-]+";
length 3..255;
}
}
}
/* end of INTERFACE_LIST */

list INTERFACE_IPPREFIX_LIST {

description "INTERFACE part of config_db.json with ip-prefix";

key "port_name ip-prefix";

leaf port_name {
/* This node must be present in INTERFACE_LIST */
must "(current() = ../../INTERFACE_LIST[port_name=current()]/port_name)"
{
error-message "Must condition not satisfied, Try adding PORT: {}, Example: 'Ethernet0': {}";
}

leaf interface {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
}
Expand Down Expand Up @@ -71,7 +101,7 @@ module sonic-interface {
type head:ip-family;
}
}
/* end of INTERFACE_LIST */
/* end of INTERFACE_IPPREFIX_LIST */

}
/* end of INTERFACE container */
Expand Down
85 changes: 85 additions & 0 deletions src/sonic-yang-mgmt/yang-models/sonic-loopback-interface.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
module sonic-loopback-interface {

namespace "http://github.com/Azure/sonic-loopback-interface";
prefix lointf;

import ietf-inet-types {
prefix inet;
}

import sonic-head {
prefix head;
revision-date 2019-07-01;
}

organization "Linkedin Corporation";

contact "lnos_coders@linkedin.com";

description
"SONIC LOOPBACK INTERFACE";

revision 2020-02-05 {
description "First Revision";
}

container sonic-loopback-interface {

container LOOPBACK_INTERFACE {

list LOOPBACK_INTERFACE_LIST {
key "loopback_interface_name";

leaf loopback_interface_name{
type string;
}

leaf vrf_name {
type string {
pattern "Vrf[a-zA-Z0-9_-]+";
length 3..255;
}
}
}
/* end of LOOPBACK_INTERFACE_LIST */

list LOOPBACK_INTERFACE_IPPREFIX_LIST {
key "loopback_interface_name ip-prefix";

leaf loopback_interface_name{
/* This node must be present in LOOPBACK_INTERFACE_LIST */
must "(current() = ../../LOOPBACK_INTERFACE_LIST[loopback_interface_name=current()]/loopback_interface_name)"
{
error-message "Must condition not satisfied, Try adding lo<>: {}, Example: 'lo1': {}";
}
type string;
}

leaf ip-prefix {
type inet:ip-prefix;
}

leaf scope {
type enumeration {
enum global;
enum local;
}
}

leaf family {

/* family leaf needed for backward compatibility
Both ip4 and ip6 address are string in IETF RFC 6021,
so must statement can check based on : or ., family
should be IPv4 or IPv6 according.
*/

must "(contains(../ip-prefix, ':') and current()='IPv6') or
(contains(../ip-prefix, '.') and current()='IPv4')";
type head:ip-family;
}
}
}
/* end of LOOPBACK_INTERFACE_IPPREFIX_LIST */
}
}
28 changes: 28 additions & 0 deletions src/sonic-yang-mgmt/yang-models/sonic-vlan.yang
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,43 @@ module sonic-vlan {
}

container sonic-vlan {

container VLAN_INTERFACE {

description "VLAN_INTERFACE part of config_db.json";

list VLAN_INTERFACE_LIST {

description "VLAN INTERFACE part of config_db.json with vrf";

key "vlan_name";

leaf vlan_name {
type leafref {
path /vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:vlan_name;
}
}

leaf vrf_name {
type string {
pattern "Vrf[a-zA-Z0-9_-]+";
length 3..255;
}
}
}
/* end of VLAN_INTERFACE_LIST */

list VLAN_INTERFACE_IPPREFIX_LIST {

key "vlan_name ip-prefix";

leaf vlan_name {
/* This node must be present in VLAN_INTERFACE_LIST */
must "(current() = ../../VLAN_INTERFACE_LIST[vlan_name=current()]/vlan_name)"
{
error-message "Must condition not satisfied, Try adding Vlan<vlanid>: {}, Example: 'Vlan100': {}";
}

type leafref {
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:vlan_name";
}
Expand Down