/usr/lib/oar/oarresume is in oar-user 2.5.2-4.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/usr/bin/perl
# $Id$
# resume a job --> it will be rescheduled
use strict;
use warnings;
use Data::Dumper;
use DBI();
use OAR::IO;
use OAR::Conf qw(init_conf dump_conf get_conf is_conf);
use OAR::Tools;
use OAR::Version;
use Getopt::Long;
my $Old_umask = sprintf("%lo",umask());
umask(oct("022"));
sub usage {
print <<EOS;
Usage: $0 [--array][job_ids][--sql "sql syntax"][-V][-h]
Ask OAR to change job_ids states into Waiting when it is Hold or in Running
if it is Suspended.
--array resume array job(s) passed as parameter (all the sub-jobs)
--sql resume jobs which respond to the SQL where clause on the table
jobs (ex: "project = 'p1'")
-h, --help show this help screen
-V, --version print OAR version number
EOS
}
my $Version;
my $Help;
my $Sql_property;
my $array;
GetOptions (
"version|V" => \$Version,
"sql=s" => \$Sql_property,
"array" => \$array,
"help|h" => \$Help
);
if (defined($Help)){
usage();
exit(0);
}
if (defined($Version)){
print("OAR version : ".OAR::Version::get_version()."\n");
exit(0);
}
if (($#ARGV < 0) and (!defined($Sql_property))){
usage();
exit(1);
}
init_conf($ENV{OARCONFFILE});
my $remote_host = get_conf("SERVER_HOSTNAME");
my $remote_port = get_conf("SERVER_PORT");
my @job_ids;
my $exit_code = 0;
foreach my $j (@ARGV){
if ($j =~ m/^\d+$/m){
#if defined --array, delete all the sub-jobs
if(defined($array)){
my $db = OAR::IO::connect_ro();
my @tmp_jobs = OAR::IO::get_array_job_ids($db,$j);
if(scalar @tmp_jobs == 0){
warn("[ERROR] \"$j\" is not a valid array job\n");
$exit_code = 2;
}else{
foreach my $j (@tmp_jobs){
push(@job_ids, $j);
}
}
OAR::IO::disconnect($db);
}else{
push(@job_ids, $j);
}
}else{
if(defined($array)){
warn("[ERROR] \"$j\" is not a valid job array identifier\n");
}else{
warn("[ERROR] \"$j\" is not a valid job identifier\n");
}
$exit_code = 2;
}
}
if (defined($Sql_property)){
my $db = OAR::IO::connect_ro();
foreach my $j (OAR::IO::get_jobs_with_given_properties($db,$Sql_property)){
push(@job_ids, $j->{job_id});
}
OAR::IO::disconnect($db);
}
my $base = OAR::IO::connect();
foreach my $j (@job_ids){
my $err = OAR::IO::resume_job($base,$j);
if ($err != 0) {
my $str = "/!\\ Cannot resume $j :";
if ($err == -1){
warn("$str this job does not exist.\n");
}elsif ($err == -2){
warn("$str you are not the right user.\n");
}elsif ($err == -3){
warn("$str the job is not in the Hold or Suspended state.\n");
}elsif ($err == -4){
warn("$str only oar or root user can resume Suspended jobs.\n");
}else{
warn("$str unknown reason.\n");
}
$exit_code = 1;
}else{
print("[$j] Resume request was sent to the OAR server.\n");
}
}
OAR::IO::disconnect($base);
#Signal Almigthy
OAR::Tools::notify_tcp_socket($remote_host,$remote_port,"ChState");
exit($exit_code);
|