Changeset 38168 for trunk/ippScripts/scripts/sc_remote_poll.pl
- Timestamp:
- Apr 23, 2015, 3:12:58 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/sc_remote_poll.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/sc_remote_poll.pl
r38145 r38168 26 26 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 27 27 use Pod::Usage qw( pod2usage ); 28 29 # Hard coded values30 my $DMZ_HOST = 'wtrw';31 my @SEC_HOSTS= ('mu-fe1','mu-fe2','mu-fe3'32 # ,'mu-fe4'33 );34 my $SEC_HOST = $SEC_HOSTS[int(rand(@SEC_HOSTS))]; # 'mu-fe';35 my $IPP_PATH = '/turquoise/usr/projects/cosmo/mswarren/ipp/';36 my $remote_root = '/scratch3/watersc1/';37 28 38 29 # tools … … 44 35 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 45 36 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 37 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 46 38 47 39 if ($missing_tools) { … … 51 43 52 44 # Options 53 my ($remote_id,$path_base,$skip_poll,$skip_transfer,$job_id,$dbname,$retry,$verbose,$no_update,$camera );45 my ($remote_id,$path_base,$skip_poll,$skip_transfer,$job_id,$dbname,$retry,$verbose,$no_update,$camera,$cmd_recipe); 54 46 $verbose = 0; 55 47 GetOptions( … … 61 53 'camera=s' => \$camera, 62 54 'dbname=s' => \$dbname, 55 'recipe=s' => \$cmd_recipe, 63 56 'retry' => \$retry, 64 57 'verbose' => \$verbose, … … 67 60 68 61 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 69 pod2usage( -msg => "Required options: --remote_id --job_id --path_base ", -exitval => 3) unless62 pod2usage( -msg => "Required options: --remote_id --job_id --path_base --recipe", -exitval => 3) unless 70 63 defined($path_base) and 71 64 defined($remote_id) and 65 defined($cmd_recipe) and 72 66 defined($job_id); 67 68 69 70 # Now accessible from a recipe 71 my %remote_recipe = (); 72 { 73 my $verbose = 0; 74 my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -"; 75 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 76 run(command => $conf_cmd, verbose => $verbose); 77 unless ($success) { 78 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 79 &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR); 80 } 81 my $mdcParser = PS::IPP::Metadata::Config->new; 82 my $metadata = $mdcParser->parse(join "", @$stdout_buf); 83 84 my $active_recipe = ''; 85 my %recipes = (); 86 87 # print Dumper($metadata); 88 foreach my $entry (@{ $metadata }) { 89 if (${ $entry }{name} eq 'ACTIVE') { 90 $active_recipe = ${ $entry }{value}; # Not actually used 91 } 92 else { 93 if (${ $entry }{class} eq 'metadata') { # A real recipe 94 my $name = ${ $entry }{name}; 95 foreach my $tentry (@{ ${ $entry }{value} }) { 96 if (${ $tentry }{class} eq 'scalar') { # A recipe value 97 $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value}; 98 } 99 elsif (${ $tentry }{class} eq 'metadata') { # A recipe array 100 foreach my $arr_entry (@{ ${ $tentry }{value} }) { 101 push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value}; 102 } 103 } 104 } 105 } 106 } 107 } 108 109 unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) }; 110 # print Dumper(%recipes); 111 %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe. 112 # print Dumper(\%remote_recipe); 113 } 114 115 116 # Hard coded values 117 my $DMZ_HOST = $remote_recipe{DMZ_HOST}; 118 my @SEC_HOSTS= @{ $remote_recipe{SEC_HOST} }; 119 my $SEC_HOST; 120 if ($#SEC_HOSTS != -1) { 121 $SEC_HOST = $SEC_HOSTS[int(rand(@SEC_HOSTS))]; 122 } 123 else { 124 $SEC_HOST = ''; 125 } 126 my $IPP_PATH = $remote_recipe{IPP_PATH}; 127 my $remote_root = $remote_recipe{REMOTE_ROOT}; 128 73 129 74 130 my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id); … … 351 407 my $file = shift; 352 408 my $destination = shift; 353 my $cmd = "$scp $file ${DMZ_HOST}:${SEC_HOST}:${destination}"; 409 my $cmd; 410 if ($SEC_HOST ne '') { 411 $cmd = "$scp $file ${DMZ_HOST}:${SEC_HOST}:${destination}"; 412 } 413 else { 414 $cmd = "$scp $file ${DMZ_HOST}:${destination}"; 415 } 354 416 355 417 my $directory = dirname($destination); … … 367 429 my $destination = shift; 368 430 my $file = shift; 369 370 my $cmd = "$scp ${DMZ_HOST}:${SEC_HOST}:${destination} $file "; 431 my $cmd; 432 if ($SEC_HOST ne '') { 433 $cmd = "$scp ${DMZ_HOST}:${SEC_HOST}:${destination} $file "; 434 } 435 else { 436 $cmd = "$scp $file ${DMZ_HOST}:${destination}"; 437 } 371 438 372 439 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 380 447 sub ssh_exec_command { 381 448 my $cmd = shift; 382 $cmd = "$ssh -n $DMZ_HOST ssh ${SEC_HOST} $cmd"; 449 450 if ($SEC_HOST ne '') { 451 $cmd = "$ssh -n $DMZ_HOST ssh ${SEC_HOST} $cmd"; 452 } 453 else { 454 $cmd = "$ssh -n $DMZ_HOST $cmd"; 455 } 456 383 457 print "EXEC: $cmd\n"; 384 458 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 511 585 } 512 586 elsif ($stage eq 'staticsky') { 513 # ($class_id, $stage_id) = $file =~ /(/;587 ($class_id, $stage_id) = $file =~ /(skycell.\d\d\d\d.\d\d\d).sky.(\d*).dbinfo/; 514 588 } 515 589 elsif ($stage eq 'diff') { 516 # ($class_id,$stage_id) = $file =~ /(/;590 ($class_id,$stage_id) = $file =~ /(skycell.\d\d\d\d.\d\d\d).WS.dif.(\d*).dbinfo/; 517 591 } 518 592 elsif ($stage eq 'ff') { 519 # ($class_id,$stage_id) = $file =~ /(/;593 ($class_id,$stage_id) = $file =~ /wrp\.(\d*).ff.(\d*).dbinfo/; 520 594 } 521 595 return ($stage_id, $class_id); … … 548 622 $class_id = 0; 549 623 } 624 elsif ($stage eq 'staticsky') { 625 ($class_id, $stage_id, $component) = $file =~ /(skycell.\d\d\d\d.\d\d\d).sky.(\d*).([\w\.]+)$/; 626 } 627 elsif ($stage eq 'diff') { 628 ($class_id,$stage_id, $component) = $file =~ /(skycell.\d\d\d\d.\d\d\d).WS.dif.(\d*).([\w\.]+)$/; 629 } 630 elsif ($stage eq 'ff') { 631 ($class_id,$stage_id, $component) = $file =~ /wrp\.(\d*).ff.(\d*).([\w\.]+)$/; 632 } 633 550 634 return($stage_id,$class_id,$component); 551 635 }
Note:
See TracChangeset
for help on using the changeset viewer.
