me);
}
if ( !cmd || !strcmp(cmd, "new") )
- fprintf(stderr,"\n'new' command usage: %s new [ { -s socket_fd | -a fake_addr } ] {-j jobid | -o owner | -n network_server}\n"
+ fprintf(stderr,"\n'new' command usage: %s new [ { -s socket_fd | -a fake_addr } ] {-j jobid | -o owner | -n network_server | -v virtual_organization}\n"
" jobid job ID to connect notif. reg. with\n"
" owner match this owner DN\n"
" network_server match only this networ server (WMS entry point)\n\n"
char *arg = NULL;
int attr = 0;
- while ((c = getopt(argc-1,argv+1,"j:o:n:s:a:")) > 0) switch (c) {
+ while ((c = getopt(argc-1,argv+1,"j:o:v:n:s:a:")) > 0) switch (c) {
case 'j':
if (arg) { usage("new"); return EX_USAGE; }
attr = EDG_WLL_QUERY_ATTR_JOBID;
if (arg) { usage("new"); return EX_USAGE; }
attr = EDG_WLL_QUERY_ATTR_OWNER;
arg = optarg; break;
+ case 'v':
+ if (arg) { usage("new"); return EX_USAGE; }
+ attr = EDG_WLL_QUERY_ATTR_JDL_ATTR;
+ arg = optarg; break;
case 'n':
if (arg) { usage("new"); return EX_USAGE; }
attr= EDG_WLL_QUERY_ATTR_NETWORK_SERVER;
conditions[0][0].attr = attr;
conditions[0][0].op = EDG_WLL_QUERY_OP_EQUAL;
if (attr == EDG_WLL_QUERY_ATTR_JOBID) conditions[0][0].value.j = jid;
- else conditions[0][0].value.c = arg;
+ else {
+ conditions[0][0].value.c = arg;
+ if (attr == EDG_WLL_QUERY_ATTR_JDL_ATTR) asprintf(&(conditions[0][0].attr_id.tag), "VirtualOrganisation");
+ }
if ( !edg_wll_NotifNew(ctx,
(edg_wll_QueryRec const* const*)conditions,
int edg_wll_CmpColumn(const edg_wll_QueryRec *,const edg_wll_QueryRec *);
char *edg_wll_StatToSQL(edg_wll_JobStat const *stat,edg_wll_QueryAttr attr);
+char *edg_wll_JDLStatToSQL(edg_wll_JobStat const *stat, edg_wll_QueryRec col_rec);
typedef struct _edg_wll_IColumnRec {
#define STD_PREFIX "STD_"
#define USR_PREFIX "USR_"
#define TIME_PREFIX "TIME_"
+#define JDL_PREFIX "JDL_"
#endif /* GLITE_LB_INDEX_H */
#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <cclassad.h>
#include "glite/lb/context-int.h"
#include "glite/lbu/trio.h"
idx[nkeys] = realloc(idx[nkeys],(j+2)*sizeof idx[nkeys][0]);
memset(&idx[nkeys][j+1],0,sizeof idx[nkeys][0]);
}
-
+
if (edg_wll_ColumnToQueryRec(column_names[i][j],&idx[nkeys][j])) {
int code;
char *ed;
return std_attrs[i].attr ? std_attrs[i].to_sql(stat,std_attrs[i].offset) : (char *) -1;
}
+char *edg_wll_JDLStatToSQL(edg_wll_JobStat const *stat,edg_wll_QueryRec col_rec)
+{
+ struct cclassad *ad = NULL;
+ char *extr_val = NULL;
+
+ ad = cclassad_create(stat->jdl);
+ if (ad) {
+ if (!cclassad_evaluate_to_string(ad, col_rec.attr_id.tag, &extr_val)) { // Extract attribute value
+ extr_val = NULL;
+ cclassad_delete(ad);
+ }
+ }
+
+ //return extr_val ? extr_val : (char *) -1;
+ return extr_val;
+}
+
int edg_wll_ColumnToQueryRec(const char *col_name,edg_wll_QueryRec *rec)
{
int i;
rec->attr_id.tag = strdup(col_name+const_len(USR_PREFIX));
rec->value.c = NULL;
}
+ else if (strncasecmp(col_name,JDL_PREFIX,const_len(JDL_PREFIX)) == 0) {
+ rec->attr = EDG_WLL_QUERY_ATTR_JDL_ATTR;
+ rec->attr_id.tag = strdup(col_name+const_len(JDL_PREFIX));
+ rec->value.c = NULL;
+ }
return !rec->attr;
}
free(s);
}
}
+ else if (rec->attr == EDG_WLL_QUERY_ATTR_JDL_ATTR) {
+ strcpy(col,JDL_PREFIX);
+ strcat(col,rec->attr_id.tag);
+ }
else {
int i;
for (i=0; std_attrs[i].name && std_attrs[i].attr != rec->attr; i++);
time_t now = time(NULL);
char *cond_where = NULL;
+ char *cond_and_where = NULL;
edg_wll_ResetError(ctx);
if (ctx->notif_index) {
- cond_where = strdup("");
edg_wll_IColumnRec *notif_index_cols = ctx->notif_index_cols;
for (i=0; notif_index_cols[i].qrec.attr; i++) {
char *val = NULL;
- val = edg_wll_StatToSQL(stat,notif_index_cols[i].qrec.attr);
- assert(val != (char *) -1);
+ if (notif_index_cols[i].qrec.attr != EDG_WLL_QUERY_ATTR_JDL_ATTR) {
+ val = edg_wll_StatToSQL(stat,notif_index_cols[i].qrec.attr);
+ assert(val != (char *) -1);
+ }
+ else { // Special Treatment for JDL attributes
+ val = edg_wll_JDLStatToSQL(stat,notif_index_cols[i].qrec);
+ }
if (val) {
char *aux;
- trio_asprintf(&aux, "%s or %s = %s",cond_where,
+ if (!cond_where) cond_where = strdup("");
+ trio_asprintf(&aux, "%s or %s = '%s'",cond_where,
notif_index_cols[i].colname,val);
free(cond_where);
cond_where = aux;
free(val);
}
+ else if (notif_index_cols[i].qrec.attr == EDG_WLL_QUERY_ATTR_JDL_ATTR) {
+ char *aux;
+ if (!cond_and_where) cond_and_where = strdup("");
+ trio_asprintf(&aux, "%s AND %s = NULL",cond_and_where,
+ notif_index_cols[i].colname);
+ free(cond_and_where);
+ cond_and_where = aux;
+ free(val);
+ }
}
}
"select distinct n.notifid,n.destination,n.valid,u.cert_subj,n.conditions "
"from notif_jobs j,users u,notif_registrations n "
"where j.notifid=n.notifid and n.userid=u.userid "
- " and (j.jobid = '%|Ss' or j.jobid = '%|Ss' %s)",
- ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS,cond_where ? cond_where : "");
+ " and (j.jobid = '%|Ss' or j.jobid = '%|Ss' %s) %s",
+ ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS,cond_where ? cond_where : "",cond_and_where ? cond_and_where : "");
free(ju);