Skip to content

Commit 39afe5e

Browse files
stewegrjarry
authored andcommitted
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 <[email protected]>
1 parent 2740fa2 commit 39afe5e

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
@@ -526,6 +526,7 @@ def validate(
526526
rpc: bool = False,
527527
rpcreply: bool = False,
528528
notification: bool = False,
529+
dep_tree: Optional["DNode"] = None,
529530
) -> None:
530531
dtype = None
531532
if rpc:
@@ -538,7 +539,7 @@ def validate(
538539
if dtype is None:
539540
self.validate_all(no_state, validate_present)
540541
else:
541-
self.validate_op(dtype)
542+
self.validate_op(dtype, dep_tree)
542543

543544
def validate_all(
544545
self,
@@ -560,11 +561,15 @@ def validate_all(
560561
def validate_op(
561562
self,
562563
dtype: DataType,
564+
dep_tree: Optional["DNode"] = None,
563565
) -> None:
564566
dtype = data_type(dtype)
565-
node_p = ffi.new("struct lyd_node **")
566-
node_p[0] = self.cdata
567-
ret = lib.lyd_validate_op(node_p[0], ffi.NULL, dtype, ffi.NULL)
567+
ret = lib.lyd_validate_op(
568+
self.cdata,
569+
ffi.NULL if dep_tree is None else dep_tree.cdata,
570+
dtype,
571+
ffi.NULL,
572+
)
568573
if ret != lib.LY_SUCCESS:
569574
raise self.context.error("validation failed")
570575

0 commit comments

Comments
 (0)