summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/VyattaConfig.pm4
-rwxr-xr-xscripts/VyattaConfigLoad.pm19
-rwxr-xr-xscripts/VyattaConfigOutput.pm6
-rwxr-xr-xscripts/vyatta-load-config.pl34
4 files changed, 46 insertions, 17 deletions
diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm
index 3c4b51f..1c0eaf3 100755
--- a/scripts/VyattaConfig.pm
+++ b/scripts/VyattaConfig.pm
@@ -130,7 +130,9 @@ sub listOrigNodes {
$tmp =~ s/\n//g;
$tmp =~ s/%2F/\//g;
#print "DEBUG VyattaConfig->listNodes(): node = $tmp\n";
- push @nodes_modified, $tmp;
+ if ($tmp ne 'def') {
+ push @nodes_modified, $tmp;
+ }
}
return @nodes_modified;
diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm
index f1339c3..c8563bb 100755
--- a/scripts/VyattaConfigLoad.pm
+++ b/scripts/VyattaConfigLoad.pm
@@ -56,7 +56,8 @@ my %regex_rank = (
'interfaces ethernet \S* vrrp' => 500,
'interfaces ethernet \S* vif \S* vrrp' => 500,
'protocols bgp \d+ parameters' => 810,
- 'protocols bgp \d+ neighbor \S*[^\d.]\S*' => 800,
+ 'protocols bgp \d+ neighbor \d+\.\d+\.\d+\.\d+' => 800,
+ 'protocols bgp \d+ neighbor \w+' => 801,
);
my @all_nodes = ();
@@ -296,9 +297,6 @@ sub findDeletedNodes {
$active_cfg->setLevel(join ' ', @active_path);
my @active_nodes = $active_cfg->listOrigNodes();
foreach (@active_nodes) {
- if ($_ eq 'def') {
- next;
- }
if ($_ eq 'node.val') {
findDeletedValues($new_ref, \@active_path);
next;
@@ -396,8 +394,19 @@ sub getConfigDiff {
# everything together anyway.
@delete_list = sort { ${$a}[1] <=> ${$b}[1] } @delete_list;
@set_list = sort { ${$b}[1] <=> ${$a}[1] } @set_list;
+
+ # need to filter out deletions of nodes with default values
+ my @new_delete_list = ();
+ foreach my $del (@delete_list) {
+ my @comps = map { s/^'(.*)'$/$1/; $_; } @{${$del}[0]};
+ my ($is_multi, $is_text, $default) = $active_cfg->parseTmpl(\@comps);
+ if (!defined($default)) {
+ push @new_delete_list, $del;
+ }
+ }
+
my %diff = (
- 'delete' => \@delete_list,
+ 'delete' => \@new_delete_list,
'set' => \@set_list,
);
return %diff;
diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm
index 5358c21..ab7068f 100755
--- a/scripts/VyattaConfigOutput.pm
+++ b/scripts/VyattaConfigOutput.pm
@@ -138,7 +138,7 @@ sub displayValues {
my @cnames = sort keys %cnodes;
if (defined($simple_show)) {
- if (!$cnodes{'def'} || $show_all) {
+ if ($show_all) {
if ($is_password && $hide_password) {
$oval = $HIDE_PASSWORD;
}
@@ -159,7 +159,7 @@ sub displayValues {
$diff = '>';
}
}
- if (!$cnodes{'def'} || $show_all) {
+ if ($show_all) {
if ($is_password && $hide_password) {
$value = $HIDE_PASSWORD;
}
@@ -194,8 +194,6 @@ sub displayDeletedOrigChildren {
if ($cnames[0] eq 'node.val') {
displayValues([ @cur_path, $child ], $prefix, $child,
$dont_show_as_deleted);
- } elsif ($cnames[0] eq 'def') {
- #ignore
} elsif (scalar($#cnames) >= 0) {
if ($is_tag) {
@cnames = sort versioncmp @cnames;
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index 29d4dec..ee4a9c4 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -23,6 +23,9 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
+use POSIX;
+use IO::Prompt;
+use Sys::Syslog qw(:standard :macros);
use VyattaConfigLoad;
my $etcdir = $ENV{vyatta_sysconfdir};
@@ -42,6 +45,7 @@ my $proto;
if (defined($ARGV[0])) {
$load_file = $ARGV[0];
}
+my $orig_load_file = $load_file;
if ($load_file =~ /^[^\/]\w+:\//) {
if ($load_file =~ /^(\w+):\/\/\w/) {
@@ -107,20 +111,36 @@ if ($mode eq 'local') {
}
$load_file = $url_tmp_file;
}
+
+my $xorp_cfg = 0;
+my $valid_cfg = 0;
while (<CFG>) {
if (/\/\*XORP Configuration File, v1.0\*\//) {
- print "Warning: Loading a pre-Glendale configuration.\n";
- print "Do you want to continue? [no] ";
- my $resp = <STDIN>;
- if (!($resp =~ /^yes$/i)) {
- print "Configuration not loaded\n";
- exit 1;
- }
+ $xorp_cfg = 1;
+ last;
+ } elsif (/vyatta-config-version/) {
+ $valid_cfg = 1;
last;
}
}
+if ($xorp_cfg or ! $valid_cfg) {
+ if ($xorp_cfg) {
+ print "Warning: Loading a pre-Glendale configuration.\n";
+ } else {
+ print "Warning: file does NOT appear to be a valid config file.\n";
+ }
+ if (!prompt("Do you want to continue? ", -tty, -Yes, -default=>'no')) {
+ print "Configuration not loaded\n";
+ exit 1;
+ }
+}
close CFG;
+# log it
+openlog($0, "", LOG_USER);
+my $login = getlogin() || getpwuid($<) || "unknown";
+syslog("warning", "Load config [$orig_load_file] by $login");
+
# do config migration
system("$sbindir/vyatta_config_migrate.pl $load_file");