diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-03-05 17:50:38 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-03-05 17:50:38 -0800 |
commit | 3968e2fc5b06c5603fbba25491717983a684e801 (patch) | |
tree | a0527f82e551c9e4f9c768cc78db073824267fa7 /lib/Vyatta/Config.pm | |
parent | 14db16773514b4d972fad8e81fa5ff3529ddacb8 (diff) | |
download | vyatta-cfg-3968e2fc5b06c5603fbba25491717983a684e801.tar.gz vyatta-cfg-3968e2fc5b06c5603fbba25491717983a684e801.zip |
add function for traversing template hierarchy
Diffstat (limited to 'lib/Vyatta/Config.pm')
-rwxr-xr-x | lib/Vyatta/Config.pm | 15 |
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. |