From 3968e2fc5b06c5603fbba25491717983a684e801 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Fri, 5 Mar 2010 17:50:38 -0800 Subject: add function for traversing template hierarchy --- lib/Vyatta/Config.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 515be64..df4d20f 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -760,6 +760,21 @@ sub parseTmplAll { return \%ret; } +# $cfg_path: config path of the node. +# returns the list of the node's children in the template hierarchy. +sub getTmplChildren { + my ($self, $cfg_path) = @_; + my @pdirs = split(/ +/, $cfg_path); + my $tpath = $self->getTmplPath(\@pdirs); + return () unless $tpath; + + opendir (my $tdir, $tpath) or return; + my @tchildren = grep !/^node\.def$/, (grep !/^\./, (readdir $tdir)); + closedir $tdir; + + return @tchildren; +} + ###### misc functions ###### # compare two value lists and return "deleted" and "added" lists. -- cgit v1.2.3