diff options
author | Michael Larson <mike@ft1.vyatta.com> | 2009-09-11 16:08:43 -0700 |
---|---|---|
committer | Michael Larson <mike@ft1.vyatta.com> | 2009-09-11 16:08:43 -0700 |
commit | 6870f3dc627f8ec3711ae12b0ff26afa9b3ed0cd (patch) | |
tree | bd1f077456ee27d9793b9ffa6240ffdc33cc7bb2 /lib/Vyatta | |
parent | 51ddc5fc71e45ad5d599a5f4908b49fc929c3f02 (diff) | |
download | vyatta-cfg-6870f3dc627f8ec3711ae12b0ff26afa9b3ed0cd.tar.gz vyatta-cfg-6870f3dc627f8ec3711ae12b0ff26afa9b3ed0cd.zip |
term multinodes perl api support to provide currently committed values.
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/Config.pm | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index ec74904..b7d9050 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -356,7 +356,7 @@ sub returnOrigPlusComValue { if (index($node[1],$dir_path) != -1) { #found, now figure out if this a set or delete if ($node[0] eq '+') { - my $pos = rindex($node[1],"/"); + my $pos = rindex($node[1],"/value:"); $tmp = substr($node[1],$pos+7); } else { @@ -404,6 +404,63 @@ sub returnValues { return @values; } +## returnValues("node") +# returns an array of all the values of "node", or an empty array if the values do not exist. +# node is relative +sub returnOrigPlusComValues { + my ( $self, $path ) = @_; + my @values = returnValues($self,$path); + + #now parse the commit accounting file. + my $level = $self->{_level}; + if (! defined $level) { + $level = ""; + } + my $dir_path = $level; + if (defined $path) { + $dir_path .= " " . $path; + } + $dir_path =~ s/ /\//g; + $dir_path = "/".$dir_path."/value"; + + #now need to compare this against what I've done + my $com_file = "/tmp/.changes"; + if (-e $com_file) { + open FILE, "<", $com_file; + foreach my $line (<FILE>) { + my @node = split " ", $line; #split on space + if (index($node[1],$dir_path) != -1) { + #found, now figure out if this a set or delete + my $pos = rindex($node[1],"/value:"); + my $tmp = substr($node[1],$pos+7); + my $i = 0; + my $match = 0; + foreach my $v (@values) { + if ($v eq $tmp) { + $match = 1; + last; + } + $i = $i + 1; + } + if ($node[0] eq '+') { + #add value + if ($match == 0) { + push(@values,$tmp); + } + } + else { + #remove value + if ($match == 1) { + splice(@values,$i); + } + } + } + } + close $com_file; + } + return @values; +} + ## returnOrigValues("node") # returns an array of all the original values of "node" (i.e., before the # current change; i.e., in "working"), or an empty array if the values do not |