lib/Rex/Commands/JobControl.pm

filter: Statementstmt 52.5% 21 / 40 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 2 totaltotal 45.0% 27 / 60 CC 5 SCAR 13.5
CC
5
Cov
44%
jobcontrol_add_server
6.0
__ANON__
6.0
jobcontrol_next_server
6.0
CRAP 3.9
« blib/lib/Rex/TaskList/Parallel_ForkManager.pm ↑ Summary lib/Rex/Test/Base/has_cron.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Commands::JobControl;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Commands;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 require Exporter;
16 1 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use vars qw(@EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 @EXPORT = qw(jobcontrol_add_server jobcontrol_next_server);
20  
21 0 ▶sub jobcontrol_add_server {
Subroutine jobcontrol_add_server: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my (%option) = @_;
23 0 ▶ if ( !exists( $ENV{JOBCONTROL_PROJECT_PATH} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ENV{"JOBCONTROL_PROJECT_PATH"}) 0 0 0
24 0 Rex::Logger::debug(
25 "Can only run on the same host where Rex::JobControl is running.");
26 0 return;
27 }
28  
29 0 ▶ LOCAL {
Subroutine __ANON__: not called CC=2 SCAR=17.9
30 my $ref =
31 0 YAML::LoadFile( $ENV{JOBCONTROL_PROJECT_PATH} . "/project.conf.yml" );
32 0 ▶ if ( !exists $ref->{nodes} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ref->{"nodes"}) 0 0 0
33 0 $ref->{nodes} = [];
34 }
35  
36 0 push @{ $ref->{nodes} }, {%option};
37  
38 0 YAML::DumpFile( $ENV{JOBCONTROL_PROJECT_PATH} . "/project.conf.yml", $ref );
39 0 };
40 }
41  
42 0 ▶sub jobcontrol_next_server {
Subroutine jobcontrol_next_server: not called CC=2 SCAR=17.9
Pod undocumented
43 0 my ($server) = @_;
44  
45 0 ▶ if ( !exists( $ENV{JOBCONTROL_PROJECT_PATH} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $ENV{"JOBCONTROL_PROJECT_PATH"}) 0 0 0
46 0 Rex::Logger::debug(
47 "Can only run on the same host where Rex::JobControl is running.");
48 0 return;
49 }
50  
51 0 ▶ LOCAL {
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 ▶ open( my $fh, ">", $ENV{JOBCONTROL_PROJECT_PATH} . "/next_server.txt" )
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $ENV{"JOBCONTROL_PROJECT_PATH"} . '/next_server.txt' or die "Can't write nextserver: $!" 0 0 0
53 or die("Can't write nextserver: $!");
54 0 print $fh $server;
55 0 close($fh);
56 0 };
57 }
58  
59 1 1;
« blib/lib/Rex/TaskList/Parallel_ForkManager.pm ↑ Summary lib/Rex/Test/Base/has_cron.pm »