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

    r38105 r38168  
    1919use Pod::Usage qw( pod2usage );
    2020
    21 # Hard coded values
    22 # my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    23 my $remote_root     = '/scratch3/watersc1/';  # Far side destination base location
    24 my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
    25 my $threads_req     = 0;                      # How many threads are we going to use?
    26 
    27 my $fail_state = "prep_fail";
    28 
    2921# Look for programs we need
    3022my $missing_tools;
     
    3224my $camtool    = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    3325my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     26my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3427
    3528if ($missing_tools) {
     
    3831}
    3932
    40 my ($remote_id,$cam_id,$camera,$dbname,$verbose,$path_base,$no_update);
     33my ($remote_id,$cam_id,$camera,$dbname,$verbose,$path_base,$no_update,$cmd_recipe);
    4134GetOptions(
    4235    'remote_id=s'    => \$remote_id,
     
    4437    'camera|c=s'     => \$camera,
    4538    'dbname|d=s'     => \$dbname,
     39    'recipe=s'       => \$cmd_recipe,
    4640    'path_base=s'    => \$path_base,
    4741    'no_update'      => \$no_update,
     
    5044
    5145pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    52 pod2usage( -msg => "Required options: --remote_id --cam_id --camera --dbname --path_base", -exitval => 3) unless
     46pod2usage( -msg => "Required options: --remote_id --cam_id --camera --dbname --path_base --recipe", -exitval => 3) unless
    5347    defined($remote_id) and
    5448    defined($cam_id) and
    5549    defined($camera) and
    5650    defined($path_base) and
     51    defined($cmd_recipe) and
    5752    defined($dbname);
     53
     54
     55# Hard coded values
     56# Now accessible from a recipe
     57my %remote_recipe = ();
     58{
     59    my $verbose = 0;
     60    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
     61    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     62        run(command => $conf_cmd, verbose => $verbose);
     63    unless ($success) {
     64        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     65        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
     66    }
     67    my $mdcParser = PS::IPP::Metadata::Config->new;
     68    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     69
     70    my $active_recipe = '';
     71    my %recipes = ();
     72   
     73#    print Dumper($metadata);
     74    foreach my $entry (@{ $metadata }) {
     75        if (${ $entry }{name} eq 'ACTIVE') {
     76            $active_recipe = ${ $entry }{value}; # Not actually used
     77        }
     78        else {
     79            if (${ $entry }{class} eq 'metadata') { # A real recipe
     80                my $name = ${ $entry }{name};
     81                foreach my $tentry (@{ ${ $entry }{value} }) {
     82                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
     83                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
     84                    }
     85                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array
     86                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
     87                        push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
     88                        }
     89                    }
     90                }
     91            }
     92        }
     93    }
     94   
     95    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
     96#    print Dumper(%recipes);
     97    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
     98#    print Dumper(\%remote_recipe);
     99}
     100
     101
     102# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     103my $remote_root     = $remote_recipe{REMOTE_ROOT};
     104my $remote_hostname = $remote_recipe{REMOTE_HOSTNAME};         # Name of the remote node.
     105my $threads_req     = 0;                      # How many threads are we going to use?
     106
     107my $fail_state = "prep_fail";
     108
    58109
    59110my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $cam_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
Note: See TracChangeset for help on using the changeset viewer.