[gold-users] API Question
Scott Jackson
scottmo at clusterresources.com
Tue Apr 28 10:50:51 MDT 2009
Oops, I missed the operator:)
Scott Jackson 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");
>
$request->setCondition("User, "mike", "EQ", "And", "+1");
$request->setCondition("User, "other", "EQ", "Or");
$request->setCondition("User, "bob", "EQ", "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");
$request->setCondition("User, $user, "EQ", "And", "0");
> }
> elsif ($firstTime)
> {
> $request->setCondition("User, $user, "And", "+1");
$request->setCondition("User, $user, "EQ", "And", "+1");
> }
> elsif ($lastTime)
> {
> $request->setCondition("User, $user, "Or", "-1");
$request->setCondition("User, $user, "EQ", "Or", "-1");
> }
> else
> {
> $request->setCondition("User, $user, "Or", "0");
$request->setCondition("User, $user, "EQ", "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
>>
>
>
More information about the gold-users
mailing list