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_prepare_chip.pl

    r37833 r38168  
    1818use Pod::Usage qw( pod2usage );
    1919
    20 # Hard coded values
    21 # my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 my $remote_root     = '/scratch3/watersc1/';  # Far side destination base location
    23 my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
    24 my $remote_raw      = "${remote_root}/tmp/";  # Directory to find raw data in.
    25 my $threads_req     = 4;
    26 
    27 my $fail_state = "prep_fail";
    28 my $hard_fail_state = "fail";
    2920
    3021# Look for programs we need
     
    3425my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3526my $ipp_burntool_fix = can_run('ipp_apply_burntool_fix.pl') or (warn "Can't find ipp_apply_burntool_fix.pl" and $missing_tools = 1);
     27my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3628
    3729if ($missing_tools) {
     
    4133
    4234# Options
    43 my ($remote_id,$chip_id,$camera,$dbname,$path_base,$no_update,$verbose,$dbverbose);
     35my ($remote_id,$chip_id,$camera,$dbname,$path_base,$no_update,$verbose,$dbverbose,$cmd_recipe);
    4436GetOptions(
    4537    'remote_id=s'    => \$remote_id,
     
    4739    'camera|c=s'     => \$camera,
    4840    'dbname|d=s'     => \$dbname,
     41    'recipe=s'       => \$cmd_recipe,
    4942    'path_base=s'    => \$path_base,
    5043    'no_update'      => \$no_update,
     
    5447
    5548pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    56 pod2usage( -msg => "Required options: --remote_id --chip_id --camera --dbname --path_base", -exitval => 3) unless
     49pod2usage( -msg => "Required options: --remote_id --chip_id --camera --dbname --path_base --recipe", -exitval => 3) unless
    5750    defined($remote_id) and
    5851    defined($chip_id) and
    5952    defined($camera) and
    6053    defined($path_base) and
     54    defined($cmd_recipe) and
    6155    defined($dbname);
     56
     57
     58# Hard coded values
     59# Now accessible from a recipe
     60my %remote_recipe = ();
     61{
     62    my $verbose = 0;
     63    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     64    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     65        run(command => $conf_cmd, verbose => $verbose);
     66    unless ($success) {
     67        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     68        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     69    }
     70    my $mdcParser = PS::IPP::Metadata::Config->new;
     71    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     72
     73    my $active_recipe = '';
     74    my %recipes = ();
     75   
     76#    print Dumper($metadata);
     77    foreach my $entry (@{ $metadata }) {
     78        if (${ $entry }{name} eq 'ACTIVE') {
     79            $active_recipe = ${ $entry }{value}; # Not actually used
     80        }
     81        else {
     82            if (${ $entry }{class} eq 'metadata') { # A real recipe
     83                my $name = ${ $entry }{name};
     84                foreach my $tentry (@{ ${ $entry }{value} }) {
     85                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     86                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     87                    }
     88                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     89                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     90                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     91                        }
     92                    }
     93                }
     94            }
     95        }
     96    }
     97   
     98    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
     99#    print Dumper(%recipes);
     100    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
     101#    print Dumper(\%remote_recipe);
     102}
     103
     104
     105# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     106my $remote_root     = $remote_recipe{REMOTE_ROOT};
     107my $remote_hostname = $remote_recipe{REMOTE_HOSTNAME};         # Name of the remote node.
     108my $remote_raw      = "${remote_root}/tmp/";  # Directory to find raw data in.
     109my $threads_req     = 4;
     110
     111my $fail_state = "prep_fail";
     112my $hard_fail_state = "fail";
    62113
    63114my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
Note: See TracChangeset for help on using the changeset viewer.