File Coverage

lib/Rex/Commands/JobControl.pm
Criterion Covered Total %
statement 17 36 47.2
branch 0 8 0.0
condition n/a
subroutine 6 10 60.0
pod 0 2 0.0
total 23 56 41.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Commands::JobControl;
6              
7 1     1   19 use v5.12.5;
  1         6  
8 1     1   6 use warnings;
  1         3  
  1         41  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12 1     1   6 use Rex::Commands;
  1         7  
  1         6  
13 1     1   8 use YAML;
  1         3  
  1         62  
14              
15             require Exporter;
16 1     1   5 use base qw(Exporter);
  1         8  
  1         81  
17 1     1   8 use vars qw(@EXPORT);
  1         2  
  1         367  
18              
19             @EXPORT = qw(jobcontrol_add_server jobcontrol_next_server);
20              
21             sub jobcontrol_add_server {
22 0     0 0   my (%option) = @_;
23 0 0         if ( !exists( $ENV{JOBCONTROL_PROJECT_PATH} ) ) {
24 0           Rex::Logger::debug(
25             "Can only run on the same host where Rex::JobControl is running.");
26 0           return;
27             }
28              
29             LOCAL {
30             my $ref =
31 0     0     YAML::LoadFile( $ENV{JOBCONTROL_PROJECT_PATH} . "/project.conf.yml" );
32 0 0         if ( !exists $ref->{nodes} ) {
33 0           $ref->{nodes} = [];
34             }
35              
36 0           push @{ $ref->{nodes} }, {%option};
  0            
37              
38 0           YAML::DumpFile( $ENV{JOBCONTROL_PROJECT_PATH} . "/project.conf.yml", $ref );
39 0           };
40             }
41              
42             sub jobcontrol_next_server {
43 0     0 0   my ($server) = @_;
44              
45 0 0         if ( !exists( $ENV{JOBCONTROL_PROJECT_PATH} ) ) {
46 0           Rex::Logger::debug(
47             "Can only run on the same host where Rex::JobControl is running.");
48 0           return;
49             }
50              
51             LOCAL {
52 0 0   0     open( my $fh, ">", $ENV{JOBCONTROL_PROJECT_PATH} . "/next_server.txt" )
53             or die("Can't write nextserver: $!");
54 0           print $fh $server;
55 0           close($fh);
56 0           };
57             }
58              
59             1;