1# 2# (c) Jan Gehring <jan.gehring@gmail.com> 3# 4# vim: set ts=2 sw=2 tw=0: 5# vim: set expandtab: 6 7package Rex::Batch; 8 9use 5.010001; 10use strict; 11use warnings; 12 13our $VERSION = '1.13.4'; # VERSION 14 15use Rex::Logger; 16use Rex::TaskList; 17 18use vars qw(%batchs); 19 20sub create_batch { 21 my $class = shift; 22 my $batch_name = shift; 23 my $batch_desc = pop; 24 my @task_names = @_; 25 my $task_list = Rex::TaskList->create; 26 27 for my $task_name (@task_names) { 28 die "ERROR: no task: $task_name" 29 unless $task_list->is_task($task_name); 30 } 31 32 $batchs{$batch_name} = { 33 desc => $batch_desc, 34 task_names => \@task_names 35 }; 36} 37 38sub get_batch { 39 my $class = shift; 40 my $batch_name = shift; 41 42 return @{ $batchs{$batch_name}->{'task_names'} }; 43} 44 45sub get_desc { 46 my $class = shift; 47 my $batch_name = shift; 48 49 return $batchs{$batch_name}->{'desc'}; 50} 51 52sub get_batchs { 53 my $class = shift; 54 my @a = sort { $a cmp $b } keys %batchs; 55} 56 57sub is_batch { 58 my $class = shift; 59 my $batch_name = shift; 60 61 if ( defined $batchs{$batch_name} ) { return 1; } 62 return 0; 63} 64 651; 66