From 4417f9fb181de458663103fd0b8ca8e218d7029c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Fri, 4 Jan 2013 14:06:06 +0000 Subject: [PATCH] - VM job type querying - bugfix in match_status (several missed breaks in switch on condition attributes) --- org.glite.lb.server/src/cond_dump.c | 4 ++++ org.glite.lb.server/src/lb_proto.c | 7 +++++++ org.glite.lb.server/src/lb_xml_parse.c.T | 7 +++++++ org.glite.lb.server/src/query.c | 34 ++++++++++++++++++++++++++++++++ org.glite.lb.server/src/ws_typemap.h | 1 + org.glite.lb.server/src/ws_typeref.c.T | 7 +++++-- 6 files changed, 58 insertions(+), 2 deletions(-) diff --git a/org.glite.lb.server/src/cond_dump.c b/org.glite.lb.server/src/cond_dump.c index 2c56f3b..ae659ea 100644 --- a/org.glite.lb.server/src/cond_dump.c +++ b/org.glite.lb.server/src/cond_dump.c @@ -183,6 +183,10 @@ int edg_wll_Condition_Dump(notifInfo *ni, char **output, int oneline){ GS(buf); free(buf); break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + /*XXX op. within not implemented */ + GS(edg_wll_VMStatToString((edg_wll_JobStatCode)l2->value.i)); + break; default: assert(! "Unknown condition attribute!"); break; diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c index f2edda31..bd1b83e 100644 --- a/org.glite.lb.server/src/lb_proto.c +++ b/org.glite.lb.server/src/lb_proto.c @@ -560,6 +560,13 @@ int edg_wll_ParseQueryConditions(edg_wll_Context ctx, const char *query, edg_wll goto err; } break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + if ( 0 > (conds[i][j].value.i = edg_wll_StringToVMStat(value))) { + asprintf(&errmsg, "Unknown VM job state \"%s\" in query", value); + err = edg_wll_SetError(ctx, EINVAL, errmsg); + goto err; + } + break; default: asprintf(&errmsg, "Value conversion for attribute \"%s\" not supported in current implementation", attribute); err = edg_wll_SetError(ctx, ENOSYS, errmsg); diff --git a/org.glite.lb.server/src/lb_xml_parse.c.T b/org.glite.lb.server/src/lb_xml_parse.c.T index 5c91d19..199f014 100644 --- a/org.glite.lb.server/src/lb_xml_parse.c.T +++ b/org.glite.lb.server/src/lb_xml_parse.c.T @@ -562,6 +562,10 @@ static void endJobQueryRec(void *data, const char *el UNUSED_VAR) edg_wll_from_string_to_edg_wll_StatJobtype(XMLCtx); break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = + edg_wll_from_string_to_edg_wll_StatVm_state(XMLCtx); + break; default: edg_wll_freeBuf(XMLCtx); XMLCtx->level--; @@ -691,6 +695,9 @@ static void endQueryEventsRequest(void *data, const char *el UNUSED_VAR) edg_wll_from_string_to_edg_wll_StatJobtype(XMLCtx); break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.i = + edg_wll_from_string_to_edg_wll_StatVm_state(XMLCtx); default: edg_wll_freeBuf(XMLCtx); XMLCtx->level--; diff --git a/org.glite.lb.server/src/query.c b/org.glite.lb.server/src/query.c index bbdde40..7d46684 100644 --- a/org.glite.lb.server/src/query.c +++ b/org.glite.lb.server/src/query.c @@ -842,6 +842,15 @@ static char *ec_to_head_where(edg_wll_Context ctx,const edg_wll_QueryRec **ec) ct++; break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + if ( ec[m][n].op != EDG_WLL_QUERY_OP_EQUAL && ec[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) + { + edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with VM status"); + return NULL; + } + ct++; + break; + default: sprintf(msg, "ec_to_head_where(): attr=%d unsupported", ec[m][n].attr); edg_wll_SetError(ctx, EINVAL, msg); @@ -1147,6 +1156,15 @@ static char *jc_to_head_where( ct++; break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + if ( jc[m][n].op != EDG_WLL_QUERY_OP_EQUAL && jc[m][n].op != EDG_WLL_QUERY_OP_UNEQUAL ) + { + edg_wll_SetError(ctx, EINVAL, "only `=' and '!=' supported with VM status"); + return NULL; + } + ct++; + break; + default: sprintf(msg, "jc_to_head_where(): attr=%d unsupported", jc[m][n].attr); @@ -1282,6 +1300,7 @@ static char *jc_to_head_where( case EDG_WLL_QUERY_ATTR_EXITCODE: case EDG_WLL_QUERY_ATTR_STATUS: case EDG_WLL_QUERY_ATTR_JOB_TYPE: + case EDG_WLL_QUERY_ATTR_VM_STATUS: if ( !is_indexed(&(jc[m][n]), ctx) || !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) ) { @@ -1657,6 +1676,7 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; // TODO: EDG_WLL_QUERY_OP_LESS, EDG_WLL_QUERY_OP_GREATER, EDG_WLL_QUERY_OP_WITHIN, EDG_WLL_QUERY_OP_CHANGED } + break; case EDG_WLL_QUERY_ATTR_NETWORK_SERVER: if ( stat->network_server ) { @@ -1796,6 +1816,7 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if (oldstat->stateEnterTime.tv_sec != stat->stateEnterTime.tv_sec) goto or_satisfied; break; } + break; case EDG_WLL_QUERY_ATTR_LASTUPDATETIME: if ( !stat->lastUpdateTime.tv_sec ) break; @@ -1821,6 +1842,7 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if (oldstat->lastUpdateTime.tv_sec != stat->lastUpdateTime.tv_sec) goto or_satisfied; break; } + break; case EDG_WLL_QUERY_ATTR_JOB_TYPE: switch ( conds[i][j].op ) { @@ -1831,6 +1853,18 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.i != stat->jobtype ) goto or_satisfied; break; } + break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: + switch ( conds[i][j].op ) + { + case EDG_WLL_QUERY_OP_EQUAL: + if ( conds[i][j].value.i == stat->vm_state ) goto or_satisfied; + break; + case EDG_WLL_QUERY_OP_UNEQUAL: + if ( conds[i][j].value.i != stat->vm_state ) goto or_satisfied; + break; + } + break; default: break; } diff --git a/org.glite.lb.server/src/ws_typemap.h b/org.glite.lb.server/src/ws_typemap.h index 5701e2f..6a84855 100644 --- a/org.glite.lb.server/src/ws_typemap.h +++ b/org.glite.lb.server/src/ws_typemap.h @@ -44,6 +44,7 @@ limitations under the License. #define LASTUPDATETIME lbt__queryAttr__LASTUPDATETIME #define NETWORKSERVER lbt__queryAttr__NETWORKSERVER #define JOBTYPE lbt__queryAttr__JOBTYPE +#define VM_STATUS lbt__queryAttr__VM_USCORESTATUS #define EQUAL lbt__queryOp__EQUAL #define UNEQUAL lbt__queryOp__UNEQUAL diff --git a/org.glite.lb.server/src/ws_typeref.c.T b/org.glite.lb.server/src/ws_typeref.c.T index d681dd3..d2aa5cb 100644 --- a/org.glite.lb.server/src/ws_typeref.c.T +++ b/org.glite.lb.server/src/ws_typeref.c.T @@ -418,7 +418,7 @@ int edg_wll_JobStatFlagsToSoap(struct soap *soap, const int in, struct lbt__jobF int edg_wll_SoapToAttr(const enum lbt__queryAttr in, edg_wll_QueryAttr *out) { - assert(EDG_WLL_QUERY_ATTR_JOB_TYPE + 1 == EDG_WLL_QUERY_ATTR__LAST); + assert(EDG_WLL_QUERY_ATTR_VM_STATUS + 1 == EDG_WLL_QUERY_ATTR__LAST); switch ( in ) { @@ -444,6 +444,7 @@ int edg_wll_SoapToAttr(const enum lbt__queryAttr in, edg_wll_QueryAttr *out) case LASTUPDATETIME: *out = EDG_WLL_QUERY_ATTR_LASTUPDATETIME; break; case NETWORKSERVER: *out = EDG_WLL_QUERY_ATTR_NETWORK_SERVER; break; case JOBTYPE: *out = EDG_WLL_QUERY_ATTR_JOB_TYPE; break; + case VM_STATUS: *out = EDG_WLL_QUERY_ATTR_VM_STATUS; break; default: return 0; } @@ -452,7 +453,7 @@ int edg_wll_SoapToAttr(const enum lbt__queryAttr in, edg_wll_QueryAttr *out) int edg_wll_AttrToSoap(const edg_wll_QueryAttr in, enum lbt__queryAttr *out) { - assert(EDG_WLL_QUERY_ATTR_JOB_TYPE + 1 == EDG_WLL_QUERY_ATTR__LAST); + assert(EDG_WLL_QUERY_ATTR_VM_STATUS + 1 == EDG_WLL_QUERY_ATTR__LAST); switch ( in ) { @@ -478,6 +479,7 @@ int edg_wll_AttrToSoap(const edg_wll_QueryAttr in, enum lbt__queryAttr *out) case EDG_WLL_QUERY_ATTR_LASTUPDATETIME: *out = LASTUPDATETIME; break; case EDG_WLL_QUERY_ATTR_NETWORK_SERVER: *out = NETWORKSERVER; break; case EDG_WLL_QUERY_ATTR_JOB_TYPE: *out = JOBTYPE; break; + case EDG_WLL_QUERY_ATTR_VM_STATUS: *out = VM_STATUS; break; default: return 0; } @@ -578,6 +580,7 @@ int edg_wll_QueryValToSoap( case EDG_WLL_QUERY_ATTR_RESUBMITTED: case EDG_WLL_QUERY_ATTR_EXITCODE: case EDG_WLL_QUERY_ATTR_JOB_TYPE: + case EDG_WLL_QUERY_ATTR_VM_STATUS: VALUEQR_SET(out, i, soap_malloc(soap, sizeof(*(VALUEQR_GET(out, i))))); if ( !VALUEQR_GET(out, i) ) return SOAP_FAULT; *(VALUEQR_GET(out, i)) = in->i; -- 1.8.2.3