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 YANG changes for rel_1.0 #144

Merged
merged 3 commits into from
Oct 1, 2019
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
53 changes: 53 additions & 0 deletions models/yang/sonic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
TOPDIR := ../../../
SONIC_YANGAPI_DIR := $(TOPDIR)/build/yaml
SONIC_YANGDIR := $(TOPDIR)/models/yang/sonic
SONIC_YANGDIR_DEVIATION := $(TOPDIR)/models/yang/sonic/deviation
SONIC_YANGDIR_COMMON := $(TOPDIR)/models/yang/sonic/common
SONIC_YANGDIR_COMMON_IETF := $(TOPDIR)/models/yang/sonic/common/ietf
SONIC_YANG_MOD_FILES := $(shell find $(SONIC_YANGDIR) -maxdepth 1 -name '*.yang' | sort)
SONIC_YANG_COMMON_FILES := $(shell find $(SONIC_YANGDIR_COMMON) -name '*.yang' | sort)
SONIC_YANG_COMMON_FILES += $(shell find $(SONIC_YANGDIR_COMMON_IETF) -name '*.yang' | sort)

SONIC_TOOLS_DIR := $(TOPDIR)/tools
SONIC_PYANG_DIR := $(SONIC_TOOLS_DIR)/pyang
SONIC_PYANG_PLUGIN_DIR := $(SONIC_PYANG_DIR)/pyang_plugins
SONIC_PYANG_BIN := pyang

all: yamlGen allyangs.tree allyangs_tree.html

#yamlGen: $(SONIC_YANGAPI_DIR)/.done

allyangs.tree: $(SONIC_YANG_MOD_FILES) $(SONIC_YANG_COMMON_FILES)
$(SONIC_PYANG_BIN) \
-f tree \
-o $(SONIC_YANGDIR)/$@ \
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
$(SONIC_YANG_MOD_FILES)
@echo "+++++ Generation of YANG tree for Sonic Yang modules completed +++++"

allyangs_tree.html: $(SONIC_YANG_MOD_FILES) $(SONIC_YANG_COMMON_FILES)
$(SONIC_PYANG_BIN) \
-f jstree \
-o $(SONIC_YANGDIR)/$@ \
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
$(SONIC_YANG_MOD_FILES)
@echo "+++++ Generation of HTML tree for Sonic Yang modules completed +++++"

#======================================================================
# Generate YAML files for SONiC YANG modules
#======================================================================
yamlGen:
@echo "+++++ Generating YAML files for Sonic Yang modules +++++"
mkdir -p $(SONIC_YANGAPI_DIR)
$(SONIC_PYANG_BIN) \
-f swaggerapi \
--outdir $(SONIC_YANGAPI_DIR) \
--plugindir $(SONIC_PYANG_PLUGIN_DIR) \
-p $(SONIC_YANGDIR_COMMON):$(SONIC_YANGDIR) \
$(SONIC_YANG_MOD_FILES)
@echo "+++++ Generation of YAML files for Sonic Yang modules completed +++++"

clean:
@echo "Removing files ..."
rm -rf $(SONIC_YANGAPI_DIR)
rm -rf allyangs.tree allyangs_tree.html
41 changes: 41 additions & 0 deletions models/yang/sonic/common/sonic-common.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

module sonic-common {
namespace "http://github.com/Azure/sonic-common";
prefix scommon;

organization
"SONiC";

contact
"SONiC";

description
"SONIC VLAN";

revision 2019-05-15 {
description
"Initial revision.";
}

typedef tagging_mode {
type enumeration {
enum untagged;
enum tagged;
enum priority_tagged;
}
}

typedef admin-status {
type enumeration {
enum up;
enum down;
}
}


container operation {
leaf operation {
type string;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@

module sonic-common {
namespace "http://github.com/Azure/sonic-common";
prefix sv;

import ietf-yang-types {
prefix yang;
}
module sonic-extension {
namespace "http://github.com/Azure/sonic-extension";
prefix sonic-ext;

organization
"SONiC";
Expand All @@ -14,28 +10,13 @@ module sonic-common {
"SONiC";

description
"SONIC VLAN";
"SONIC Extension";

revision 2019-05-15 {
revision 2019-09-18 {
description
"Initial revision.";
}

typedef tagging_mode {
type enumeration {
enum untagged;
enum tagged;
enum priority_tagged;
}
}

typedef admin-status {
type enumeration {
enum up;
enum down;
}
}

extension custom-handler {
description
"Node should be handled by custom handler";
Expand Down Expand Up @@ -63,24 +44,18 @@ module sonic-common {
extension map-list {
description
"If it is a map list";
argument "value";
argument "value";
}

extension map-leaf {
description
"Map leaf names";
argument "value";
argument "value";
}

extension pf-check {
description
"Platform specific validation";
argument "handler";
}

container operation {
leaf operation {
type string;
}
}
}
221 changes: 221 additions & 0 deletions models/yang/sonic/sonic-acl.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
module sonic-acl {
namespace "http://github.com/Azure/sonic-acl";
prefix sacl;
yang-version 1.1;

import ietf-inet-types {
prefix inet;
}

import sonic-common {
prefix cmn;
}

import sonic-port {
prefix prt;
}

import sonic-mirror-session {
prefix sms;
}

organization
"SONiC";

contact
"SONiC";

description
"SONIC ACL";

revision 2019-05-15 {
description
"Initial revision.";
}

container sonic-acl {

container ACL_TABLE {

list ACL_TABLE_LIST {
key "aclname";

leaf aclname {
type string {
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,71})';
length 1..72;
}
}

leaf policy_desc {
type string {
length 1..255 {
error-app-tag policy-desc-invalid-length;
}
}
}

leaf stage {
type enumeration {
enum INGRESS;
enum EGRESS;
}
}

leaf type {
type enumeration {
enum MIRROR;
enum L2;
enum L3;
enum L3V6;
}
}

leaf-list ports {
type leafref {
path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:ifname";
}
}
}
}

container ACL_RULE {

list ACL_RULE_LIST {
key "aclname rulename";

leaf aclname {
type leafref {
path "../../../ACL_TABLE/ACL_TABLE_LIST/aclname";
}
must "(/cmn:operation/cmn:operation != 'DELETE') or " +
"count(current()/../../../ACL_TABLE/ACL_TABLE_LIST[aclname=current()]/ports) = 0" {
error-message "Ports are already bound to this rule.";
}
}

leaf rulename {
type string;
}

leaf PRIORITY {
type uint16 {
range "1..65535"{
error-message "Invalid ACL rule priority.";
}
}
}

leaf RULE_DESCRIPTION {
type string;
}

leaf PACKET_ACTION {
type enumeration {
enum FORWARD;
enum DROP;
enum REDIRECT;
}
}

leaf MIRROR_ACTION {
type leafref {
path "/sms:sonic-mirror-session/sms:MIRROR_SESSION/sms:MIRROR_SESSION_LIST/sms:name";
}
}

leaf IP_TYPE {
type enumeration {
enum ANY;
enum IP;
enum IPV4;
enum IPV4ANY;
enum NON_IPV4;
enum IPV6ANY;
enum NON_IPV6;
}
}

leaf IP_PROTOCOL {
type uint8 {
range "1|2|6|17|46|47|51|103|115";
}
}

leaf ETHER_TYPE {
type string {
pattern "(0x88CC)|(0x8100)|(0x8915)|(0x0806)|(0x0800)|(0x86DD)|(0x8847)" {
error-message "Invalid ACL Rule Ether Type";
error-app-tag ether-type-invalid;
}
}
}

choice ip_src_dst {
case ipv4_src_dst {
//when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY'])";
leaf SRC_IP {
mandatory true;
type inet:ipv4-prefix;
}
leaf DST_IP {
mandatory true;
type inet:ipv4-prefix;
}
}
case ipv6_src_dst {
//when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
leaf SRC_IPV6 {
mandatory true;
type inet:ipv6-prefix;
}
leaf DST_IPV6 {
mandatory true;
type inet:ipv6-prefix;
}
}
}

choice src_port {
case l4_src_port {
leaf L4_SRC_PORT {
type uint16;
}
}
case l4_src_port_range {
leaf L4_SRC_PORT_RANGE {
type string {
pattern "[0-9]{1,5}(-)[0-9]{1,5}";
}
}
}
}

choice dst_port {
case l4_dst_port {
leaf L4_DST_PORT {
type uint16;
}
}
case l4_dst_port_range {
leaf L4_DST_PORT_RANGE {
type string {
pattern "[0-9]{1,5}(-)[0-9]{1,5}";
}
}
}
}

leaf TCP_FLAGS {
type string {
pattern "0[xX][0-9a-fA-F]{2}[/]0[xX][0-9a-fA-F]{2}";
}
}

leaf DSCP {
type uint8;
}
}
}
}
}
Loading