#368 ND2_DB_ROLLBACK environment variable to roll back job updates to DB [skip ci]
This commit is contained in:
1
Changes
1
Changes
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
* #228 timeout setting (default 10min) for backend jobs
|
* #228 timeout setting (default 10min) for backend jobs
|
||||||
* #341 timeout setting for all actions ("<actionname>_timeout")
|
* #341 timeout setting for all actions ("<actionname>_timeout")
|
||||||
|
* #368 ND2_DB_ROLLBACK environment variable to roll back job updates to DB
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ use App::Netdisco::Util::Device 'get_device';
|
|||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
Getopt::Long::Configure ("bundling");
|
Getopt::Long::Configure ("bundling");
|
||||||
|
|
||||||
my ($device, $port, $extra, $debug);
|
my ($device, $port, $extra, $debug, $rollback);
|
||||||
my ($infotrace, $snmptrace, $sqltrace) = (0, 0, 0);
|
my ($infotrace, $snmptrace, $sqltrace) = (0, 0, 0);
|
||||||
|
|
||||||
my $result = GetOptions(
|
my $result = GetOptions(
|
||||||
@@ -58,6 +58,7 @@ my $result = GetOptions(
|
|||||||
'port|p=s' => \$port,
|
'port|p=s' => \$port,
|
||||||
'extra|e=s' => \$extra,
|
'extra|e=s' => \$extra,
|
||||||
'debug|D' => \$debug,
|
'debug|D' => \$debug,
|
||||||
|
'rollback|R' => \$rollback,
|
||||||
'infotrace|I+' => \$infotrace,
|
'infotrace|I+' => \$infotrace,
|
||||||
'snmptrace|S+' => \$snmptrace,
|
'snmptrace|S+' => \$snmptrace,
|
||||||
'sqltrace|Q+' => \$sqltrace,
|
'sqltrace|Q+' => \$sqltrace,
|
||||||
@@ -74,6 +75,7 @@ $CONFIG->{log} = ($debug ? 'debug' : 'info');
|
|||||||
$ENV{INFO_TRACE} ||= $infotrace;
|
$ENV{INFO_TRACE} ||= $infotrace;
|
||||||
$ENV{SNMP_TRACE} ||= $snmptrace;
|
$ENV{SNMP_TRACE} ||= $snmptrace;
|
||||||
$ENV{DBIC_TRACE} ||= $sqltrace;
|
$ENV{DBIC_TRACE} ||= $sqltrace;
|
||||||
|
$ENV{ND2_DB_ROLLBACK} ||= $rollback;
|
||||||
|
|
||||||
# reconfigure logging to force console output
|
# reconfigure logging to force console output
|
||||||
Dancer::Logger->init('console', $CONFIG);
|
Dancer::Logger->init('console', $CONFIG);
|
||||||
@@ -160,7 +162,7 @@ netdisco-do - Run any Netdisco job from the command-line.
|
|||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
~/bin/netdisco-do <action> [-DISQ] [-d <device> [-p <port>] [-e <extra>]]
|
~/bin/netdisco-do <action> [-DISQR] [-d <device> [-p <port>] [-e <extra>]]
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
@@ -346,7 +348,10 @@ Set the PoE on/off status on a device port. Requires the C<-d> parameter
|
|||||||
Will dump the loaded and parsed configuration for the application. Pass a
|
Will dump the loaded and parsed configuration for the application. Pass a
|
||||||
specific configuration setting name to the C<-e> parameter to dump only that.
|
specific configuration setting name to the C<-e> parameter to dump only that.
|
||||||
|
|
||||||
=head1 DEBUG LEVELS
|
=head1 DEBUG OPTIONS
|
||||||
|
|
||||||
|
The flag "C<-R>" will cause any changes to the database to be rolled back
|
||||||
|
at the end of the action.
|
||||||
|
|
||||||
The flags "C<-DISQ>" can be specified, multiple times, and enable the
|
The flags "C<-DISQ>" can be specified, multiple times, and enable the
|
||||||
following items in order:
|
following items in order:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package App::Netdisco::Worker::Runner;
|
package App::Netdisco::Worker::Runner;
|
||||||
|
|
||||||
use Dancer qw/:moose :syntax/;
|
use Dancer qw/:moose :syntax/;
|
||||||
|
use Dancer::Plugin::DBIC 'schema';
|
||||||
use App::Netdisco::Util::Device 'get_device';
|
use App::Netdisco::Util::Device 'get_device';
|
||||||
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
|
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
|
||||||
use aliased 'App::Netdisco::Worker::Status';
|
use aliased 'App::Netdisco::Worker::Status';
|
||||||
@@ -59,6 +60,9 @@ sub run {
|
|||||||
|
|
||||||
my $runner = sub {
|
my $runner = sub {
|
||||||
my ($self, $job) = @_;
|
my ($self, $job) = @_;
|
||||||
|
# roll everything back if we're testing
|
||||||
|
my $txn_guard = $ENV{ND2_DB_ROLLBACK}
|
||||||
|
? schema('netdisco')->storage->txn_scope_guard : undef;
|
||||||
|
|
||||||
# run check phase and if there are workers then one MUST be successful
|
# run check phase and if there are workers then one MUST be successful
|
||||||
$self->run_workers('workers_check');
|
$self->run_workers('workers_check');
|
||||||
|
|||||||
Reference in New Issue
Block a user