diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-09-11 14:45:58 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-09-11 14:45:58 -0700 |
commit | 92552a6237a9c59fbc4ed6350a8b6c2bee8a2c73 (patch) | |
tree | 3f8b6a4bf7ca7f2c8861bd6014dfb995efad0cd3 | |
parent | 0ddb57b94127830a7cf593ce60696e71cef2662e (diff) | |
parent | 9509f185e4d4d96e326035aa9f0fad1b898b5a3c (diff) | |
download | vyatta-cfg-92552a6237a9c59fbc4ed6350a8b6c2bee8a2c73.tar.gz vyatta-cfg-92552a6237a9c59fbc4ed6350a8b6c2bee8a2c73.zip |
Merge branch 'kenwood' of suva.vyatta.com:/git/vyatta-cfg into kenwood
-rwxr-xr-x | lib/Vyatta/Config.pm | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index c97152c..ec74904 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -142,23 +142,23 @@ sub listOrigPlusComNodes { $level = ""; } + my $dir_path = $level; + if (defined $path) { + $dir_path .= " " . $path; + } + $dir_path =~ s/ /\//g; + $dir_path = "/".$dir_path; + #now test against the inprocess file in the system # my $com_file = "/tmp/.changes_$$"; my $com_file = "/tmp/.changes"; - open FILE, "<", $com_file; if (-e $com_file) { + open FILE, "<", $com_file; foreach my $line (<FILE>) { my @node = split " ", $line; #split on space #$node[1] is of the form: system/login/blah #$coll is of the form: blah - my $dir_path = $level; - if (defined $path) { - $dir_path .= " " . $path; - } - $dir_path =~ s/ /\//g; - $dir_path = "/".$dir_path; - # print("comparing: $dir_path and $level to $node[1]\n"); #first only consider $path matches against $node[1] @@ -201,6 +201,7 @@ sub listOrigPlusComNodes { } } } + close $com_file; } #print "coll count: ".keys(%coll); @@ -327,6 +328,49 @@ sub returnValue { return $tmp; } +## returnOrigPlusComValue("node") +# returns the value of "node" or undef if the node doesn't exist . +# node is relative +sub returnOrigPlusComValue { + my ( $self, $path ) = @_; + + my $tmp = returnValue($self,$path); + + 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 + if ($node[0] eq '+') { + my $pos = rindex($node[1],"/"); + $tmp = substr($node[1],$pos+7); + } + else { + $tmp = ""; + } + last; + } + } + close $com_file; + } + return $tmp; +} + + ## returnOrigValue("node") # returns the original value of "node" (i.e., before the current change; i.e., # in "working") or undef if the node doesn't exist. |