line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# vim: set ts=3 sw=3 tw=0: |
5
|
|
|
|
|
|
|
# vim: set expandtab: |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rex::JobControl::Mojolicious::Plugin::MinionJobs; |
8
|
|
|
|
|
|
|
$Rex::JobControl::Mojolicious::Plugin::MinionJobs::VERSION = '0.7.0'; |
9
|
1
|
|
|
1
|
|
1627
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Mojolicious::Plugin; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
13
|
1
|
|
|
1
|
|
22
|
use Rex::JobControl::Helper::Project; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
496
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub register { |
18
|
1
|
|
|
1
|
1
|
48
|
my ( $plugin, $app ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$app->minion->add_task( |
21
|
|
|
|
|
|
|
execute_rexfile => sub { |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
|
0
|
my ( $job, $project_dir, $job_dir, $current_user, $cmdb, @server ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$job->app->log->debug("Project: $project_dir"); |
26
|
0
|
|
|
|
|
0
|
$job->app->log->debug("Job: $job_dir"); |
27
|
0
|
|
|
|
|
0
|
$job->app->log->debug("User: $current_user"); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
eval { |
30
|
0
|
|
|
|
|
0
|
my $pr = $job->app->project($project_dir); |
31
|
0
|
|
|
|
|
0
|
my $job = $pr->get_job($job_dir); |
32
|
0
|
|
|
|
|
0
|
$job->execute( $current_user, $cmdb, @server ); |
33
|
0
|
|
|
|
|
0
|
1; |
34
|
0
|
0
|
|
|
|
0
|
} or do { |
35
|
0
|
|
|
|
|
0
|
$job->app->log->debug("Error executing: $@"); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
|
|
16
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$app->minion->add_task( |
42
|
|
|
|
|
|
|
checkout_rexfile => sub { |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
|
|
my ( $job, $project_dir, $rexfile_name, $rexfile_url, |
45
|
|
|
|
|
|
|
$rexfile_description ) |
46
|
|
|
|
|
|
|
= @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$job->app->log->debug("checkout_rexfile: got params: " . join(", ", @_)); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
eval { |
51
|
0
|
|
|
|
|
|
my $pr = $job->app->project($project_dir); |
52
|
0
|
|
|
|
|
|
$pr->create_rexfile( |
53
|
|
|
|
|
|
|
directory => $rexfile_name, |
54
|
|
|
|
|
|
|
url => $rexfile_url, |
55
|
|
|
|
|
|
|
description => $rexfile_description, |
56
|
|
|
|
|
|
|
); |
57
|
0
|
|
|
|
|
|
1; |
58
|
0
|
0
|
|
|
|
|
} or do { |
59
|
0
|
|
|
|
|
|
$job->app->log->debug("Error checkout_rexfile: $@"); |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
302
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |