Changeset ad5639c for fedkit


Ignore:
Timestamp:
May 18, 2008 1:17:57 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
bd6e48a
Parents:
387408b
Message:

retry with different credentials on failure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/splitter.pl

    r387408b rad5639c  
    457457}
    458458
     459# Fill tbparams with results from the fedd call.  The command is passed in and
     460# a string with any relevant error conditions is returned.  undef is success.
     461sub fedd_access_request{
     462    my($cmd) = @_;
     463    my($rv)=undef;
     464
     465    system("$cmd 2> /tmp/splitter.err.$$ > /tmp/splitter.$$" );
     466
     467    if ( ! $? ) {
     468        print "Parsing /tmp/splitter.$$\n";
     469        &parse_testbeds_filename("/tmp/splitter.$$", $tbparams) ||
     470            ($rv =  "Error reading fedd output: $!\n");
     471    }
     472    else {
     473        my $f = new IO::File("/tmp/splitter.err.$$");
     474        $rv =  "Fedd_client error:\n";
     475        while (<$f>) { $rv .= $_; }
     476        $f->close();
     477    }
     478    unlink("/tmp/splitter.$$", "/tmp/splitter.err.$$");
     479    return $rv;
     480}
    459481
    460482$pid = $gid = "dummy";              # Default project and group to pass to
     
    575597        my @nodes;      # Current testbed node requests
    576598
     599        # The Allbeds line has the testbed name first separated by the node
     600        # requirements of the testbeds.  A node requirement is separated form
     601        # teh testbed name and other node requirements by a vertical bar (|).
     602        # This pulls the testbed off the front (which must be present) and
     603        # splits the node descriptors out by the vertical bar.  The first
     604        # vertical bar (the one after the testbed) is removed by the intial
     605        # regular expression to avoid a null entry in @nodes.  The node
     606        # requests are of the form image:type:count and can be passed directly
     607        # to fedd_client as parameters.
    577608        /([^|]+)\|?(.*)/ && do {
    578             my $n;
     609            my $n;      # Scratch
    579610
    580611            ($tb , $n) = ($1, $2);
     
    588619                die "Can't open pipe to fedd:$!\n";
    589620            my $proj = $auth_proj ? " -p $auth_proj " : "";
     621            my @cmds;
     622            my $rv;
    590623
    591624            print("Checking access to $tb using " . $tbparams->{$tb}->{'uri'}
    592625                . "\n") if $verbose;
    593626
    594             my $cmd = "$fedd_client -t " .
     627            # First access command, implicitly uses localhost fedd
     628            push(@cmds,"$fedd_client -t " .
    595629                $tbparams->{$tb}->{'uri'} .  " -T $ENV{HOME}/cacert.pem ".
    596630                "-l $tb $proj" . (@nodes ? " -n " : " ") .
    597                 join(" -n ", @nodes) . "| /usr/bin/tee fedd.$tb ";
    598             print "$cmd\n" if $verbose;
    599 
    600             $access_pipe->reader($cmd) ||
    601                     die "Can't exec fedd_client: $!\n";
    602 
    603             &parse_testbeds($access_pipe, $tbparams) ||
    604                 warn("Error reading fedd output: $!\n");
    605             $access_pipe->close();
     631                join(" -n ", @nodes));
     632            # Second try access command, implicitly directly contact testbed
     633            push(@cmds,"$fedd_client -t " .
     634                $tbparams->{$tb}->{'uri'} .  " -u " .
     635                $tbparams->{$tb}->{'uri'} .  " -T $ENV{HOME}/cacert.pem ".
     636                "-l $tb $proj" . (@nodes ? " -n " : " ") .
     637                join(" -n ", @nodes));
     638
     639            foreach my $c (@cmds) {
     640                print "$c\n" if $verbose;
     641                $rv = &fedd_access_request($c);
     642                warn($rv) if $rv;
     643
     644                last if $rv eq undef;
     645            }
     646            die "Cannot get access to $tb\n"  if $rv;
    606647        }
    607648        next;
Note: See TracChangeset for help on using the changeset viewer.