From c76441272e7bc3e8ca8fc14f1929653d48d9276b Mon Sep 17 00:00:00 2001 From: Max Rottenkolber Date: Fri, 11 Nov 2022 16:34:49 +0100 Subject: [PATCH] lib.yang.path/path_data: handle rpc schema --- src/lib/yang/path.lua | 4 ++++ src/lib/yang/path_data.lua | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/yang/path.lua b/src/lib/yang/path.lua index 9ef9eccf35..839d79ed79 100644 --- a/src/lib/yang/path.lua +++ b/src/lib/yang/path.lua @@ -84,6 +84,10 @@ local function extract_grammar_node(grammar, name) function handlers.array () error("Invalid path: trying to access '"..name.."' in leaf-list.") end + -- rpc + function handlers.sequence (node) + if node.members[name] then return node.members[name] end + end local node = assert(handlers[grammar.type], grammar.type)(grammar) return node or error("Invalid path: '"..name.."' is not in schema.") end diff --git a/src/lib/yang/path_data.lua b/src/lib/yang/path_data.lua index b0ca63c463..2e805af9bd 100644 --- a/src/lib/yang/path_data.lua +++ b/src/lib/yang/path_data.lua @@ -51,11 +51,11 @@ local function compute_list_getter(key, getter) end local function compute_getter(grammar, part, getter) - if grammar.type == 'struct' then + if grammar.type == 'struct' or grammar.type == 'sequence' then getter = compute_struct_getter(part.name, getter) grammar = part.grammar else - error("Invalid path: '"..name.."' is not a container") + error("Invalid path: '"..part.name.."' is not a container") end if part.key then if grammar.type == 'array' then