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

[sonic-head.yang]: Libyang sweep host bits from inet:ip-prefix, fixin… #56

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,9 @@ def test_xlate_rev_xlate(self):
if syc.jIn == syc.revXlateJson:
print("Xlate and Rev Xlate Passed")
else:
# Right now, interface and vlan_interface will have default diff due to ip_prefix
from jsondiff import diff
configDiff = diff(syc.jIn, syc.revXlateJson, syntax='symmetric')
for key in configDiff.keys():
if 'INTERFACE' not in key:
print("Xlate and Rev Xlate failed")
sys.exit(1)
print("Xlate and Rev Xlate Passed")
print("Xlate and Rev Xlate failed")
# make it fail
assert False == True

return

Expand Down
36 changes: 27 additions & 9 deletions src/sonic-yang-mgmt/yang-models/Sonic Yang Tree
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,37 @@ module: sonic-acl
module: sonic-interface
Copy link
Owner

Choose a reason for hiding this comment

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

Is file autogenerated? If so, should we not keep this as part of the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is generated by Pyang tool. Yes, Cool, we can also generate it as part of build process. Sonic-stretch docker will\should have pyang installed and then while building sonic-yang-models pkg I can run "pyang" tool.

+--rw sonic-interface
+--rw INTERFACE
+--rw INTERFACE_LIST* [interface ip-prefix]
+--rw interface -> /port:sonic-port/PORT/PORT_LIST/port_name
+--rw ip-prefix inet:ip-prefix
+--rw INTERFACE_LIST* [port_name]
| +--rw port_name -> /port:sonic-port/PORT/PORT_LIST/port_name
| +--rw vrf_name? string
+--rw INTERFACE_IPPREFIX_LIST* [port_name ip-prefix]
+--rw port_name -> /port:sonic-port/PORT/PORT_LIST/port_name
+--rw ip-prefix union
+--rw scope? enumeration
+--rw family? head:ip-family
module: sonic-loopback-interface
+--rw sonic-loopback-interface
+--rw LOOPBACK_INTERFACE
+--rw LOOPBACK_INTERFACE_LIST* [loopback_interface_name]
| +--rw loopback_interface_name string
| +--rw vrf_name? string
+--rw LOOPBACK_INTERFACE_IPPREFIX_LIST* [loopback_interface_name ip-prefix]
+--rw loopback_interface_name string
+--rw ip-prefix inet:ip-prefix
+--rw scope? enumeration
+--rw family? head:ip-family
module: sonic-port
+--rw sonic-port
+--rw PORT
+--rw PORT_LIST* [port_name]
+--rw port_name string
+--rw alias? string
+--rw lanes? string
+--rw lanes string
+--rw description? string
+--rw speed? uint32
+--rw speed uint32
+--rw mtu? uint16
+--rw admin_status head:admin_status
+--rw index? uint16
+--rw admin_status? head:admin_status
+--rw fec? string
module: sonic-portchannel
+--rw sonic-portchannel
Expand All @@ -82,9 +97,12 @@ module: sonic-portchannel
module: sonic-vlan
+--rw sonic-vlan
+--rw VLAN_INTERFACE
| +--rw VLAN_INTERFACE_LIST* [vlan_name ip-prefix]
| +--rw VLAN_INTERFACE_LIST* [vlan_name]
| | +--rw vlan_name -> /sonic-vlan/VLAN/VLAN_LIST/vlan_name
| | +--rw vrf_name? string
| +--rw VLAN_INTERFACE_IPPREFIX_LIST* [vlan_name ip-prefix]
| +--rw vlan_name -> /sonic-vlan/VLAN/VLAN_LIST/vlan_name
| +--rw ip-prefix inet:ip-prefix
| +--rw ip-prefix union
| +--rw scope? enumeration
| +--rw family? head:ip-family
+--rw VLAN
Expand All @@ -94,7 +112,7 @@ module: sonic-vlan
| +--rw description? string
| +--rw dhcp_servers* inet:ip-address
| +--rw mtu? uint16
| +--rw admin_status head:admin_status
| +--rw admin_status? head:admin_status
| +--rw members* -> /port:sonic-port/PORT/PORT_LIST/port_name
+--rw VLAN_MEMBER
+--rw VLAN_MEMBER_LIST* [vlan_name port]
Expand Down
26 changes: 24 additions & 2 deletions src/sonic-yang-mgmt/yang-models/sonic-head.yang
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,40 @@ module sonic-head {
contact "lnos_coders@linkedin.com";

description "Head yang Module for SONiC OS";

revision 2019-07-01 {
praveen-li marked this conversation as resolved.
Show resolved Hide resolved
description "First Revision";
}

typedef ip-family {
type enumeration {
enum IPv4;
enum IPv6;
}
}

typedef sonic-ip4-prefix {
type string {
pattern
'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+ '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
+ '/(([0-9])|([1-2][0-9])|(3[0-2]))';
}
}

typedef sonic-ip6-prefix {
type string {
pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
+ '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
+ '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
+ '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
+ '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
+ '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
+ '(/.+)';
}
}

typedef admin_status {
type enumeration {
enum up;
Expand Down
6 changes: 4 additions & 2 deletions src/sonic-yang-mgmt/yang-models/sonic-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ module sonic-interface {
}

leaf ip-prefix {
/* TODO: this should be custom, not inet:ip-prefix.*/
type inet:ip-prefix;
type union {
type head:sonic-ip4-prefix;
type head:sonic-ip6-prefix;
}
}

leaf scope {
Expand Down
6 changes: 4 additions & 2 deletions src/sonic-yang-mgmt/yang-models/sonic-vlan.yang
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ module sonic-vlan {
}

leaf ip-prefix {
mandatory true;
praveen-li marked this conversation as resolved.
Show resolved Hide resolved
type inet:ip-prefix;
type union {
type head:sonic-ip4-prefix;
type head:sonic-ip6-prefix;
}
}

leaf scope {
Expand Down