From d36d0a6ea76d443c5e4072401eaa9dbf563c74bd Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Fri, 14 May 2010 13:47:21 -0700 Subject: 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] "" --- scripts/vyatta-config-loader.pl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'scripts/vyatta-config-loader.pl') diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl index 7a3df2b..b8e594e 100755 --- a/scripts/vyatta-config-loader.pl +++ b/scripts/vyatta-config-loader.pl @@ -46,7 +46,7 @@ sub restore_fds { } # get a list of all config statement in the startup config file -my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0]); +my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0],'true'); if (scalar(@all_nodes) == 0) { # no config statements restore_fds(); @@ -72,6 +72,32 @@ foreach (@all_nodes) { my ($path_ref, $rank) = @$_; my @pr = @$path_ref; + if (@pr[0] =~ /^comment$/) { + my $ct = 0; + my $rel_path; + foreach my $rp (@pr[1..$#pr]) { + $ct++; + my $tmp_path = $rel_path . "/" . $rp; + my $node_path = "/opt/vyatta/share/vyatta-cfg/templates/" . $tmp_path . "/node.def"; + if ($rp eq '"') { + last; + } + elsif ($rp eq '""') { + last; + } + elsif (!-e $node_path) { + #pop this element + delete @pr[$ct]; + last; + } + $rel_path = $tmp_path; + } + + my $comment_cmd = "$CWRAPPER " . join(" ",@pr) ; + `$comment_cmd`; + next; + } + if (@pr[0] eq '!') { @pr = @pr[1..$#pr]; my $deactivate_cmd = "$CWRAPPER deactivate " . (join ' ', @pr) . " 1>/dev/null"; -- cgit v1.2.3