????
| Current Path : /usr/lib/raider/Raider/ |
| Current File : //usr/lib/raider/Raider/Jobs.pm |
use strict;
use warnings;
package Raider::Jobs;
use base qw( Raider::Base );
use Raider::Jobs::3ware;
use Raider::Jobs::Adaptec;
use Raider::Jobs::MegaraidSAS;
use Raider::Jobs::FusionMPTSAS2;
use Raider::Jobs::MegaraidSATA;
use Raider::Jobs::Mdraid;
use Raider::Jobs::StorCli;
=head1 NAME
Raider::Jobs - Base class for job related tasks.
=head1 DESCRIPTION
Base class for all jobs tasks.
=head1 USAGE
use Raider::Jobs;
my $jobsObj = Raider::Jobs->new();
=head1 METHODS
=head2 get_job_list()
Return a list of jobs.
=head2 icmd_in_path(\%args)
Ensure required icmd is in path.
=head2 run_jobs()
Delegates the first steps in --run-jobs command line argument.
=head2 device_job_is_monitorable()
Given a list of jobs and a job, returns 1/0 based on if the
job is monitorable.
=cut
sub get_job_list {
my $self = shift;
my $jobs_ref = $self->sysFindFile({ search_path => "$Raider::Base::base_conf{'jobs_path'}" });
$Raider::Base::base_conf{'MegaraidSAS_Present'} = 1 if ( grep{$_ =~ /MegaraidSAS/i} @{$jobs_ref} );
my @jobs_filtered = ();
# Ensure satascsiata is always last.
for my $job ( @{ $jobs_ref }) {
if ( $job !~ /satascsiata/i ) {
push(@jobs_filtered,$job);
}
}
push(@jobs_filtered, 'satascsiata');
return \@jobs_filtered;
}
sub icmd_in_path {
my $self = shift;
my $opts = shift;
my $icmd_ref = [ "$opts->{icmd}" ];
my $path_check = $self->in_path({ cmds => $icmd_ref, mode => 'nofatal' });
if ( $path_check ne 'present' ) {
$self->logger({ cat => 'c', msg => "Required vendor tool ($opts->{icmd}) cannot be found!" });
}
}
sub run_jobs {
my $self = shift;
my $jobs = $self->get_job_list();
my $conf_file = $self->read_conf_file();
my $job_args;
if ($conf_file->{enable_bbu_checks}) {
$job_args->{bbu_check} = 1;
}
if ($conf_file->{cntlr_temp_checks}) {
$job_args->{cntlr_temp_checks} = 1;
}
for my $job (@$jobs) {
next unless $self->device_job_is_monitorable($jobs, $job);
$self->logger({ cat => 'i', msg => "Running job for device $job" });
my $jobObj = "Raider::Jobs::$job"->new();
# check raid health
$jobObj->run_job($job_args);
};
}
sub device_job_is_monitorable {
my ($self, $jobs, $job) = @_;
return 0 if ($job eq 'satascsiata');
if (grep {$_ eq $job} @$jobs) {
return 1;
}
return 0;
}
1;