Skip to content

Commit f032ec5

Browse files
authored
Merge pull request #144 from project-arlo/sonic_yang_changes_1.0
SONiC YANG changes for rel_1.0
2 parents a592fd3 + 47b02e3 commit f032ec5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1402
-1116
lines changed

models/yang/sonic/Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
TOPDIR := ../../../
2+
SONIC_YANGAPI_DIR := $(TOPDIR)/build/yaml
3+
SONIC_YANGDIR := $(TOPDIR)/models/yang/sonic
4+
SONIC_YANGDIR_DEVIATION := $(TOPDIR)/models/yang/sonic/deviation
5+
SONIC_YANGDIR_COMMON := $(TOPDIR)/models/yang/sonic/common
6+
SONIC_YANGDIR_COMMON_IETF := $(TOPDIR)/models/yang/sonic/common/ietf
7+
SONIC_YANG_MOD_FILES := $(shell find $(SONIC_YANGDIR) -maxdepth 1 -name '*.yang' | sort)
8+
SONIC_YANG_COMMON_FILES := $(shell find $(SONIC_YANGDIR_COMMON) -name '*.yang' | sort)
9+
SONIC_YANG_COMMON_FILES += $(shell find $(SONIC_YANGDIR_COMMON_IETF) -name '*.yang' | sort)
10+
11+
SONIC_TOOLS_DIR := $(TOPDIR)/tools
12+
SONIC_PYANG_DIR := $(SONIC_TOOLS_DIR)/pyang
13+
SONIC_PYANG_PLUGIN_DIR := $(SONIC_PYANG_DIR)/pyang_plugins
14+
SONIC_PYANG_BIN := pyang
15+
16+
all: yamlGen allyangs.tree allyangs_tree.html
17+
18+
#yamlGen: $(SONIC_YANGAPI_DIR)/.done
19+
20+
allyangs.tree: $(SONIC_YANG_MOD_FILES) $(SONIC_YANG_COMMON_FILES)
21+
$(SONIC_PYANG_BIN) \
22+
-f tree \
23+
-o $(SONIC_YANGDIR)/$@ \
24+
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
25+
$(SONIC_YANG_MOD_FILES)
26+
@echo "+++++ Generation of YANG tree for Sonic Yang modules completed +++++"
27+
28+
allyangs_tree.html: $(SONIC_YANG_MOD_FILES) $(SONIC_YANG_COMMON_FILES)
29+
$(SONIC_PYANG_BIN) \
30+
-f jstree \
31+
-o $(SONIC_YANGDIR)/$@ \
32+
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
33+
$(SONIC_YANG_MOD_FILES)
34+
@echo "+++++ Generation of HTML tree for Sonic Yang modules completed +++++"
35+
36+
#======================================================================
37+
# Generate YAML files for SONiC YANG modules
38+
#======================================================================
39+
yamlGen:
40+
@echo "+++++ Generating YAML files for Sonic Yang modules +++++"
41+
mkdir -p $(SONIC_YANGAPI_DIR)
42+
$(SONIC_PYANG_BIN) \
43+
-f swaggerapi \
44+
--outdir $(SONIC_YANGAPI_DIR) \
45+
--plugindir $(SONIC_PYANG_PLUGIN_DIR) \
46+
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
47+
$(SONIC_YANG_MOD_FILES)
48+
@echo "+++++ Generation of YAML files for Sonic Yang modules completed +++++"
49+
50+
clean:
51+
@echo "Removing files ..."
52+
rm -rf $(SONIC_YANGAPI_DIR)
53+
rm -rf allyangs.tree allyangs_tree.html
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
module sonic-common {
3+
namespace "http://github.com/Azure/sonic-common";
4+
prefix scommon;
5+
6+
organization
7+
"SONiC";
8+
9+
contact
10+
"SONiC";
11+
12+
description
13+
"SONIC VLAN";
14+
15+
revision 2019-05-15 {
16+
description
17+
"Initial revision.";
18+
}
19+
20+
typedef tagging_mode {
21+
type enumeration {
22+
enum untagged;
23+
enum tagged;
24+
enum priority_tagged;
25+
}
26+
}
27+
28+
typedef admin-status {
29+
type enumeration {
30+
enum up;
31+
enum down;
32+
}
33+
}
34+
35+
36+
container operation {
37+
leaf operation {
38+
type string;
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11

2-
module sonic-common {
3-
namespace "http://github.com/Azure/sonic-common";
4-
prefix sv;
5-
6-
import ietf-yang-types {
7-
prefix yang;
8-
}
2+
module sonic-extension {
3+
namespace "http://github.com/Azure/sonic-extension";
4+
prefix sonic-ext;
95

106
organization
117
"SONiC";
@@ -14,28 +10,13 @@ module sonic-common {
1410
"SONiC";
1511

1612
description
17-
"SONIC VLAN";
13+
"SONIC Extension";
1814

19-
revision 2019-05-15 {
15+
revision 2019-09-18 {
2016
description
2117
"Initial revision.";
2218
}
2319

24-
typedef tagging_mode {
25-
type enumeration {
26-
enum untagged;
27-
enum tagged;
28-
enum priority_tagged;
29-
}
30-
}
31-
32-
typedef admin-status {
33-
type enumeration {
34-
enum up;
35-
enum down;
36-
}
37-
}
38-
3920
extension custom-handler {
4021
description
4122
"Node should be handled by custom handler";
@@ -63,24 +44,18 @@ module sonic-common {
6344
extension map-list {
6445
description
6546
"If it is a map list";
66-
argument "value";
47+
argument "value";
6748
}
6849

6950
extension map-leaf {
7051
description
7152
"Map leaf names";
72-
argument "value";
53+
argument "value";
7354
}
7455

7556
extension pf-check {
7657
description
7758
"Platform specific validation";
7859
argument "handler";
7960
}
80-
81-
container operation {
82-
leaf operation {
83-
type string;
84-
}
85-
}
8661
}

models/yang/sonic/sonic-acl.yang

+221
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
module sonic-acl {
2+
namespace "http://github.com/Azure/sonic-acl";
3+
prefix sacl;
4+
yang-version 1.1;
5+
6+
import ietf-inet-types {
7+
prefix inet;
8+
}
9+
10+
import sonic-common {
11+
prefix cmn;
12+
}
13+
14+
import sonic-port {
15+
prefix prt;
16+
}
17+
18+
import sonic-mirror-session {
19+
prefix sms;
20+
}
21+
22+
organization
23+
"SONiC";
24+
25+
contact
26+
"SONiC";
27+
28+
description
29+
"SONIC ACL";
30+
31+
revision 2019-05-15 {
32+
description
33+
"Initial revision.";
34+
}
35+
36+
container sonic-acl {
37+
38+
container ACL_TABLE {
39+
40+
list ACL_TABLE_LIST {
41+
key "aclname";
42+
43+
leaf aclname {
44+
type string {
45+
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,71})';
46+
length 1..72;
47+
}
48+
}
49+
50+
leaf policy_desc {
51+
type string {
52+
length 1..255 {
53+
error-app-tag policy-desc-invalid-length;
54+
}
55+
}
56+
}
57+
58+
leaf stage {
59+
type enumeration {
60+
enum INGRESS;
61+
enum EGRESS;
62+
}
63+
}
64+
65+
leaf type {
66+
type enumeration {
67+
enum MIRROR;
68+
enum L2;
69+
enum L3;
70+
enum L3V6;
71+
}
72+
}
73+
74+
leaf-list ports {
75+
type leafref {
76+
path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:ifname";
77+
}
78+
}
79+
}
80+
}
81+
82+
container ACL_RULE {
83+
84+
list ACL_RULE_LIST {
85+
key "aclname rulename";
86+
87+
leaf aclname {
88+
type leafref {
89+
path "../../../ACL_TABLE/ACL_TABLE_LIST/aclname";
90+
}
91+
must "(/cmn:operation/cmn:operation != 'DELETE') or " +
92+
"count(current()/../../../ACL_TABLE/ACL_TABLE_LIST[aclname=current()]/ports) = 0" {
93+
error-message "Ports are already bound to this rule.";
94+
}
95+
}
96+
97+
leaf rulename {
98+
type string;
99+
}
100+
101+
leaf PRIORITY {
102+
type uint16 {
103+
range "1..65535"{
104+
error-message "Invalid ACL rule priority.";
105+
}
106+
}
107+
}
108+
109+
leaf RULE_DESCRIPTION {
110+
type string;
111+
}
112+
113+
leaf PACKET_ACTION {
114+
type enumeration {
115+
enum FORWARD;
116+
enum DROP;
117+
enum REDIRECT;
118+
}
119+
}
120+
121+
leaf MIRROR_ACTION {
122+
type leafref {
123+
path "/sms:sonic-mirror-session/sms:MIRROR_SESSION/sms:MIRROR_SESSION_LIST/sms:name";
124+
}
125+
}
126+
127+
leaf IP_TYPE {
128+
type enumeration {
129+
enum ANY;
130+
enum IP;
131+
enum IPV4;
132+
enum IPV4ANY;
133+
enum NON_IPV4;
134+
enum IPV6ANY;
135+
enum NON_IPV6;
136+
}
137+
}
138+
139+
leaf IP_PROTOCOL {
140+
type uint8 {
141+
range "1|2|6|17|46|47|51|103|115";
142+
}
143+
}
144+
145+
leaf ETHER_TYPE {
146+
type string {
147+
pattern "(0x88CC)|(0x8100)|(0x8915)|(0x0806)|(0x0800)|(0x86DD)|(0x8847)" {
148+
error-message "Invalid ACL Rule Ether Type";
149+
error-app-tag ether-type-invalid;
150+
}
151+
}
152+
}
153+
154+
choice ip_src_dst {
155+
case ipv4_src_dst {
156+
//when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY'])";
157+
leaf SRC_IP {
158+
mandatory true;
159+
type inet:ipv4-prefix;
160+
}
161+
leaf DST_IP {
162+
mandatory true;
163+
type inet:ipv4-prefix;
164+
}
165+
}
166+
case ipv6_src_dst {
167+
//when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
168+
leaf SRC_IPV6 {
169+
mandatory true;
170+
type inet:ipv6-prefix;
171+
}
172+
leaf DST_IPV6 {
173+
mandatory true;
174+
type inet:ipv6-prefix;
175+
}
176+
}
177+
}
178+
179+
choice src_port {
180+
case l4_src_port {
181+
leaf L4_SRC_PORT {
182+
type uint16;
183+
}
184+
}
185+
case l4_src_port_range {
186+
leaf L4_SRC_PORT_RANGE {
187+
type string {
188+
pattern "[0-9]{1,5}(-)[0-9]{1,5}";
189+
}
190+
}
191+
}
192+
}
193+
194+
choice dst_port {
195+
case l4_dst_port {
196+
leaf L4_DST_PORT {
197+
type uint16;
198+
}
199+
}
200+
case l4_dst_port_range {
201+
leaf L4_DST_PORT_RANGE {
202+
type string {
203+
pattern "[0-9]{1,5}(-)[0-9]{1,5}";
204+
}
205+
}
206+
}
207+
}
208+
209+
leaf TCP_FLAGS {
210+
type string {
211+
pattern "0[xX][0-9a-fA-F]{2}[/]0[xX][0-9a-fA-F]{2}";
212+
}
213+
}
214+
215+
leaf DSCP {
216+
type uint8;
217+
}
218+
}
219+
}
220+
}
221+
}

0 commit comments

Comments
 (0)