From 0d020c8b938443ac8875bcfcff231dd1bf0d1d41 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Wed, 5 May 2010 16:50:44 -0700 Subject: boot loader support now added. various bug fixes and some small rework. --- lib/Vyatta/Config.pm | 26 ++++++++++++++++---------- lib/Vyatta/ConfigLoad.pm | 9 ++++++--- lib/Vyatta/ConfigOutput.pm | 8 ++++---- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 8de3aba..82d835f 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -532,6 +532,7 @@ sub getDeactivated { my ($self, $node) = @_; if (!defined $node) { + $node = $self->{_level}; } # let's setup the filepath for the change_dir @@ -634,7 +635,7 @@ sub isAdded { # node name is the hash key. node status is the hash value. # node status can be one of deleted, added, changed, or static sub listNodeStatus { - my ($self, $path) = @_; + my ($self, $path, $disable) = @_; my @nodes = (); my %nodehash = (); @@ -647,15 +648,20 @@ sub listNodeStatus { @nodes = (); @nodes = $self->listNodes($path); foreach my $node (@nodes) { - if ($node =~ /.+/) { - my $nodepath = $node; - $nodepath = "$path $node" if ($path); - #print "DEBUG Vyatta::Config->listNodeStatus(): node $node\n"; - # No deleted nodes -- added, changed, ot static only. - if ($self->isAdded($nodepath)) { $nodehash{$node} = "added"; } - elsif ($self->isChanged($nodepath)) { $nodehash{$node} = "changed"; } - else { $nodehash{$node} = "static"; } - } + if ($node =~ /.+/) { + my $status = undef; + if (!defined $disable) { + ($status,undef) = $self->getDeactivated($self->{_level}." ".$node); + } + my $nodepath = $node; + $nodepath = "$path $node" if ($path); + #print "DEBUG Vyatta::Config->listNodeStatus(): node $node\n"; + # No deleted nodes -- added, changed, ot static only. + if (defined $status && $status eq 'local') { $nodehash{$node} = "deleted"; } + elsif ($self->isAdded($nodepath)) { $nodehash{$node} = "added"; } + elsif ($self->isChanged($nodepath)) { $nodehash{$node} = "changed"; } + else { $nodehash{$node} = "static"; } + } } return %nodehash; diff --git a/lib/Vyatta/ConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm index 54befc6..28e932e 100755 --- a/lib/Vyatta/ConfigLoad.pm +++ b/lib/Vyatta/ConfigLoad.pm @@ -87,13 +87,16 @@ sub enumerate_branch { push @cur_path, $val; } if (defined $cur_node->{'disable'}) { - push @all_naked_nodes, [ '!', @cur_path ]; + push @all_naked_nodes, [ '!', @cur_path ]; + my @qpath = applySingleQuote(@cur_path); + unshift(@qpath,'!'); + push @all_nodes, [\@qpath, 0]; } else { push @all_naked_nodes, [ @cur_path ]; + my @qpath = applySingleQuote(@cur_path); + push @all_nodes, [\@qpath, 0]; } - my @qpath = applySingleQuote(@cur_path); - push @all_nodes, [\@qpath, 0]; } } diff --git a/lib/Vyatta/ConfigOutput.pm b/lib/Vyatta/ConfigOutput.pm index fd377d7..caa9356 100755 --- a/lib/Vyatta/ConfigOutput.pm +++ b/lib/Vyatta/ConfigOutput.pm @@ -138,7 +138,7 @@ sub displayValues { } } - my %cnodes = $config->listNodeStatus(); + my %cnodes = $config->listNodeStatus(undef,'true'); my @cnames = sort keys %cnodes; if (defined($simple_show)) { @@ -298,7 +298,7 @@ sub displayChildren { } $config->setLevel(join ' ', (@cur_path, $child)); - my %cnodes = $config->listNodeStatus(); + my %cnodes = $config->listNodeStatus(undef,'true'); my @cnames = sort keys %cnodes; #if node.val exists and ct == 0 w/o def or ct ==1 w/ def @@ -345,7 +345,7 @@ sub displayChildren { $dis, "$prefix "); } else { $config->setLevel(join ' ', (@cur_path, $child, $cname)); - my %ccnodes = $config->listNodeStatus(); + my %ccnodes = $config->listNodeStatus(undef,'true'); displayChildren(\%ccnodes, [ @cur_path, $child, $cname ], $dis, "$prefix "); } @@ -387,7 +387,7 @@ sub displayChildren { sub outputNewConfig { $config = new Vyatta::Config; $config->setLevel(join ' ', @_); - my %rnodes = $config->listNodeStatus(); + my %rnodes = $config->listNodeStatus(undef,'true'); if (scalar(keys %rnodes) > 0) { my @rn = keys %rnodes; -- cgit v1.2.3