Skip to content

Commit

Permalink
config-models: Updated TestDevice 2.0.0 YANG to pass linting (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCondon authored Nov 12, 2021
1 parent 533b12d commit 641e871
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jenkins-test: jenkins_version_check # @HELP run the jenkins verification tests
docker run --rm --name ct --volume `pwd`:/charts quay.io/helmpack/chart-testing:v3.0.0-beta.1 sh -c "ct lint --charts charts/onos-config,charts/onos-topo,charts/onos-cli,charts/onos-gui,charts/device-simulator --debug --validate-maintainers=false"

test: # @HELP run the integration tests
test: version_check
test: version_check yang-lint
kubectl create ns onos-topo && helmit test -n onos-topo ./test -c . --suite onos-topo
kubectl create ns onos-config && helmit test -n onos-config ./test -c . --suite onos-config
kubectl create ns onos-umbrella && helmit test -n onos-umbrella ./test -c . --suite onos-umbrella
Expand All @@ -33,6 +33,13 @@ build-tools: # @HELP install the ONOS build tools if needed
bumponosdeps: build-tools # @HELP update "onosproject" go dependencies and push patch to git.
./../build-tools/bump-onos-deps ${VERSION}

yang-lint: # @HELP install the ONOS build tools if needed
yang-lint: pyang-tool
pyang --lint config-models/testdevice-2.x/files/yang/*.yang

pyang-tool: # @HELP install the Pyang tool if needed
pyang --version || python -m pip install pyang==0.2.4

clean: # @HELP clean up temporary files.
rm -rf onos-umbrella/charts onos-umbrella/Chart.lock

Expand Down
2 changes: 1 addition & 1 deletion config-models/testdevice-2.x/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: config-model-testdevice
version: 2.0.3
version: 2.0.4
kubeVersion: ">=1.18.0"
appVersion: 2.0.0
description: TestDevice model
Expand Down
3 changes: 2 additions & 1 deletion config-models/testdevice-2.x/files/testdevice-2.0.0.tree
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module: test1
module: onf-test1
+--rw cont1a!
| +--rw cont2a
| | +--rw leaf2a? uint8
Expand Down Expand Up @@ -32,3 +32,4 @@ module: test1
+--ro cont2c
+--ro leaf3a? boolean
+--ro leaf3b? string

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module test1-augmented {
module onf-test1-augmented {
namespace "http://opennetworking.org/devicesim/test1-augmented";
prefix t1a;

import test1 { prefix t1; }
import onf-test1 { prefix t1; }


organization "Open Networking Foundation.";
Expand All @@ -20,29 +20,40 @@ module test1-augmented {
container cont2d {
leaf leaf2d3c {
type string;
description "string leaf on Container 2d augmented to cont1a";
}


choice snack {
description "straight from RFC-6020";
case sports-arena {
leaf pretzel {
type empty;
description "empty leaf in case sports-arena on Container 2d augmented to cont1a";
}
leaf beer {
type empty;
description "2nd empty leaf in case sports-arena on Container 2d augmented to cont1a";
}
}
case late-night {
leaf chocolate {
type enumeration {
enum dark;
enum milk;
enum first-available;
enum dark {
description "Dark Chocolate";
}
enum milk {
description "Milk Chocolate";
}
enum first-available {
description "First available Chocolate";
}
}
description "enumerated leaf in case late-night on Container 2d augmented to cont1a";
}
}
}
description "Container 2d";
}
description "Extending Container 1a";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module test1-identities {
module onf-test1-identities {
namespace "http://opennetworking.org/devicesim/test1-identities";
prefix t1id;

Expand All @@ -8,6 +8,8 @@ module test1-identities {

revision "2020-09-01" {
description "Initial Version";
reference
"onos unit testing";
}

identity MYBASE {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module test1 {
module onf-test1 {
namespace "http://opennetworking.org/devicesim/test1";
prefix t1;

import test1-identities { prefix t1id; }
import onf-test1-identities { prefix t1id; }

organization "Open Networking Foundation.";
contact "Sean Condon";
Expand All @@ -25,6 +25,9 @@ module test1 {
description "The top level container";

container cont2a {
must "leaf2g or leaf2a < 4" {
error-message "If Leaf 2a is above 4 then leaf2g must be true for the validation to pass";
}
description "The 2nd level container";

leaf leaf2a {
Expand All @@ -42,7 +45,6 @@ module test1 {
range -0.001..2.000;
}
units mV;
config true;
mandatory true;
description "Voltage leaf inside Container 2a";
}
Expand All @@ -68,6 +70,7 @@ module test1 {
type binary {
length 20;
}
description "binary leaf inside Container 2a";
}
leaf leaf2g {
type boolean;
Expand All @@ -83,6 +86,10 @@ module test1 {
}

list list2a {
must "tx-power < rx-power" {
error-message "tx-power is greater than or equal to rx-power";
description "tx-power must be less than rx-power - the only value they can share is 20";
}
key name;
max-elements 4;
description "A simple list of configuration items";
Expand Down Expand Up @@ -127,6 +134,7 @@ module test1 {
list list2b {
key "index1 index2";
config false;
max-elements 3;
description "A simple list of state items, with a double key";

leaf index1 {
Expand All @@ -140,10 +148,10 @@ module test1 {
}

leaf leaf3c {
config false;
type string {
length 1..20;
}
config false;
description "A string attribute in the list";
}

Expand All @@ -156,11 +164,11 @@ module test1 {
}

leaf leaf2d {
config false;
type uint16 {
range 10000..20000;
}
units mm;
config false;
description "A state attribute";
}

Expand Down
6 changes: 3 additions & 3 deletions config-models/testdevice-2.x/templates/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ spec:
type: TestDevice
version: {{ .Chart.AppVersion | quote }}
modules:
- name: test1
- name: onf-test1
organization: Open Networking Foundation
revision: 2019-06-10
file: test1@2019-06-10.yang
- name: test1-augmented
- name: onf-test1-augmented
organization: Open Networking Foundation
revision: 2020-02-29
file: test1-augmented@2020-02-29.yang
file: onf-test1-augmented@2020-02-29.yang
files:
{{- range $path, $_ := $.Files.Glob "files/yang/*.yang" }}
{{ base $path }}: |
Expand Down

0 comments on commit 641e871

Please sign in to comment.