Changeset 37265
- Timestamp:
- Aug 19, 2014, 8:00:38 AM (12 years ago)
- Location:
- tags/ipp-pv3-20140717/ippScripts
- Files:
-
- 2 edited
-
Build.PL (modified) (1 diff)
-
scripts/sc_retry_return.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/ippScripts/Build.PL
r37124 r37265 142 142 scripts/sc_prepare_warp.pl 143 143 scripts/sc_remote_exec.pl 144 scripts/sc_retry_return.pl 144 145 scripts/sc_transfer_tool.pl 145 146 )], -
tags/ipp-pv3-20140717/ippScripts/scripts/sc_retry_return.pl
r37264 r37265 25 25 my $scp = can_run('scp') or (warn "Can't find scp" and $missing_tools = 1); 26 26 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1); 27 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1); 27 28 28 29 if ($missing_tools) { … … 32 33 33 34 # Options 34 my ($remote_id,$path_base,$ policy,$poll,$force,$job_id,$dbname,$verbose,$no_update,$camera);35 my ($remote_id,$path_base,$job_id,$dbname,$verbose,$no_update,$camera); 35 36 $force = 0; 36 37 $verbose = 0; … … 39 40 'job_id=s' => \$job_id, 40 41 'path_base=s' => \$path_base, 41 'policy=s' => \$policy,42 'poll' => \$poll,43 'force-poll' => \$force,44 42 'camera=s' => \$camera, 45 43 'dbname=s' => \$dbname, … … 80 78 my $rrData2 = parse_md_list($rrData); 81 79 my $runData = ${ $rrData2 }[0]; # There should be only one 82 83 # keep this for reference for the moment, but this block should not be in this function84 if (0) {85 # Phase 2: Ensure files are in place:86 # Copy command files87 my @files = ();88 89 my $uri_command = $path_base . ".cmd";90 my $uri_transfer= $path_base . ".transfer";91 my $uri_check = $path_base . ".check";92 my $uri_config = $path_base . ".config";93 my $uri_generate= $path_base . ".generate";94 my $uri_return = $path_base . ".return";95 96 my $disk_command = $ipprc->file_resolve($uri_command);97 my $disk_transfer= $ipprc->file_resolve($uri_transfer);98 my $disk_check = $ipprc->file_resolve($uri_check);99 my $disk_config = $ipprc->file_resolve($uri_config);100 my $disk_generate= $ipprc->file_resolve($uri_generate);101 my $disk_return = $ipprc->file_resolve($uri_return);102 103 scp_put($disk_command,uri_local_to_remote($uri_command));104 scp_put($disk_transfer,uri_local_to_remote($uri_transfer));105 scp_put($disk_check,uri_local_to_remote($uri_check));106 scp_put($disk_config,uri_local_to_remote($uri_config));107 scp_put($disk_generate,uri_local_to_remote($uri_generate));108 scp_put($disk_return, uri_local_to_remote($uri_return));109 110 # Run check command111 my (undef,$remote_check) = uri_convert($uri_check);112 my (undef,$remote_transfer)= uri_convert($uri_transfer);113 114 my $ssh_check_stdout = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_check --fetch $remote_transfer");115 # We no longer need to parse this output, as it retrieves files itself.116 foreach my $l (split /\n/, (join '', @$ssh_check_stdout)) {117 print "$l\n";118 }119 120 # Run real command121 my (undef,$remote_command) = uri_convert($uri_command);122 my $ssh_exec_stdout = ssh_exec_command("msub -V $remote_command");123 if ($#{ $ssh_exec_stdout } != -1) { # Parse the output124 $job_id = ${ $ssh_exec_stdout }[0];125 chomp($job_id);126 $job_id =~ s/\s+//g;127 }128 129 unless(defined($job_id)) { # If we don't have a job_id from this command, it didn't run correctly.130 &my_die("No job_id returned. Sorry.",$remote_id,$PS_EXIT_PROG_ERROR);131 }132 133 # Notify the database that this entry is currently running.134 my $command = "$remotetool -updaterun -remote_id $remote_id ";135 $command .= " -set_state run ";136 $command .= " -job_id $job_id ";137 $command .= " -dbname $dbname " if defined $dbname;138 139 print STDERR "$command\n";140 system($command);141 142 } # End of exec phase143 80 144 81 # Poll the job status? … … 203 140 print "$return_push_output_print\n"; 204 141 } while (($transfer_success != 1) && ($iter < 10)); # Try harder; 142 143 if (!$transfer_success) &my_die ("failed to get all return files"); 205 144 } 206 145 207 146 foreach my $file (@dbinfo_files) { 208 # use the filename to get the stage id, check if we have already updated this entry: 209 210 147 148 # use the dbinfo filename to get stage id, check if we have already updated this entry: 149 my ($stage_id, $class_id) = get_stage_id_from_dbinfo ($file); 150 151 # chiptool -dbname -chip_id $stage_id -class_id $class_id 152 153 # we just need to check for the existence of an entry: 154 if ($runData->{stage} == "chip") { 155 my $cmd = "$chiptool -simple -processedimfile -chip_id $stage_id -class_id $class_id"; 156 $cmd .= " -dbname $dbname " if defined($dbname); 157 158 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $cmd, verbose => $verbose); 160 161 unless ($success) { 162 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 163 &my_die("Unable to run chiptool to check on results", $remote_id,$error_code); 164 } 165 166 my $Nrows = @$stdout_buff; 167 if ($Nrows > 0) { 168 print STDERR "skip this entry: $stage_id, $class_id\n"; 169 next; 170 } 171 } 211 172 212 173 open(DBF,"$file") || warn "Missing file $file\n"; 213 174 my $cmd = <DBF>; 214 175 close(DBF); 176 215 177 chomp($cmd); 216 # print STDERR "$file $cmd\n"; 178 217 179 $cmd =~ s/-/ -/g; # This is just a safety check for missing space. 180 if ($cmd == "") { 181 print STDERR "empty dbinfo file for $stage_id, $class_id, skipping\n"; 182 next; 183 } 184 218 185 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 219 186 run(command => $cmd, verbose => $verbose); 220 187 unless ($success) { 221 222 188 # This shouldn't fail, but we also can't suddenly abort if something does fail. 223 189 # Now we're going to drop the component that owns this dbinfo, which should force a retry. … … 228 194 } 229 195 } 230 231 196 } 232 197 … … 234 199 &my_die("Finished",$remote_id,0,"full"); 235 200 236 237 201 # END PROGRAM 238 202 239 203 # yes 240 204 sub check_ssh_connection { 241 205 my $cmd = "$ssh -O check $DMZ_HOST"; … … 245 209 unless ($success) { 246 210 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 247 &my_die("Authorization check failed.",$remote_id,0,'auth'); 248 } 249 } 250 251 sub scp_put { 252 my $file = shift; 253 my $destination = shift; 254 my $cmd = "$scp $file ${DMZ_HOST}:${SEC_HOST}:${destination}"; 255 256 my $directory = dirname($destination); 257 ssh_exec_command("mkdir -p $directory"); 258 259 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 260 run(command => $cmd, verbose => $verbose); 261 unless ($success) { 262 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 263 &my_die(); 264 } 265 } 266 267 sub scp_get { 268 my $destination = shift; 269 my $file = shift; 270 271 my $cmd = "$scp ${DMZ_HOST}:${SEC_HOST}:${destination} $file "; 272 273 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 274 run(command => $cmd, verbose => $verbose); 275 unless ($success) { 276 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 277 &my_die(); 211 &my_die("Authorization check failed", $remote_id, 0, 'auth'); 278 212 } 279 213 } … … 294 228 } 295 229 230 sub uri_convert { 231 my $neb_uri = shift; 232 my $ipp_disk= $ipprc->file_resolve( $neb_uri ); 233 my $remote_disk = $ipp_disk; 234 235 unless(defined($ipp_disk)) { 236 my_die(); 237 } 238 239 $remote_disk =~ s%^.*/%%; # Remove nebulous path 240 $remote_disk =~ s%^\d+\.%%; # Remove ins_id 241 $remote_disk =~ s%:%/%g; # Replace colons with directories 242 $remote_disk = "${remote_root}/${remote_disk}"; 243 return($ipp_disk, $remote_disk); 244 } 245 296 246 sub poll_job { 297 247 my $job_id = shift; 298 248 my $response_array = ssh_exec_command("checkjob -v $job_id"); 299 249 my $response = join "\n", @$response_array; 300 301 if ($response =~ /State: Running/) { 302 return(0,"Running");250 251 if ($response =~ /State: Running/) { 252 return(0,"Running"); 303 253 } 304 254 elsif ($response =~ /State: Completed/) { 305 return(1,"Completed");255 return(1,"Completed"); 306 256 } 307 257 elsif ($response =~ /State: Idle/) { 308 return(-2,"Idle");258 return(-2,"Idle"); 309 259 } 310 260 else { 311 my $response_word = $response; 312 $response_word =~ s/.*State: //; 313 $response_word =~ s/\n.*//; 314 return(-1,$response_word); 315 } 316 } 317 318 319 sub uri_convert { 320 my $neb_uri = shift; 321 my $ipp_disk= $ipprc->file_resolve( $neb_uri ); 322 my $remote_disk = $ipp_disk; 323 324 unless(defined($ipp_disk)) { 325 my_die(); 326 } 327 328 $remote_disk =~ s%^.*/%%; # Remove nebulous path 329 $remote_disk =~ s%^\d+\.%%; # Remove ins_id 330 $remote_disk =~ s%:%/%g; # Replace colons with directories 331 $remote_disk = "${remote_root}/${remote_disk}"; 332 return($ipp_disk,$remote_disk); 333 } 334 335 sub uri_to_outputs { 336 my $neb_uri = shift; 337 my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri ); 338 339 # print TRANSFER "$ipp_disk\n"; 340 # print CHECK "$remote_disk\n"; 341 return($ipp_disk,$remote_disk); 342 } 343 344 sub uri_local_to_remote { 345 # This needs to replace the nebulous tag with the remote root. 346 my $local_uri = shift; 347 $local_uri =~ s%^.*?/%%; # neb:/ 348 $local_uri =~ s%^.*?/%%; # / 349 $local_uri =~ s%^.*?/%%; # @HOST@.0/ 350 my $remote_uri = "${remote_root}/" . $local_uri; 351 352 return($remote_uri); 353 } 354 355 sub uri_remote_to_local { 356 # This needs to replace the remote root directory with the nebulous tag. 357 my $remote_uri = shift; 358 $remote_uri =~ s%${remote_root}%%; 359 my $local_uri = "neb:///" . $remote_uri; 360 361 return($local_uri); 362 } 261 my $response_word = $response; 262 $response_word =~ s/.*State: //; 263 $response_word =~ s/\n.*//; 264 return(-1,$response_word); 265 } 266 } 267 363 268 364 269 # assumes $runData->{stage} exists 365 270 sub get_stage_id_from_dbinfo { 366 271 my $file = shift; 272 273 my $stage_id = 0; 274 my $class_id = 0; 367 275 368 276 # Steal the stage_id from the filename. This isn't something I'm happy about. … … 373 281 elsif ($stage eq 'camera') { 374 282 $stage_id =~ s/^.*cm\.//; 283 $class_id = 0; 375 284 } 376 285 elsif ($stage eq 'warp') { 377 286 $stage_id =~ s/^.*wrp\.//; 287 $class_id = 0; 378 288 } 379 289 elsif ($stage eq 'stack') { 380 290 $stage_id =~ s/^.*stk\.//; 291 $class_id = 0; 381 292 } 382 293 … … 439 350 exit($exit_code); 440 351 } 441 442 # Quick review:443 # new -> pending -> run -> full444 # auth
Note:
See TracChangeset
for help on using the changeset viewer.
