From 99720f5d5ccdad86529a4617032b49cf508c9d3f Mon Sep 17 00:00:00 2001 From: Partha Dutta Date: Wed, 18 Sep 2019 09:37:06 +0530 Subject: [PATCH 1/4] Moving unwanted CVL YANG to testdata --- src/cvl/Makefile | 6 ++- src/cvl/cvl_test.go | 8 +-- src/cvl/internal/yparser/yparser.go | 11 +++- src/cvl/schema/sonic-acl.yang | 51 +++++-------------- src/cvl/schema/sonic-common.yang | 28 +++++----- src/cvl/schema/sonic-interface.yang | 16 +++--- src/cvl/schema/sonic-mirror-session.yang | 4 +- src/cvl/schema/sonic-port.yang | 10 ++-- src/cvl/testdata/schema/Makefile | 26 ++++++++++ .../{ => testdata}/schema/sonic-acl-dev.yang | 4 +- .../schema/sonic-bgp-neighbor.yang | 4 +- .../schema/sonic-buffer-pg.yang | 4 +- .../schema/sonic-buffer-pool.yang | 4 +- .../schema/sonic-buffer-profile.yang | 4 +- .../schema/sonic-cablelength.yang | 4 +- .../schema/sonic-device-metadata.yang | 4 +- .../schema/sonic-device-neighbor.yang | 4 +- .../schema/sonic-dscp-tc-map.yang | 4 +- .../schema/sonic-pf-limits.yang | 4 +- .../schema/sonic-pfc-priority-queue-map.yang | 4 +- .../schema/sonic-port-qos-map.yang | 4 +- .../schema/sonic-portchannel-interface.yang | 4 +- .../schema/sonic-portchannel.yang | 4 +- .../{ => testdata}/schema/sonic-queue.yang | 4 +- .../schema/sonic-scheduler.yang | 4 +- .../schema/sonic-tc-priority-group-map.yang | 4 +- .../schema/sonic-tc-queue-map.yang | 4 +- .../{ => testdata}/schema/sonic-vlan-dev.yang | 4 +- .../testdata/schema/sonic-vlan-dev.yin.tmp | 30 +++++++++++ .../schema/sonic-vlan-interface.yang | 4 +- src/cvl/{ => testdata}/schema/sonic-vlan.yang | 4 +- .../schema/sonic-wred-profile.yang | 4 +- src/cvl/tests/Makefile | 1 + 33 files changed, 162 insertions(+), 117 deletions(-) create mode 100644 src/cvl/testdata/schema/Makefile rename src/cvl/{ => testdata}/schema/sonic-acl-dev.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-bgp-neighbor.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-buffer-pg.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-buffer-pool.yang (96%) rename src/cvl/{ => testdata}/schema/sonic-buffer-profile.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-cablelength.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-device-metadata.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-device-neighbor.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-dscp-tc-map.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-pf-limits.yang (96%) rename src/cvl/{ => testdata}/schema/sonic-pfc-priority-queue-map.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-port-qos-map.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-portchannel-interface.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-portchannel.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-queue.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-scheduler.yang (96%) rename src/cvl/{ => testdata}/schema/sonic-tc-priority-group-map.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-tc-queue-map.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-vlan-dev.yang (96%) create mode 100644 src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp rename src/cvl/{ => testdata}/schema/sonic-vlan-interface.yang (97%) rename src/cvl/{ => testdata}/schema/sonic-vlan.yang (98%) rename src/cvl/{ => testdata}/schema/sonic-wred-profile.yang (98%) diff --git a/src/cvl/Makefile b/src/cvl/Makefile index 4f85259fc4..198a541290 100644 --- a/src/cvl/Makefile +++ b/src/cvl/Makefile @@ -50,7 +50,11 @@ tests: make -C tests gotest: - CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/schema GOPATH=$(GOPATH) tests/run_test.sh + make -C schema + make -C testdata/schema + cp schema/*.yin testdata/schema + #CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/schema:$(abspath .)/testdata/schema GOPATH=$(GOPATH) tests/run_test.sh + CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/schema GOPATH=$(GOPATH) tests/run_test.sh clean: make -C tests clean diff --git a/src/cvl/cvl_test.go b/src/cvl/cvl_test.go index 74d51df3d0..1ac35ed30f 100644 --- a/src/cvl/cvl_test.go +++ b/src/cvl/cvl_test.go @@ -2806,16 +2806,16 @@ func TestBadSchema(t *testing.T) { if _, err := os.Stat("/usr/sbin/schema"); os.IsNotExist(err) { //Corrupt some schema file - exec.Command("/bin/sh", "-c", "/bin/cp schema/sonic-port.yin schema/sonic-port.yin.bad" + - " && /bin/sed -i '1 a ' schema/sonic-port.yin.bad").Output() + exec.Command("/bin/sh", "-c", "/bin/cp testdata/schema/sonic-port.yin testdata/schema/sonic-port.yin.bad" + + " && /bin/sed -i '1 a ' testdata/schema/sonic-port.yin.bad").Output() //Parse bad schema file - if module, _ := yparser.ParseSchemaFile("schema/sonic-port.yin.bad.1"); module != nil { //should fail + if module, _ := yparser.ParseSchemaFile("testdata/schema/sonic-port.yin.bad"); module != nil { //should fail t.Errorf("Bad schema parsing should fail.") } //Revert to - exec.Command("/bin/sh", "-c", "/bin/rm schema/sonic-port.yin.bad").Output() + exec.Command("/bin/sh", "-c", "/bin/rm testdata/schema/sonic-port.yin.bad").Output() } else { //Corrupt some schema file exec.Command("/bin/sh", "-c", "/bin/cp /usr/sbin/schema/sonic-port.yin /usr/sbin/schema/sonic-port.yin.bad" + diff --git a/src/cvl/internal/yparser/yparser.go b/src/cvl/internal/yparser/yparser.go index d08f66c702..a654d34fc2 100644 --- a/src/cvl/internal/yparser/yparser.go +++ b/src/cvl/internal/yparser/yparser.go @@ -7,6 +7,7 @@ import ( "strings" log "github.com/golang/glog" . "cvl/internal/util" + "fmt" ) /* @@ -235,7 +236,10 @@ func ParseSchemaFile(modelFile string) (*YParserModule, YParserError) { module := C.lys_parse_path((*C.struct_ly_ctx)(ypCtx), C.CString(modelFile), C.LYS_IN_YIN) if module == nil { + fmt.Printf("\n\nFailed Parsed file .... %s\n\n", modelFile) return nil, getErrorDetails() + } else { + fmt.Printf("\n\nParsed file .... %s\n\n", modelFile) } if (strings.Contains(modelFile, "sonic-common.yin") == true) { @@ -250,7 +254,12 @@ func ParseSchemaFile(modelFile string) (*YParserModule, YParserError) { //Add child node to a parent node func(yp *YParser) AddChildNode(module *YParserModule, parent *YParserNode, name string) *YParserNode { - return (*YParserNode)(C.lyd_new((*C.struct_lyd_node)(parent), (*C.struct_lys_module)(module), C.CString(name))) + //return (*YParserNode)(C.lyd_new((*C.struct_lyd_node)(parent), (*C.struct_lys_module)(module), C.CString(name))) + ret := (*YParserNode)(C.lyd_new((*C.struct_lyd_node)(parent), (*C.struct_lys_module)(module), C.CString(name))) + if (ret == nil) { + fmt.Printf("\n\nFailed parsing .... %s\n\n", name) + } + return ret } //Add child node to a parent node diff --git a/src/cvl/schema/sonic-acl.yang b/src/cvl/schema/sonic-acl.yang index 61ed679d8d..c2a96aaccb 100644 --- a/src/cvl/schema/sonic-acl.yang +++ b/src/cvl/schema/sonic-acl.yang @@ -19,23 +19,15 @@ module sonic-acl { prefix prt; } - import sonic-portchannel { - prefix spc; - } - import sonic-mirror-session { prefix sms; } - import sonic-pf-limits { - prefix spf; - } - organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC ACL"; @@ -50,13 +42,12 @@ module sonic-acl { list ACL_TABLE { key "aclname"; - /* must "count(/prt:sonic-port/prt:PORT) > 0"; */ leaf aclname { - type string { - pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,71})'; - length 1..72; - } + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,71})'; + length 1..72; + } } leaf policy_desc { @@ -84,30 +75,14 @@ module sonic-acl { } leaf-list ports { - type union { - type leafref { - path "/prt:sonic-port/prt:PORT/prt:ifname"; - } - type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:name"; - } + type leafref { + path "/prt:sonic-port/prt:PORT/prt:ifname"; } } } list ACL_RULE { key "aclname rulename"; - scommon:pf-check "ACL_CheckAclLimits"; - - /* Limit for number of dynamic ACL rules */ - /*must "count(../ACL_RULE) > /spf:sonic-pf-limits/acl/MAX_ACL_RULES" { - error-message "Number of ACL rules reached max platform limit."; - } - must "PRIORITY > /spf:sonic-pf-limits/acl/MAX_PRIORITY" { - error-message "Invalid ACL rule priority."; - } - must "count(../ACL_TABLE) > 0 and count(/prt:sonic-port/prt:PORT) > 0"; //Temporary work-around - */ leaf aclname { type leafref { @@ -116,7 +91,7 @@ module sonic-acl { must "(/scommon:operation/scommon:operation != 'DELETE') or " + "count(current()/../../ACL_TABLE[aclname=current()]/ports) = 0" { error-message "Ports are already bound to this rule."; - } + } } leaf rulename { @@ -127,7 +102,7 @@ module sonic-acl { type uint16 { range "1..65535"{ error-message "Invalid ACL rule priority."; - } + } } } @@ -160,7 +135,7 @@ module sonic-acl { enum NON_IPV6; } } - + leaf IP_PROTOCOL { type uint8 { range "1|2|6|17|46|47|51|103|115"; @@ -171,8 +146,8 @@ module sonic-acl { type string{ pattern "(0x88CC)|(0x8100)|(0x8915)|(0x0806)|(0x0800)|(0x86DD)|(0x8847)"{ error-message "Invalid ACL Rule Ether Type"; - error-app-tag ether-type-invalid; - } + error-app-tag ether-type-invalid; + } } } diff --git a/src/cvl/schema/sonic-common.yang b/src/cvl/schema/sonic-common.yang index be94f4645a..329d40c537 100644 --- a/src/cvl/schema/sonic-common.yang +++ b/src/cvl/schema/sonic-common.yang @@ -8,10 +8,10 @@ module sonic-common { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC VLAN"; @@ -22,18 +22,18 @@ module sonic-common { } typedef tagging_mode { - type enumeration { - enum untagged; - enum tagged; - enum priority_tagged; - } + type enumeration { + enum untagged; + enum tagged; + enum priority_tagged; + } } typedef admin-status { - type enumeration { - enum up; - enum down; - } + type enumeration { + enum up; + enum down; + } } extension custom-handler { @@ -63,19 +63,19 @@ 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"; // + argument "handler"; } container operation { diff --git a/src/cvl/schema/sonic-interface.yang b/src/cvl/schema/sonic-interface.yang index 1ddf94c115..540b3a16b8 100644 --- a/src/cvl/schema/sonic-interface.yang +++ b/src/cvl/schema/sonic-interface.yang @@ -7,8 +7,8 @@ module sonic-interface { } import ietf-inet-types { - prefix inet; - } + prefix inet; + } import sonic-common { prefix scommon; @@ -19,10 +19,10 @@ module sonic-interface { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC INTERFACE"; @@ -38,13 +38,13 @@ module sonic-interface { leaf portname{ type leafref { - path "/prt:sonic-port/prt:PORT/prt:ifname"; - } + path "/prt:sonic-port/prt:PORT/prt:ifname"; + } } leaf ip_prefix { - mandatory true; - type inet:ip-prefix; + mandatory true; + type inet:ip-prefix; } } diff --git a/src/cvl/schema/sonic-mirror-session.yang b/src/cvl/schema/sonic-mirror-session.yang index 36bb32cc81..1a2591cc0c 100644 --- a/src/cvl/schema/sonic-mirror-session.yang +++ b/src/cvl/schema/sonic-mirror-session.yang @@ -15,10 +15,10 @@ module sonic-mirror-session { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC MIRROR SESSION"; diff --git a/src/cvl/schema/sonic-port.yang b/src/cvl/schema/sonic-port.yang index 5e9e893a39..3d99d0534f 100644 --- a/src/cvl/schema/sonic-port.yang +++ b/src/cvl/schema/sonic-port.yang @@ -11,10 +11,10 @@ module sonic-port { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC VLAN"; @@ -33,11 +33,11 @@ module sonic-port { type string { pattern "Ethernet([1-3][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[0-9])"{ error-message "Invalid interface name"; - error-app-tag interface-name-invalid; - } + error-app-tag interface-name-invalid; + } } } - + leaf index { type uint16; } diff --git a/src/cvl/testdata/schema/Makefile b/src/cvl/testdata/schema/Makefile new file mode 100644 index 0000000000..daf398bd65 --- /dev/null +++ b/src/cvl/testdata/schema/Makefile @@ -0,0 +1,26 @@ +src_files=$(wildcard *.yang) +out=$(patsubst %.yang, %.yin, $(src_files)) +out_ext=$(patsubst %.yang, %.tree, $(src_files)) + +all:schema + +schema: $(out) + +%.yin:%.yang + @echo "Generating $@ ..." + @devFile="`echo $< | cut -d . -f1`-dev.yang"; \ + if [ -f $$devFile ] ; then devOpt="--deviation-module $$devFile"; fi; \ + pyang -p /home/pd945169/mgmt_framework_pr/sonic-mgmt-framework/src/cvl/schema:../../schema/:../../schema/ietf/ -f yin $$devOpt $< -o $@.tmp + @xmllint --noblanks $@.tmp > $@ + @rm -rf $@.tmp + +%.tree:%.yang + @echo "Generating $@ ..." + @devFile="`echo $< | cut -d . -f1`-dev.yang"; \ + if [ -f $$devFile ] ; then devOpt="--deviation-module $$devFile"; fi; \ + pyang -p ../../schema/:../../schema/ietf/ -f tree $$devOpt $< -o $@ + +clean: + @echo "Removing files ..." + rm -rf $(out) + rm -rf $(out_ext) diff --git a/src/cvl/schema/sonic-acl-dev.yang b/src/cvl/testdata/schema/sonic-acl-dev.yang similarity index 97% rename from src/cvl/schema/sonic-acl-dev.yang rename to src/cvl/testdata/schema/sonic-acl-dev.yang index 963a88303c..9c47e0fd0b 100644 --- a/src/cvl/schema/sonic-acl-dev.yang +++ b/src/cvl/testdata/schema/sonic-acl-dev.yang @@ -21,10 +21,10 @@ module sonic-acl-dev { organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC ACLi Deviations"; diff --git a/src/cvl/schema/sonic-bgp-neighbor.yang b/src/cvl/testdata/schema/sonic-bgp-neighbor.yang similarity index 97% rename from src/cvl/schema/sonic-bgp-neighbor.yang rename to src/cvl/testdata/schema/sonic-bgp-neighbor.yang index f1cf321615..2264e5238e 100644 --- a/src/cvl/schema/sonic-bgp-neighbor.yang +++ b/src/cvl/testdata/schema/sonic-bgp-neighbor.yang @@ -19,10 +19,10 @@ module sonic-bgp-neighbor { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC BGP NEIGHBOR"; diff --git a/src/cvl/schema/sonic-buffer-pg.yang b/src/cvl/testdata/schema/sonic-buffer-pg.yang similarity index 98% rename from src/cvl/schema/sonic-buffer-pg.yang rename to src/cvl/testdata/schema/sonic-buffer-pg.yang index 96af02e24c..61b5013fed 100644 --- a/src/cvl/schema/sonic-buffer-pg.yang +++ b/src/cvl/testdata/schema/sonic-buffer-pg.yang @@ -23,10 +23,10 @@ module sonic-buffer-pg { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC BUFFER PG"; diff --git a/src/cvl/schema/sonic-buffer-pool.yang b/src/cvl/testdata/schema/sonic-buffer-pool.yang similarity index 96% rename from src/cvl/schema/sonic-buffer-pool.yang rename to src/cvl/testdata/schema/sonic-buffer-pool.yang index 2c6b6b3689..130c28287f 100644 --- a/src/cvl/schema/sonic-buffer-pool.yang +++ b/src/cvl/testdata/schema/sonic-buffer-pool.yang @@ -15,10 +15,10 @@ module sonic-buffer-pool { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC BUFFER POOL"; diff --git a/src/cvl/schema/sonic-buffer-profile.yang b/src/cvl/testdata/schema/sonic-buffer-profile.yang similarity index 97% rename from src/cvl/schema/sonic-buffer-profile.yang rename to src/cvl/testdata/schema/sonic-buffer-profile.yang index 7d4c1c3dc5..895def38c4 100644 --- a/src/cvl/schema/sonic-buffer-profile.yang +++ b/src/cvl/testdata/schema/sonic-buffer-profile.yang @@ -19,10 +19,10 @@ module sonic-buffer-profile { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC BUFFER PROFILE"; diff --git a/src/cvl/schema/sonic-cablelength.yang b/src/cvl/testdata/schema/sonic-cablelength.yang similarity index 97% rename from src/cvl/schema/sonic-cablelength.yang rename to src/cvl/testdata/schema/sonic-cablelength.yang index 3109294732..e4eeed031c 100644 --- a/src/cvl/schema/sonic-cablelength.yang +++ b/src/cvl/testdata/schema/sonic-cablelength.yang @@ -19,10 +19,10 @@ module sonic-cablelength { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC CABLELENGTH"; diff --git a/src/cvl/schema/sonic-device-metadata.yang b/src/cvl/testdata/schema/sonic-device-metadata.yang similarity index 98% rename from src/cvl/schema/sonic-device-metadata.yang rename to src/cvl/testdata/schema/sonic-device-metadata.yang index 77ef8a1731..0bd953836b 100644 --- a/src/cvl/schema/sonic-device-metadata.yang +++ b/src/cvl/testdata/schema/sonic-device-metadata.yang @@ -15,10 +15,10 @@ module sonic-device-metadata { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC DEVICE METADATA"; diff --git a/src/cvl/schema/sonic-device-neighbor.yang b/src/cvl/testdata/schema/sonic-device-neighbor.yang similarity index 98% rename from src/cvl/schema/sonic-device-neighbor.yang rename to src/cvl/testdata/schema/sonic-device-neighbor.yang index cba3eed0fc..9dc28187ef 100644 --- a/src/cvl/schema/sonic-device-neighbor.yang +++ b/src/cvl/testdata/schema/sonic-device-neighbor.yang @@ -20,10 +20,10 @@ module sonic-device-neighbor { organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC DEVICE NEIGHBOR"; diff --git a/src/cvl/schema/sonic-dscp-tc-map.yang b/src/cvl/testdata/schema/sonic-dscp-tc-map.yang similarity index 97% rename from src/cvl/schema/sonic-dscp-tc-map.yang rename to src/cvl/testdata/schema/sonic-dscp-tc-map.yang index 449310367a..481cfbece0 100644 --- a/src/cvl/schema/sonic-dscp-tc-map.yang +++ b/src/cvl/testdata/schema/sonic-dscp-tc-map.yang @@ -15,10 +15,10 @@ module sonic-dscp-tc-map { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC DSCP_TO_TC_MAP"; diff --git a/src/cvl/schema/sonic-pf-limits.yang b/src/cvl/testdata/schema/sonic-pf-limits.yang similarity index 96% rename from src/cvl/schema/sonic-pf-limits.yang rename to src/cvl/testdata/schema/sonic-pf-limits.yang index 984e649888..6b92e97dba 100644 --- a/src/cvl/schema/sonic-pf-limits.yang +++ b/src/cvl/testdata/schema/sonic-pf-limits.yang @@ -16,10 +16,10 @@ module sonic-pf-limits { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC Platform constrainst"; diff --git a/src/cvl/schema/sonic-pfc-priority-queue-map.yang b/src/cvl/testdata/schema/sonic-pfc-priority-queue-map.yang similarity index 97% rename from src/cvl/schema/sonic-pfc-priority-queue-map.yang rename to src/cvl/testdata/schema/sonic-pfc-priority-queue-map.yang index e1a08c07cb..b5c8952e6b 100644 --- a/src/cvl/schema/sonic-pfc-priority-queue-map.yang +++ b/src/cvl/testdata/schema/sonic-pfc-priority-queue-map.yang @@ -11,10 +11,10 @@ module sonic-pfc-priority-queue-map { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC MAP_PFC_PRIORITY_TO_QUEUE"; diff --git a/src/cvl/schema/sonic-port-qos-map.yang b/src/cvl/testdata/schema/sonic-port-qos-map.yang similarity index 98% rename from src/cvl/schema/sonic-port-qos-map.yang rename to src/cvl/testdata/schema/sonic-port-qos-map.yang index 04838ae775..eeb5ca0bbc 100644 --- a/src/cvl/schema/sonic-port-qos-map.yang +++ b/src/cvl/testdata/schema/sonic-port-qos-map.yang @@ -31,10 +31,10 @@ module sonic-port-qos-map { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC PORT_QOS_MAP"; diff --git a/src/cvl/schema/sonic-portchannel-interface.yang b/src/cvl/testdata/schema/sonic-portchannel-interface.yang similarity index 97% rename from src/cvl/schema/sonic-portchannel-interface.yang rename to src/cvl/testdata/schema/sonic-portchannel-interface.yang index 2bfc4cc006..305fd6ae76 100644 --- a/src/cvl/schema/sonic-portchannel-interface.yang +++ b/src/cvl/testdata/schema/sonic-portchannel-interface.yang @@ -19,10 +19,10 @@ module sonic-portchannel-interface { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC PORTCHANNEL INTERFACE"; diff --git a/src/cvl/schema/sonic-portchannel.yang b/src/cvl/testdata/schema/sonic-portchannel.yang similarity index 97% rename from src/cvl/schema/sonic-portchannel.yang rename to src/cvl/testdata/schema/sonic-portchannel.yang index 25b08d5785..4ecd3a33d6 100644 --- a/src/cvl/schema/sonic-portchannel.yang +++ b/src/cvl/testdata/schema/sonic-portchannel.yang @@ -15,10 +15,10 @@ module sonic-portchannel { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC PORTCHANNEL"; diff --git a/src/cvl/schema/sonic-queue.yang b/src/cvl/testdata/schema/sonic-queue.yang similarity index 98% rename from src/cvl/schema/sonic-queue.yang rename to src/cvl/testdata/schema/sonic-queue.yang index e3be11691b..fb55793443 100644 --- a/src/cvl/schema/sonic-queue.yang +++ b/src/cvl/testdata/schema/sonic-queue.yang @@ -23,10 +23,10 @@ module sonic-queue { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC QUEUE"; diff --git a/src/cvl/schema/sonic-scheduler.yang b/src/cvl/testdata/schema/sonic-scheduler.yang similarity index 96% rename from src/cvl/schema/sonic-scheduler.yang rename to src/cvl/testdata/schema/sonic-scheduler.yang index 0b0745185b..d1e26ab359 100644 --- a/src/cvl/schema/sonic-scheduler.yang +++ b/src/cvl/testdata/schema/sonic-scheduler.yang @@ -11,10 +11,10 @@ module sonic-scheduler { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC SCHEDULER"; diff --git a/src/cvl/schema/sonic-tc-priority-group-map.yang b/src/cvl/testdata/schema/sonic-tc-priority-group-map.yang similarity index 97% rename from src/cvl/schema/sonic-tc-priority-group-map.yang rename to src/cvl/testdata/schema/sonic-tc-priority-group-map.yang index 6f7ec329d7..253ed0f47b 100644 --- a/src/cvl/schema/sonic-tc-priority-group-map.yang +++ b/src/cvl/testdata/schema/sonic-tc-priority-group-map.yang @@ -11,10 +11,10 @@ module sonic-tc-priority-group-map { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC TC_TO_PRIORITY_GROUP_MAP"; diff --git a/src/cvl/schema/sonic-tc-queue-map.yang b/src/cvl/testdata/schema/sonic-tc-queue-map.yang similarity index 97% rename from src/cvl/schema/sonic-tc-queue-map.yang rename to src/cvl/testdata/schema/sonic-tc-queue-map.yang index a2473d3985..385b9edfac 100644 --- a/src/cvl/schema/sonic-tc-queue-map.yang +++ b/src/cvl/testdata/schema/sonic-tc-queue-map.yang @@ -11,10 +11,10 @@ module sonic-tc-queue-map { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC TC_TO_QUEUE_MAP"; diff --git a/src/cvl/schema/sonic-vlan-dev.yang b/src/cvl/testdata/schema/sonic-vlan-dev.yang similarity index 96% rename from src/cvl/schema/sonic-vlan-dev.yang rename to src/cvl/testdata/schema/sonic-vlan-dev.yang index 9ee9e6eede..dcb6531126 100644 --- a/src/cvl/schema/sonic-vlan-dev.yang +++ b/src/cvl/testdata/schema/sonic-vlan-dev.yang @@ -12,10 +12,10 @@ module sonic-vlan-dev { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC VLAN deviation file"; diff --git a/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp b/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp new file mode 100644 index 0000000000..1ccfd03006 --- /dev/null +++ b/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp @@ -0,0 +1,30 @@ + + + + + + + + + + + + + SONiC + + + SONiC + + + SONIC VLAN deviation file + + + + Initial revision. + + + diff --git a/src/cvl/schema/sonic-vlan-interface.yang b/src/cvl/testdata/schema/sonic-vlan-interface.yang similarity index 97% rename from src/cvl/schema/sonic-vlan-interface.yang rename to src/cvl/testdata/schema/sonic-vlan-interface.yang index 7f186b9ff0..86b9f8c0f3 100644 --- a/src/cvl/schema/sonic-vlan-interface.yang +++ b/src/cvl/testdata/schema/sonic-vlan-interface.yang @@ -19,10 +19,10 @@ module sonic-vlan-interface { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC VLAN INTERFACE"; diff --git a/src/cvl/schema/sonic-vlan.yang b/src/cvl/testdata/schema/sonic-vlan.yang similarity index 98% rename from src/cvl/schema/sonic-vlan.yang rename to src/cvl/testdata/schema/sonic-vlan.yang index f8c0bc1b48..5a043b5f22 100644 --- a/src/cvl/schema/sonic-vlan.yang +++ b/src/cvl/testdata/schema/sonic-vlan.yang @@ -20,10 +20,10 @@ module sonic-vlan { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC VLAN"; diff --git a/src/cvl/schema/sonic-wred-profile.yang b/src/cvl/testdata/schema/sonic-wred-profile.yang similarity index 98% rename from src/cvl/schema/sonic-wred-profile.yang rename to src/cvl/testdata/schema/sonic-wred-profile.yang index 96ddd89d64..89b9c90ef5 100644 --- a/src/cvl/schema/sonic-wred-profile.yang +++ b/src/cvl/testdata/schema/sonic-wred-profile.yang @@ -11,10 +11,10 @@ module sonic-wred-profile { } organization - "BRCM"; + "SONiC"; contact - "BRCM"; + "SONiC"; description "SONIC WRED_PROFILE"; diff --git a/src/cvl/tests/Makefile b/src/cvl/tests/Makefile index 36ddbc1a33..64b8eb1c6c 100644 --- a/src/cvl/tests/Makefile +++ b/src/cvl/tests/Makefile @@ -9,6 +9,7 @@ all:tests tests: $(OUT) %:%.go + make -C ../testdata/schema @echo "Building $@ ..." GOPATH=$(GOPATH) $(GO) build -gcflags="all=-N -l" $< From 4dd512a15fe6df14ece91a1d701d2ab228147990 Mon Sep 17 00:00:00 2001 From: Partha Dutta Date: Wed, 18 Sep 2019 10:33:20 +0530 Subject: [PATCH 2/4] Updated Makefiles --- src/cvl/Makefile | 3 +-- src/cvl/internal/yparser/yparser.go | 8 ++------ src/cvl/testdata/schema/Makefile | 5 ++--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/cvl/Makefile b/src/cvl/Makefile index 198a541290..54c3980818 100644 --- a/src/cvl/Makefile +++ b/src/cvl/Makefile @@ -53,8 +53,7 @@ gotest: make -C schema make -C testdata/schema cp schema/*.yin testdata/schema - #CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/schema:$(abspath .)/testdata/schema GOPATH=$(GOPATH) tests/run_test.sh - CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/schema GOPATH=$(GOPATH) tests/run_test.sh + CVL_CFG_FILE=$(abspath .)/conf/cvl_cfg.json CVL_SCHEMA_PATH=$(abspath .)/testdata/schema GOPATH=$(GOPATH) tests/run_test.sh clean: make -C tests clean diff --git a/src/cvl/internal/yparser/yparser.go b/src/cvl/internal/yparser/yparser.go index a654d34fc2..a41a058507 100644 --- a/src/cvl/internal/yparser/yparser.go +++ b/src/cvl/internal/yparser/yparser.go @@ -7,7 +7,6 @@ import ( "strings" log "github.com/golang/glog" . "cvl/internal/util" - "fmt" ) /* @@ -236,10 +235,7 @@ func ParseSchemaFile(modelFile string) (*YParserModule, YParserError) { module := C.lys_parse_path((*C.struct_ly_ctx)(ypCtx), C.CString(modelFile), C.LYS_IN_YIN) if module == nil { - fmt.Printf("\n\nFailed Parsed file .... %s\n\n", modelFile) return nil, getErrorDetails() - } else { - fmt.Printf("\n\nParsed file .... %s\n\n", modelFile) } if (strings.Contains(modelFile, "sonic-common.yin") == true) { @@ -254,11 +250,11 @@ func ParseSchemaFile(modelFile string) (*YParserModule, YParserError) { //Add child node to a parent node func(yp *YParser) AddChildNode(module *YParserModule, parent *YParserNode, name string) *YParserNode { - //return (*YParserNode)(C.lyd_new((*C.struct_lyd_node)(parent), (*C.struct_lys_module)(module), C.CString(name))) ret := (*YParserNode)(C.lyd_new((*C.struct_lyd_node)(parent), (*C.struct_lys_module)(module), C.CString(name))) if (ret == nil) { - fmt.Printf("\n\nFailed parsing .... %s\n\n", name) + TRACE_LOG(INFO_DEBUG, TRACE_YPARSER, "Failed parsing node %s\n", name) } + return ret } diff --git a/src/cvl/testdata/schema/Makefile b/src/cvl/testdata/schema/Makefile index daf398bd65..8fabd881ed 100644 --- a/src/cvl/testdata/schema/Makefile +++ b/src/cvl/testdata/schema/Makefile @@ -10,7 +10,7 @@ schema: $(out) @echo "Generating $@ ..." @devFile="`echo $< | cut -d . -f1`-dev.yang"; \ if [ -f $$devFile ] ; then devOpt="--deviation-module $$devFile"; fi; \ - pyang -p /home/pd945169/mgmt_framework_pr/sonic-mgmt-framework/src/cvl/schema:../../schema/:../../schema/ietf/ -f yin $$devOpt $< -o $@.tmp + pyang -p ../../schema/:../../schema/ietf/ -f yin $$devOpt $< -o $@.tmp @xmllint --noblanks $@.tmp > $@ @rm -rf $@.tmp @@ -22,5 +22,4 @@ schema: $(out) clean: @echo "Removing files ..." - rm -rf $(out) - rm -rf $(out_ext) + rm -rf *.yin From a2714372ad7373ac826997c2d68b849eda1aa08e Mon Sep 17 00:00:00 2001 From: Partha Dutta Date: Wed, 18 Sep 2019 10:45:49 +0530 Subject: [PATCH 3/4] Delete file checked in mistakenly. --- .../testdata/schema/sonic-vlan-dev.yin.tmp | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp diff --git a/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp b/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp deleted file mode 100644 index 1ccfd03006..0000000000 --- a/src/cvl/testdata/schema/sonic-vlan-dev.yin.tmp +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - SONiC - - - SONiC - - - SONIC VLAN deviation file - - - - Initial revision. - - - From 692beca2ab2d5f4850ecb9ddab7c6fdeb377c5cb Mon Sep 17 00:00:00 2001 From: Partha Dutta Date: Wed, 18 Sep 2019 11:30:44 +0530 Subject: [PATCH 4/4] Updated new Makefile with license, copy schema from testdata/schema also. --- Makefile | 1 + src/cvl/schema/sonic-acl.yang | 8 ++++---- src/cvl/testdata/schema/Makefile | 19 +++++++++++++++++++ src/cvl/testdata/schema/sonic-acl-dev.yang | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d2f9b1fe07..01d0a951db 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,7 @@ install: $(INSTALL) -d $(DESTDIR)/usr/sbin/schema/ $(INSTALL) -d $(DESTDIR)/usr/sbin/lib/ $(INSTALL) -D $(TOPDIR)/src/cvl/schema/*.yin $(DESTDIR)/usr/sbin/schema/ + $(INSTALL) -D $(TOPDIR)/src/cvl/testdata/schema/*.yin $(DESTDIR)/usr/sbin/schema/ cp -rf $(TOPDIR)/build/rest_server/dist/ui/ $(DESTDIR)/rest_ui/ cp -rf $(TOPDIR)/build/cli $(DESTDIR)/usr/sbin/ cp -rf $(TOPDIR)/build/swagger_client_py/ $(DESTDIR)/usr/sbin/lib/ diff --git a/src/cvl/schema/sonic-acl.yang b/src/cvl/schema/sonic-acl.yang index c2a96aaccb..fc65e5ac4a 100644 --- a/src/cvl/schema/sonic-acl.yang +++ b/src/cvl/schema/sonic-acl.yang @@ -143,11 +143,11 @@ module sonic-acl { } leaf ETHER_TYPE { - type string{ - pattern "(0x88CC)|(0x8100)|(0x8915)|(0x0806)|(0x0800)|(0x86DD)|(0x8847)"{ + type string { + pattern "(0x88CC)|(0x8100)|(0x8915)|(0x0806)|(0x0800)|(0x86DD)|(0x8847)" { error-message "Invalid ACL Rule Ether Type"; - error-app-tag ether-type-invalid; - } + error-app-tag ether-type-invalid; + } } } diff --git a/src/cvl/testdata/schema/Makefile b/src/cvl/testdata/schema/Makefile index 8fabd881ed..308b3eaf6b 100644 --- a/src/cvl/testdata/schema/Makefile +++ b/src/cvl/testdata/schema/Makefile @@ -1,3 +1,22 @@ +################################################################################ +# # +# Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or # +# its subsidiaries. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# # +################################################################################ + src_files=$(wildcard *.yang) out=$(patsubst %.yang, %.yin, $(src_files)) out_ext=$(patsubst %.yang, %.tree, $(src_files)) diff --git a/src/cvl/testdata/schema/sonic-acl-dev.yang b/src/cvl/testdata/schema/sonic-acl-dev.yang index 9c47e0fd0b..7fcf99f931 100644 --- a/src/cvl/testdata/schema/sonic-acl-dev.yang +++ b/src/cvl/testdata/schema/sonic-acl-dev.yang @@ -27,7 +27,7 @@ module sonic-acl-dev { "SONiC"; description - "SONIC ACLi Deviations"; + "SONIC ACL Deviations"; revision 2019-05-15 { description