summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-03-05 17:50:38 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2010-03-05 17:50:38 -0800
commit3968e2fc5b06c5603fbba25491717983a684e801 (patch)
treea0527f82e551c9e4f9c768cc78db073824267fa7 /lib
parent14db16773514b4d972fad8e81fa5ff3529ddacb8 (diff)
downloadvyatta-cfg-3968e2fc5b06c5603fbba25491717983a684e801.tar.gz
vyatta-cfg-3968e2fc5b06c5603fbba25491717983a684e801.zip
add function for traversing template hierarchy
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/Config.pm15
1 files changed, 15 insertions, 0 deletions
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.