IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2015, 3:12:58 PM (11 years ago)
Author:
watersc1
Message:

Updated remote code with ff support and ippconfig recipes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/sc_remote_poll.pl

    r38145 r38168  
    2626use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2727use Pod::Usage qw( pod2usage );
    28 
    29 # Hard coded values
    30 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/';
    3728
    3829# tools
     
    4435my $camtool    = can_run('camtool')    or (warn "Can't find camtool"    and $missing_tools = 1);
    4536my $warptool   = can_run('warptool')   or (warn "Can't find warptool"   and $missing_tools = 1);
     37my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    4638
    4739if ($missing_tools) {
     
    5143
    5244# Options
    53 my ($remote_id,$path_base,$skip_poll,$skip_transfer,$job_id,$dbname,$retry,$verbose,$no_update,$camera);
     45my ($remote_id,$path_base,$skip_poll,$skip_transfer,$job_id,$dbname,$retry,$verbose,$no_update,$camera,$cmd_recipe);
    5446$verbose = 0;
    5547GetOptions(
     
    6153    'camera=s'      => \$camera,
    6254    'dbname=s'      => \$dbname,
     55    'recipe=s'       => \$cmd_recipe,
    6356    'retry'         => \$retry,
    6457    'verbose'       => \$verbose,
     
    6760
    6861pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    69 pod2usage( -msg => "Required options: --remote_id --job_id --path_base", -exitval => 3) unless
     62pod2usage( -msg => "Required options: --remote_id --job_id --path_base --recipe", -exitval => 3) unless
    7063    defined($path_base) and
    7164    defined($remote_id) and
     65    defined($cmd_recipe) and
    7266    defined($job_id);
     67
     68
     69
     70# Now accessible from a recipe
     71my %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
     117my $DMZ_HOST = $remote_recipe{DMZ_HOST};
     118my @SEC_HOSTS= @{ $remote_recipe{SEC_HOST} };
     119my $SEC_HOST;
     120if ($#SEC_HOSTS != -1) {
     121    $SEC_HOST = $SEC_HOSTS[int(rand(@SEC_HOSTS))];
     122}
     123else {
     124    $SEC_HOST = '';
     125}
     126my $IPP_PATH = $remote_recipe{IPP_PATH};
     127my $remote_root  = $remote_recipe{REMOTE_ROOT};
     128
    73129
    74130my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id);
     
    351407    my $file = shift;
    352408    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    }
    354416
    355417    my $directory = dirname($destination);
     
    367429    my $destination = shift;
    368430    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    }
    371438
    372439    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    380447sub ssh_exec_command {
    381448    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
    383457    print "EXEC: $cmd\n";
    384458    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    511585    }
    512586    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/;
    514588    }
    515589    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/;
    517591    }
    518592    elsif ($stage eq 'ff') {
    519 #       ($class_id,$stage_id) = $file =~ /(/;
     593        ($class_id,$stage_id) = $file =~ /wrp\.(\d*).ff.(\d*).dbinfo/;
    520594    }
    521595    return ($stage_id, $class_id);
     
    548622        $class_id = 0;
    549623    }
     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
    550634    return($stage_id,$class_id,$component);
    551635}
Note: See TracChangeset for help on using the changeset viewer.