diff options
author | Michael Larson <mike@ft1.vyatta.com> | 2009-09-11 10:58:24 -0700 |
---|---|---|
committer | Michael Larson <mike@ft1.vyatta.com> | 2009-09-11 10:58:24 -0700 |
commit | 9509f185e4d4d96e326035aa9f0fad1b898b5a3c (patch) | |
tree | e921b88d09a1d765afa6b99c5add01dfe0b59abd /lib | |
parent | 9b6b62c3792ffcea6d9ae240a6dbe5b04065bf1e (diff) | |
download | vyatta-cfg-9509f185e4d4d96e326035aa9f0fad1b898b5a3c.tar.gz vyatta-cfg-9509f185e4d4d96e326035aa9f0fad1b898b5a3c.zip |
leaf node support for new commit. Returns reconciled processed node returnOrigPlusComValue()
no term multinode leaf support yet.
Diffstat (limited to 'lib')
-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. |