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

Using YANG list with multiple keys #1215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions src/lib/yang/test-schema-v1.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module test-schema-v1 {
namespace snabb:test;
prefix test;

import ietf-inet-types { prefix inet; }
import ietf-yang-types { prefix yang; }

container test-config {
container ports {
container port-range {
leaf start {type uint16; default 1025;}
leaf end {type uint16; default 32000;}
}
}
}

container test-list {
list entry {
key "ip01 port01";
leaf ip01 { type inet:ipv4-address; mandatory true; }
leaf port01 { type uint16; mandatory true; }
leaf ip02 { type inet:ipv4-address; mandatory true; }
leaf port02 { type uint16; mandatory true; }
}
}
}
5 changes: 5 additions & 0 deletions src/program/test_yang/test_yang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test-list {
entry{ip01 192.168.1.195; port01 22; ip02 192.168.11.229; port02 22; }
entry{ip01 192.168.1.194; port01 80; ip02 192.168.11.230; port02 80; }
}

19 changes: 19 additions & 0 deletions src/program/test_yang/test_yang.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module(..., package.seeall)

local schema = require("lib.yang.schema")
local yang = require('lib.yang.yang')

function run (parameters)
local schema_name = 'test-schema-v1'
local schema = schema.load_schema_by_name(schema_name)
local conf = yang.load_configuration(parameters[1],{schema_name=schema_name, verbose = true})

local test_list = conf.test_list.entry
for k,v in pairs(test_list) do
print (k)
end

local c = config.new()
engine.configure(c)
engine.main({duration=1})
end