Skip to content

Commit e061ba3

Browse files
committed
data: adding dep_tree option for RPC validation
This patch introduces dep_tree option to provide config data to which the RPC can referenced to during validation Signed-off-by: Stefan Gula <steweg@gmail.com>
1 parent 3072af0 commit e061ba3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

libyang/data.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ def validate(
532532
rpc: bool = False,
533533
rpcreply: bool = False,
534534
notification: bool = False,
535+
dep_tree: Optional["DNode"] = None,
535536
) -> None:
536537
dtype = None
537538
if rpc:
@@ -544,7 +545,7 @@ def validate(
544545
if dtype is None:
545546
self.validate_all(no_state, validate_present)
546547
else:
547-
self.validate_op(dtype)
548+
self.validate_op(dtype, dep_tree)
548549

549550
def validate_all(
550551
self,
@@ -566,11 +567,15 @@ def validate_all(
566567
def validate_op(
567568
self,
568569
dtype: DataType,
570+
dep_tree: Optional["DNode"] = None,
569571
) -> None:
570572
dtype = data_type(dtype)
571-
node_p = ffi.new("struct lyd_node **")
572-
node_p[0] = self.cdata
573-
ret = lib.lyd_validate_op(node_p[0], ffi.NULL, dtype, ffi.NULL)
573+
ret = lib.lyd_validate_op(
574+
self.cdata,
575+
ffi.NULL if dep_tree is None else dep_tree.cdata,
576+
dtype,
577+
ffi.NULL,
578+
)
574579
if ret != lib.LY_SUCCESS:
575580
raise self.context.error("validation failed")
576581

0 commit comments

Comments
 (0)