static char *myname;
+static void usage(char *);
+static int query_all(edg_wll_Context, edg_wll_JobStat **, edg_wlc_JobId **);
int main(int argc,char *argv[])
{
- edg_wll_Context ctx, sctx[MAX_SERVERS];
- int i, result=0, nsrv=0;
+ edg_wll_Context sctx[MAX_SERVERS];
char *servers[MAX_SERVERS];
- char *errstr = NULL;
+ int i, result=0, nsrv=0;
myname = argv[0];
printf("\n");
- if (argc < 2 || strcmp(argv[1],"--help") == 0) {
- fprintf(stderr,"Usage: %s job_id [job_id [...]]\n",argv[0]);
- fprintf(stderr," %s -all\n",argv[0]);
- return 1;
- }
- else if (argc >= 2 && strcmp(argv[1],"-all") == 0) {
+ if ( argc < 2 || strcmp(argv[1],"--help") == 0 ) { usage(argv[0]); return 0; }
+
+ if ( edg_wll_InitContext(&sctx[0]) ) {
+ fprintf(stderr,"cannot initialize edg_wll_Context\n");
+ exit(1);
+ }
+
+ if ( !strcmp(argv[1], "-all" ) ) {
edg_wll_JobStat *statesOut;
edg_wlc_JobId *jobsOut;
- edg_wll_QueryRec jc[2];
jobsOut = NULL;
statesOut = NULL;
-/* init context */
- if (edg_wll_InitContext(&ctx)) {
- fprintf(stderr,"%s: cannot initialize edg_wll_Context\n",myname);
- exit(1);
+ if ( (result = query_all(sctx[0], &statesOut, &jobsOut)) ) dgerr(sctx[0], "edg_wll_QueryJobs");
+ else for ( i = 0; statesOut[i].state; i++ ) printstat(statesOut[i],0);
+
+ if ( jobsOut ) {
+ for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]);
+ free(jobsOut);
+ }
+ if ( statesOut ) {
+ for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]);
+ free(statesOut);
}
-/* retrieve job ID's */
- memset(jc,0,sizeof jc);
+ edg_wll_FreeContext(sctx[0]);
- jc[0].attr = EDG_WLL_QUERY_ATTR_OWNER;
- jc[0].op = EDG_WLL_QUERY_OP_EQUAL;
- jc[0].value.c = NULL; /* is NULL, peerName filled in on server side */
- jc[1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
+ return result;
+ }
- //if (edg_wll_QueryJobs(ctx,jc,EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN | EDG_WLL_STAT_CHILDSTAT,
- result = edg_wll_QueryJobs(ctx,jc,0,&jobsOut, &statesOut);
- if (result == E2BIG) {
- int r;
- edg_wll_Error(ctx, NULL, &errstr);
- if (edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r)) {
- dgerr(ctx,"edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)");
- free(errstr);
- result=1; goto cleanup;
+ if ( !strcmp(argv[1], "-x") ) {
+ edg_wlc_JobId job;
+ edg_wll_JobStat status;
+
+ if ( argc < 3 ) { usage(argv[0]); return 1; }
+ if ( edg_wll_InitContext(&sctx[0]) ) {
+ fprintf(stderr,"%s: cannot initialize edg_wll_Context\n",myname);
+ exit(1);
+ }
+ edg_wll_SetParam(sctx[0], EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, argv[2]);
+ for ( i = 3; i < argc; i++ ) {
+ memset(&status, 0, sizeof status);
+ if (edg_wlc_JobIdParse(argv[i],&job)) {
+ fprintf(stderr,"%s: %s: cannot parse jobId\n", myname, argv[i]);
+ continue;
}
- if (r != EDG_WLL_QUERYRES_LIMITED) goto late_error;
- } else if (result) {
- dgerr(ctx,"edg_wll_QueryJobs");
- result=1; goto cleanup;
+ if ( edg_wll_JobStatusProxy(sctx[0], job, EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN | EDG_WLL_STAT_CHILDSTAT, &status)) {
+ dgerr(sctx[0], "edg_wll_JobStatusProxy"); result = 1;
+ } else printstat(status, 0);
+
+ if ( job ) edg_wlc_JobIdFree(job);
+ if ( status.state ) edg_wll_FreeStatus(&status);
}
+ edg_wll_FreeContext(sctx[0]);
-/* retrieve and print status of each job */
- for (i=0; statesOut[i].state; i++)
- printstat(statesOut[i],0);
+ return result;
+ }
-late_error: if (result) {
- edg_wll_SetError(ctx, result, errstr);
- free(errstr);
- dgerr(ctx,"edg_wll_QueryJobs");
- result=1;
- }
-cleanup:
- if (jobsOut)
- {
- for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]);
- free(jobsOut);
- }
- if (statesOut)
- {
- for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]);
- free(statesOut);
- }
- edg_wll_FreeContext(ctx);
- }
- else {
- for (i=1; i<argc; i++) {
+ for ( i = 1; i < argc; i++ ) {
int j;
char *bserver;
edg_wlc_JobId job;
memset(&status,0,sizeof status);
-/* parse job ID */
+
if (edg_wlc_JobIdParse(argv[i],&job)) {
- fprintf(stderr,"%s: %s: cannot parse jobId\n",
- myname,argv[i]);
+ fprintf(stderr,"%s: %s: cannot parse jobId\n", myname,argv[i]);
continue;
}
-/* determine bookkeeping server address */
bserver = edg_wlc_JobIdGetServer(job);
if (!bserver) {
- fprintf(stderr,"%s: %s: cannot extract bookkeeping server address\n",
- myname,argv[i]);
- edg_wlc_JobIdFree(job);
+ fprintf(stderr,"%s: %s: cannot extract bookkeeping server address\n", myname,argv[i]);
+ edg_wlc_JobIdFree(job);
continue;
}
-/* use context database */
- for (j=0; j<nsrv && strcmp(bserver,servers[j]); j++);
- if (j==nsrv) {
- edg_wll_InitContext(&sctx[j]);
+ for ( j = 0; j < nsrv && strcmp(bserver, servers[j]); j++ );
+ if ( j == nsrv ) {
+ if ( i > 0 ) edg_wll_InitContext(&sctx[j]);
nsrv++;
servers[j] = bserver;
}
if (edg_wll_JobStatus(sctx[j], job, EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN | EDG_WLL_STAT_CHILDSTAT, &status)) {
- dgerr(sctx[j],"edg_wll_JobStatus");
- result=1; goto cleanup2;
- }
-
-/* print job status */
- printstat(status,0);
+ dgerr(sctx[j],"edg_wll_JobStatus"); result = 1;
+ } else printstat(status,0);
-cleanup2:
if (job) edg_wlc_JobIdFree(job);
if (status.state) edg_wll_FreeStatus(&status);
- }
- for (i=0; i<nsrv; i++) edg_wll_FreeContext(sctx[i]);
}
+ for ( i = 0; i < nsrv; i++ ) edg_wll_FreeContext(sctx[i]);
return result;
}
static void
+usage(char *name)
+{
+ fprintf(stderr,"Usage: %s job_id [-x lb_proxy_serve_sock] [job_id [...]]\n", name);
+ fprintf(stderr," %s -all\n", name);
+}
+
+static int
+query_all(edg_wll_Context ctx, edg_wll_JobStat **statesOut, edg_wlc_JobId **jobsOut)
+{
+ edg_wll_QueryRec jc[2];
+ int ret;
+
+ memset(jc, 0, sizeof jc);
+ jc[0].attr = EDG_WLL_QUERY_ATTR_OWNER;
+ jc[0].op = EDG_WLL_QUERY_OP_EQUAL;
+ jc[0].value.c = NULL; /* is NULL, peerName filled in on server side */
+ jc[1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
+
+ if ( (ret = edg_wll_QueryJobs(ctx, jc, 0, jobsOut, statesOut)) ) {
+ if ( ret == E2BIG ) {
+ int r;
+ if ( edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r) ) return ret;
+ if ( r != EDG_WLL_QUERYRES_LIMITED ) return ret;
+
+ printf("Warning: only limited result returned!\n");
+ return 0;
+ } else return ret;
+ }
+
+ return ret;
+}
+
+static void
dgerr(edg_wll_Context ctx,char *where)
{
char *etxt,*edsc;
#include "glite/lb/xml_conversions.h"
#include "glite/lb/consumer.h"
+int use_proxy = 0;
+
+int (*user_jobs)(edg_wll_Context, edg_wlc_JobId **, edg_wll_JobStat **);
+
+
+void
+usage(char *me)
+{
+ fprintf(stderr,"usage: %s [-h] [-x] [userid]\n", me);
+}
+
int main(int argc,char **argv)
{
edg_wll_Context ctx;
int i,j;
char *owner = NULL;
- switch (argc) {
- case 1 : break;
-
- case 2 : /* fprintf(stderr,"\'userid\' option not implemented yet.\n"); */
- if ( strcmp(argv[1],"--help")) {
- owner = strdup(argv[1]);
- break;
- }
- /* else : fall through */
-
- default: fprintf(stderr,"usage: %s [userid]\n",argv[0]);
- return 1;
- }
-
+ user_jobs = edg_wll_UserJobs;
+ for ( i = 1; i < argc; i++ ) {
+ if ( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) {
+ usage(argv[0]);
+ exit(0);
+ } else if ( !strcmp(argv[i], "-x") ) {
+ user_jobs = edg_wll_UserJobsProxy;
+ continue;
+ }
+
+ owner = strdup(argv[i]);
+ break;
+ }
edg_wll_InitContext(&ctx);
+ if ( user_jobs == edg_wll_UserJobsProxy && owner )
+ edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_USER, owner);
- if (edg_wll_UserJobs(ctx,&jobs,&states)) goto err;
+ if (user_jobs(ctx,&jobs,&states)) goto err;
for (i=0; states[i].state != EDG_WLL_JOB_UNDEF; i++) {
char *id = edg_wlc_JobIdUnparse(states[i].jobId),
*st = edg_wll_StatToString(states[i].state);
#include <globus_common.h>
+#include "glite/security/glite_gss.h"
#include "glite/wmsutils/jobid/cjobid.h"
#include "glite/lb/notifid.h"
#include "glite/lb/producer.h"
char *src_instance = NULL;
int err = 0/*,i,done = 0,fmtlen*/;
int pri = 0;
- char *lbproxy = NULL;
+ int use_lbproxy = 0;
+ char *lbproxy_user = NULL;
+ char *lbproxy_store_sock = NULL;
int deb = 0;
#ifdef ENABLE_REASON_LENGTH
int elength = 0;
edg_wll_Args parray[] = {
{ EDG_WLL_ARGS_EVENT, "e", "event", "select event type (see -e help)", &event },
{ EDG_WLL_ARGS_BOOL, "p", "priority", "send as priority event", &pri },
- { EDG_WLL_ARGS_STRING, "x", "lbproxy", "send directly to L&B Proxy (not locallogger) with given credentials", &lbproxy },
+ { EDG_WLL_ARGS_BOOL, "x", "lbproxy", "send directly to L&B Proxy (not locallogger)", &use_lbproxy },
+ { EDG_WLL_ARGS_STRING, "S", "lbproxy-store-sock", "L&B Proxy store socket path", &lbproxy_store_sock },
+ { EDG_WLL_ARGS_STRING, "U", "lbproxy-user-dn", "User certificate DN L&B Proxy store socket path", &lbproxy_user },
+
{ EDG_WLL_ARGS_STRING, "m", "machine", 0, &server },
{ EDG_WLL_ARGS_SOURCE, "s", "source", "event source (see -s help)", &src },
{ EDG_WLL_ARGS_STRING, "i", "source-instance", "event source instance", &src_instance },
{ EDG_WLL_ARGS_NONE },
};
edg_wll_ParseArgs(&argc, argv, parray,
- "Usage: %s [-d] [-p] [-x] [-l eventlen] [-j dg_jobid]"
+ "Usage: %s [-d] [-p] [[-x] [-S sock] [-U user_dn]] [-l eventlen] [-j dg_jobid]"
"[-s source_id] -e event [key=value ...]");
-/* XXX: Obsolete?
- if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) {
- fprintf(stderr, "Cannot initialize Globus common module\n");
- exit(1);
- }
-*/
edg_wll_InitContext(&ctx);
/* log the event - priority/normal/proxy */
logev = (pri) ? edg_wll_LogEventSync : edg_wll_LogEvent;
- logev = (lbproxy) ? edg_wll_LogEventProxy : logev;
+ logev = (use_lbproxy) ? edg_wll_LogEventProxy : logev;
/* if no job given - generate some */
if (jobid_s == 0) {
edg_wll_SetParam(ctx, EDG_WLL_PARAM_LEVEL,
(deb) ? EDG_WLL_LEVEL_DEBUG : EDG_WLL_LEVEL_SYSTEM);
- if (lbproxy) {
- edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, "/tmp/lb_proxy_store.sock");
- edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, "/tmp/lb_proxy_serve.sock");
- if (edg_wll_SetLoggingJobProxy(ctx,jobid,code,lbproxy,EDG_WLL_SEQ_NORMAL)) {
+ if ( use_lbproxy ) {
+ if ( !lbproxy_user ) {
+ gss_cred_id_t gss_cred = GSS_C_NO_CREDENTIAL;
+ edg_wll_GssStatus gss_stat;
+ OM_uint32 min_stat;
+ if ( edg_wll_gss_acquire_cred_gsi(NULL, NULL, &gss_cred, &lbproxy_user, &gss_stat) )
+ lbproxy_user = "anonymous";
+ if ( gss_cred != GSS_C_NO_CREDENTIAL ) gss_release_cred(&min_stat, &gss_cred);
+ }
+ if ( lbproxy_store_sock )
+ edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, lbproxy_store_sock);
+ if (edg_wll_SetLoggingJobProxy(ctx,jobid,code,lbproxy_user,EDG_WLL_SEQ_NORMAL)) {
char *et,*ed;
edg_wll_Error(ctx,&et,&ed);
- fprintf(stderr,"SetLoggingJobProxy(%s,%s,%s): %s (%s)\n",jobid_s,code,lbproxy,et,ed);
+ fprintf(stderr,"SetLoggingJobProxy(%s,%s,%s): %s (%s)\n",jobid_s,code,lbproxy_user,et,ed);
exit(1);
}
} else {