summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-11-09 17:05:19 -0800
committerStig Thormodsrud <stig@vyatta.com>2010-11-09 17:05:19 -0800
commitae39faa486737dd4459eb8d66ff5fa1dc1be5166 (patch)
tree97cca32f378b591d080cf331fdf203232bdb3647 /lib
parent02791991cab3889b6a002907fa4f113a470b7838 (diff)
downloadvyatta-config-mgmt-ae39faa486737dd4459eb8d66ff5fa1dc1be5166.tar.gz
vyatta-config-mgmt-ae39faa486737dd4459eb8d66ff5fa1dc1be5166.zip
Add first pass commit-confirm and rollback (requires reboot for now).
Diffstat (limited to 'lib')
-rw-r--r--lib/Vyatta/ConfigMgmt.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Vyatta/ConfigMgmt.pm b/lib/Vyatta/ConfigMgmt.pm
index 60fce44..9a49aac 100644
--- a/lib/Vyatta/ConfigMgmt.pm
+++ b/lib/Vyatta/ConfigMgmt.pm
@@ -31,7 +31,9 @@ our @EXPORT = qw(cm_commit_add_log cm_commit_get_log cm_get_archive_dir
cm_get_commit_hook_dir cm_write_file cm_read_file
cm_commit_get_file cm_commit_get_file_name
cm_get_max_revs cm_get_num_revs cm_get_last_commit_file
- cm_get_last_push_file);
+ cm_get_last_push_file cm_get_boot_config_file
+ cm_get_config_rb
+ );
use base qw(Exporter);
use Vyatta::Config;
@@ -50,7 +52,15 @@ my $lr_state_file = "$archive_dir/lr.state";
my $commit_log_file = "$archive_dir/commits";
my $last_commit_file = "$archive_dir/config.boot";
my $last_push_file = "$archive_dir/config.boot-push";
+my $config_file_rb = "$archive_dir/config.boot-rollback";
+sub cm_get_boot_config_file {
+ return $config_file;
+}
+
+sub cm_get_config_rb {
+ return $config_file_rb;
+}
sub cm_get_commit_hook_dir {
return $commit_hook_dir;
@@ -117,9 +127,7 @@ sub cm_commit_add_log {
my $time = time();
if ($comment =~ /\|/) {
- print "before [$comment]\n";
$comment =~ s/\|/\%\%/g;
- print "after [$comment]\n";
}
my $new_line = "|$time|$user|$via|$comment|";
my @lines = cm_read_file($commit_log_file);
@@ -170,7 +178,7 @@ sub cm_commit_get_file {
my ($revnum) = @_;
my $max_revs = cm_get_max_revs();
- if ($revnum > $max_revs) {
+ if (defined $max_revs and $revnum > $max_revs) {
print "Error: Invalid config revision number\n";
exit 1;
}