summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-05-05 16:50:44 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-05-05 16:50:44 -0700
commit0d020c8b938443ac8875bcfcff231dd1bf0d1d41 (patch)
tree1f82593a10110b9b2872992e3dcdfe5a19115e32
parent0ffdc5e6d89f9677694a8eef916b07c089264753 (diff)
downloadvyatta-cfg-0d020c8b938443ac8875bcfcff231dd1bf0d1d41.tar.gz
vyatta-cfg-0d020c8b938443ac8875bcfcff231dd1bf0d1d41.zip
boot loader support now added. various bug fixes and some small rework.
-rwxr-xr-xlib/Vyatta/Config.pm26
-rwxr-xr-xlib/Vyatta/ConfigLoad.pm9
-rwxr-xr-xlib/Vyatta/ConfigOutput.pm8
-rwxr-xr-xscripts/vyatta-cfg-cmd-wrapper8
-rwxr-xr-xscripts/vyatta-config-loader.pl11
-rw-r--r--src/commit2.c22
6 files changed, 63 insertions, 21 deletions
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;
diff --git a/scripts/vyatta-cfg-cmd-wrapper b/scripts/vyatta-cfg-cmd-wrapper
index 93acd4f..3b2f040 100755
--- a/scripts/vyatta-cfg-cmd-wrapper
+++ b/scripts/vyatta-cfg-cmd-wrapper
@@ -212,6 +212,14 @@ case "$1" in
/opt/vyatta/sbin/my_delete "${@:2}"
RET_STATUS=$?
;;
+ deactivate)
+ /opt/vyatta/sbin/vyatta-activate-config.pl deactivate "${@:2}"
+ RET_STATUS=$?
+ ;;
+ activate)
+ /opt/vyatta/sbin/vyatta-activate-config.pl activate "${@:2}"
+ RET_STATUS=$?
+ ;;
commit)
# debug file /tmp/bar should be deleted before release
/opt/vyatta/sbin/my_commit -a >> /tmp/bar
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl
index 61eafa5..7a3df2b 100755
--- a/scripts/vyatta-config-loader.pl
+++ b/scripts/vyatta-config-loader.pl
@@ -70,7 +70,16 @@ my $ret = 0;
my $rank; #not used
foreach (@all_nodes) {
my ($path_ref, $rank) = @$_;
- my $cmd = "$CWRAPPER set " . (join ' ', @$path_ref);
+
+ my @pr = @$path_ref;
+ if (@pr[0] eq '!') {
+ @pr = @pr[1..$#pr];
+ my $deactivate_cmd = "$CWRAPPER deactivate " . (join ' ', @pr) . " 1>/dev/null";
+ system("$deactivate_cmd");
+ #ignore these errors due to nesting warnings.
+ }
+
+ my $cmd = "$CWRAPPER set " . (join ' ', @pr);
# this debug file should be deleted before release
system("echo [$cmd] >> /tmp/foo");
$ret = system("$cmd");
diff --git a/src/commit2.c b/src/commit2.c
index af01598..97c3b26 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -704,11 +704,27 @@ sort_func(GNode *node, gpointer data, boolean priority_mode)
}
}
+ //FIRST LET'S COMPUTE THE DEACTIVATE->ACTIVATE OVERRIDE
+ struct Data *d = &((struct VyattaNode*)gp)->_data;
+ NODE_OPERATION op = d->_operation;
+ if (d->_disable_op != K_NO_DISABLE_OP) {
+ if (!(d->_disable_op & K_LOCAL_DISABLE_OP) && (d->_disable_op & K_ACTIVE_DISABLE_OP)) {
+ //node will be activated on commit
+ //LET'S SPOOF the operation... convert it to CREATE
+ op = K_CREATE_OP;
+ }
+ else if ((d->_disable_op & K_LOCAL_DISABLE_OP) && !(d->_disable_op & K_ACTIVE_DISABLE_OP)) {
+ //node will be deactivated on commit
+ //LET'S SPOOF the operation... convert it to DELETE
+ op = K_DEL_OP;
+ }
+ }
+
//change action state of node according to enclosing behavior
if ((G_NODE_IS_ROOT(node) == FALSE) &&
(((struct VyattaNode*)gp)->_data._disable_op != K_NO_DISABLE_OP) || //added to support enclosing behavior of activated/deactivated nodes
- ((IS_SET_OR_CREATE(((struct VyattaNode*)gp)->_data._operation)) ||
- (IS_DELETE(((struct VyattaNode*)gp)->_data._operation))) &&
+ ((IS_SET_OR_CREATE(op)) ||
+ (IS_DELETE(op))) &&
(IS_NOOP(((struct VyattaNode*)(node->parent->data))->_data._operation))) {
//first check if there is enclosing behavior
@@ -734,7 +750,7 @@ sort_func(GNode *node, gpointer data, boolean priority_mode)
vtw_def def = ((struct VyattaNode*)(n->data))->_config._def;
((struct VyattaNode*)(n->data))->_data._operation = ((struct VyattaNode*)gp)->_data._operation;
//DON'T set active when only in disable state...
- if (((struct VyattaNode*)gp)->_data._disable_op == K_NO_DISABLE_OP) {
+ if (((struct VyattaNode*)(n->data))->_data._disable_op == K_NO_DISABLE_OP) {
((struct VyattaNode*)(n->data))->_data._operation |= K_ACTIVE_OP;
}
if (def.actions[end_act].vtw_list_head || def.actions[begin_act].vtw_list_head) {