diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-14 13:47:21 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-14 13:47:21 -0700 |
commit | d36d0a6ea76d443c5e4072401eaa9dbf563c74bd (patch) | |
tree | 9daed3e19d3d5b8231a9894891ac00d4df9b9c3a /scripts/vyatta-load-config.pl | |
parent | 91bb77e328c9cad994609aeeccb33971eca1486f (diff) | |
download | vyatta-cfg-d36d0a6ea76d443c5e4072401eaa9dbf563c74bd.tar.gz vyatta-cfg-d36d0a6ea76d443c5e4072401eaa9dbf563c74bd.zip |
initial checkin of comment feature for cli.
/* to create a comment */
> comment [PATH-TO-NODE] "my comments"
/* to delete a comment */
> comment [PATH-TO-NODE] ""
Diffstat (limited to 'scripts/vyatta-load-config.pl')
-rwxr-xr-x | scripts/vyatta-load-config.pl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index ab5a47e..62d6e8b 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -191,6 +191,7 @@ if ( scalar( keys %cfg_hier ) == 0 ) { my %cfg_diff = Vyatta::ConfigLoad::getConfigDiff( \%cfg_hier ); my @set_list = @{ $cfg_diff{'set'} }; my @deactivate_list = @{ $cfg_diff{'deactivate'} }; +my @comment_list = @{ $cfg_diff{'comment'} }; if ($merge_mode eq 'false') { my @delete_list = @{ $cfg_diff{'delete'} }; @@ -226,6 +227,42 @@ foreach (@deactivate_list) { #ignore error on complaint re: nested nodes } +foreach (@comment_list) { + my ( $cmd_ref ) = $_; + #apply comment if it doesn't have an empty element at the array and a .comment file exists and this is not a merge + if ($merge_mode eq 'false' && $cmd_ref =~ /\"\"$/) { + my @cmd_array = split(" ",$cmd_ref); + pop(@cmd_array); + my $rel_path = join '/', @cmd_array; + my $path = "/opt/vyatta/config/active/" . $rel_path . "/.comment"; + if (-e $path) { + my @cmd = ( "$sbindir/vyatta-comment-config.pl ", $cmd_ref ); + my $cmd_str = join ' ', @cmd; + system("$cmd_str 1>/dev/null"); + } + else { + #not found, maybe a leaf? + pop(@cmd_array); + $rel_path = join '/', @cmd_array; + my $leaf = "/opt/vyatta/config/active/" . $rel_path . "/node.val"; + if (-e $leaf) { + $path = "/opt/vyatta/config/active/" . $rel_path . "/.comment"; + if (-e $path) { + my @cmd = ( "$sbindir/vyatta-comment-config.pl ", $cmd_ref ); + my $cmd_str = join ' ', @cmd; + system("$cmd_str 1>/dev/null"); + } + } + } + } + else { + my @cmd = ( "$sbindir/vyatta-comment-config.pl ", $cmd_ref ); + my $cmd_str = join ' ', @cmd; + system("$cmd_str 1>/dev/null"); + } + #ignore error on complaint re: nested nodes +} + system("$sbindir/my_commit"); if ( $? >> 8 ) { print "Load failed (commit failed)\n"; |