[gold-users] API Question

Kevin Van Workum vanw at tticluster.com
Wed Apr 29 10:47:23 MDT 2009


Thanks. It works like a charm (after adding $firstTime = 0 at the end of the
for{} block).

On Tue, Apr 28, 2009 at 12:46 PM, Scott Jackson <
scottmo at clusterresources.com> wrote:

> Per `PERL5LIB=/usr/local/gold/lib perldoc Gold::Request`:
>
> request = $request->setCondition($name[, $value[, $op[, $conj[,$group[,
> $object[, $subject]]]]]]);
>
> To do this properly, you will need to conceptually group them in
> parentheses so that you do not get improper combining of other requested
> options, i.e what you really want is the equivalent of:
>
> goldsh Job Query ( User==mike || User==other || User==bob  )
>
> This would be something like:
>
> $request->setCondition("User, "mike", "And", "+1");
> $request->setCondition("User, "other", "Or");
> $request->setCondition("User, "bob", "Or", "-1");
>
> The first group=+1, adds a leading parentheses before the condition
> The last group=-1, adds a trailing parentheses after the condition
> The first one should be an And so that the parenthesized set is anded with
> other glsuser conditions (like -p, -m, etc.)
>
> You might want to put your code in something like this:
>
>       my $firstTime = 1;
>       my $counter   = 0;
>       foreach my $user (@users)
>       {
>           $counter++;
>           my $lastTime = ($counter == @users) ? 1 : 0;
>
>           if ($firstTime && $lastTime)
>           {
>               $request->setCondition("User, $user, "And", "0");
>           }
>           elsif ($firstTime)
>           {
>               $request->setCondition("User, $user, "And", "+1");
>           }
>           elsif ($lastTime)
>           {
>               $request->setCondition("User, $user, "Or", "-1");
>           }
>           else
>           {
>               $request->setCondition("User, $user, "Or", "0");
>           }
>       }
>
> Scott
>
> Kevin Van Workum wrote:
>
>> Hi,
>>
>> I'm writing a perl script to expand the functionality of glsjob for my
>> users. I'd like to be able to list the jobs for more than one user, e.g.
>> glsjob -u mike -u bob. To get a single user I can do:
>>
>> $request->setCondition("User", $user);
>>
>> but how do I do the equivalent of:
>>
>> goldsh Job Query User==mike || User==bob
>>
>> using the API?
>>
>> Something like this maybe:
>>
>> for my $user (@users) {
>>   $request->setCondition("User, $user, "OR");
>> }
>>
>>
>>
>> --
>> Kevin Van Workum, Ph.D.
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> gold-users mailing list
>> gold-users at supercluster.org
>> http://www.supercluster.org/mailman/listinfo/gold-users
>>
>>
>
>


-- 
Kevin Van Workum, Ph.D.
Tsunamic Technologies Inc.
Vice President
www.ClusterOnDemand.com
877-492-8027 x11
ONLINE COMPUTER CLUSTERS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.supercluster.org/pipermail/gold-users/attachments/20090429/5cf1f17a/attachment.html 


More information about the gold-users mailing list