diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-28 09:37:50 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-28 09:37:50 -0700 |
commit | 8436e5f8dd8eb59173939bcf6eb1a4e8c890abd3 (patch) | |
tree | 2478db611ecc98b77a4d0926eff85a7970c26b8a /lib/Vyatta/Config.pm | |
parent | 40f005b735d0db0415c819061614062219ef600c (diff) | |
download | vyatta-cfg-8436e5f8dd8eb59173939bcf6eb1a4e8c890abd3.tar.gz vyatta-cfg-8436e5f8dd8eb59173939bcf6eb1a4e8c890abd3.zip |
addition support for deactivate mode in perl api. Nodes should now be masked when deactivated--deactivated
nodes will appear as deleted.
Diffstat (limited to 'lib/Vyatta/Config.pm')
-rwxr-xr-x | lib/Vyatta/Config.pm | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index cc917b4..704e761 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -248,7 +248,12 @@ sub listOrigNodes { $tmp =~ s/\n//g; $tmp =~ s/%2F/\//g; #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n"; - push @nodes_modified, $tmp; + my $ttmp = $self->{_current_dir_level} . "/" . $tmp; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + if (!defined($status) || $status eq 'active') { + push @nodes_modified, $tmp; + } } return @nodes_modified; @@ -284,7 +289,12 @@ sub listOrigNodesNoDef { $tmp =~ s/%2F/\//g; #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n"; if ($tmp ne 'def') { - push @nodes_modified, $tmp; + my $ttmp = $self->{_current_dir_level} . "/" . $tmp; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + if (!defined($status) || $status eq 'active') { + push @nodes_modified, $tmp; + } } } @@ -324,14 +334,21 @@ sub returnValue { $node =~ s/\//%2F/g; $node =~ s/\s+/\//g; - return unless - open my $file, '<', - "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node/node.val"; - - read $file, $tmp, 16384; - close $file; - - $tmp =~ s/\n$//; + #getDeactivated + my $ttmp = $self->{_current_dir_level} . "/" . $node; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + #only return value if status is not disabled (i.e. local or both) + if (!defined($status) || $status eq 'active') { + return unless + open my $file, '<', + "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node/node.val"; + + read $file, $tmp, 16384; + close $file; + + $tmp =~ s/\n$//; + } return $tmp; } @@ -410,14 +427,23 @@ sub returnOrigValue { $node =~ s/\//%2F/g; $node =~ s/\s+/\//g; - my $filepath = "$self->{_active_dir_base}$self->{_current_dir_level}/$node"; - return unless open my $file, '<', "$filepath/node.val"; - - read $file, $tmp, 16384; - close $file; - $tmp =~ s/\n$//; + #getDeactivated + my $ttmp = $self->{_current_dir_level} . "/" . $node; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + #only return value if status is not disabled (i.e. local or both) + if (!defined($status) || $status eq 'active') { + my $filepath = "$self->{_active_dir_base}$self->{_current_dir_level}/$node"; + + return unless open my $file, '<', "$filepath/node.val"; + + read $file, $tmp, 16384; + close $file; + + $tmp =~ s/\n$//; + } return $tmp; } @@ -522,6 +548,16 @@ sub existsOrig { $node =~ s/\//%2F/g; $node =~ s/\s+/\//g; + #getDeactivated() + my $ttmp = $self->{_current_dir_level} . "/" . $node; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + #only return value if status is not disabled (i.e. local or both) + if (defined($status)) { #if a .disable is in local or active or both then return false + return (1 != 1); + } + + return ( -d "$self->{_active_dir_base}$self->{_current_dir_level}/$node" ); } @@ -537,6 +573,15 @@ sub isDeleted { my $filepathNew = "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node"; + #getDeactivated() + my $ttmp = $self->{_current_dir_level} . "/" . $node; + $ttmp =~ s/\// /g; + my ($status, undef) = $self->getDeactivated($ttmp); + #only return value if status is not disabled (i.e. local or both) + if (defined($status) && $status eq 'local') { + return (-e $filepathAct); + } + return ((-e $filepathAct) && !(-e $filepathNew)); } |