From: Jiří Filipovič Date: Fri, 31 Aug 2012 09:29:05 +0000 (+0000) Subject: - added RSS feed runningVM X-Git-Tag: glite-lb-client_R_5_2_4_1~12 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=6f6066b959e588bcd9a76ccff66c7dc8f4ef16c8;p=jra1mw.git - added RSS feed runningVM - fix bug (malformed RSS when destination is unknown), more robust feed recognition --- diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c index 12e3c55..4e7b647 100644 --- a/org.glite.lb.server/src/lb_proto.c +++ b/org.glite.lb.server/src/lb_proto.c @@ -352,7 +352,7 @@ static int getJobsRSS(edg_wll_Context ctx, char *feedType, edg_wll_JobStat **sta char *can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0); - if (strncmp(feedType, "finished", strlen("finished")) == 0){ + if (strcmp(feedType, "finished") == 0){ conds = malloc(4*sizeof(*conds)); conds[0] = malloc(2*sizeof(**conds)); conds[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER; @@ -378,7 +378,32 @@ static int getJobsRSS(edg_wll_Context ctx, char *feedType, edg_wll_JobStat **sta conds[2][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; conds[3] = NULL; } - else if (strncmp(feedType, "running", strlen("running")) == 0){ + else if (strcmp(feedType, "runningVM") == 0){ + conds = malloc(5*sizeof(*conds)); + conds[0] = malloc(2*sizeof(**conds)); + conds[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER; + conds[0][0].op = EDG_WLL_QUERY_OP_EQUAL; + conds[0][0].value.c = can_peername; + conds[0][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + conds[1] = malloc(2*sizeof(**conds)); + conds[1][0].attr = EDG_WLL_QUERY_ATTR_STATUS; + conds[1][0].op = EDG_WLL_QUERY_OP_EQUAL; + conds[1][0].value.i = EDG_WLL_JOB_RUNNING; + conds[1][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + conds[2] = malloc(2*sizeof(**conds)); + conds[2][0].attr = EDG_WLL_QUERY_ATTR_LASTUPDATETIME; + conds[2][0].op = EDG_WLL_QUERY_OP_GREATER; + conds[2][0].value.t.tv_sec = time(NULL) - ctx->rssTime; + conds[2][0].value.t.tv_usec = 0; + conds[2][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + conds[3] = malloc(2*sizeof(**conds)); + conds[3][0].attr = EDG_WLL_QUERY_ATTR_JOB_TYPE; + conds[3][0].op = EDG_WLL_QUERY_OP_EQUAL; + conds[3][0].value.i = EDG_WLL_STAT_VIRTUAL_MACHINE; + conds[3][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + conds[4] = NULL; + } + else if (strcmp(feedType, "running") == 0){ conds = malloc(4*sizeof(*conds)); conds[0] = malloc(2*sizeof(**conds)); conds[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER; @@ -398,7 +423,7 @@ static int getJobsRSS(edg_wll_Context ctx, char *feedType, edg_wll_JobStat **sta conds[2][1].attr = EDG_WLL_QUERY_ATTR_UNDEF; conds[3] = NULL; } - else if (strncmp(feedType, "aborted", strlen("aborted")) == 0){ + else if (strcmp(feedType, "aborted") == 0){ conds = malloc(4*sizeof(*conds)); conds[0] = malloc(2*sizeof(**conds)); conds[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER; @@ -1045,11 +1070,14 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, int i; int idx; - feedType = requestPTR + strlen("/RSS:"); + feedType = strdup(requestPTR + strlen("/RSS:")); + feedType[strrchr(feedType, ' ')-feedType] = 0; if (getJobsRSS(ctx, feedType, &states) < 0){ ret = HTTP_INTERNAL; + free(feedType); goto err; } + free(feedType); // check if owner and lastupdatetime is indexed idx = 0; diff --git a/org.glite.lb.server/src/lb_rss.c b/org.glite.lb.server/src/lb_rss.c index 8b488e1..29edd44 100644 --- a/org.glite.lb.server/src/lb_rss.c +++ b/org.glite.lb.server/src/lb_rss.c @@ -79,8 +79,8 @@ int edg_wll_RSSFeed(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat *states, cha time = states[i].stateEnterTime.tv_sec; TR("State entered: %s\n", ctime(&time)); TRC("]]>\n"); - TR("Destination: %s\n", states[i].destination); - TRC("\n"); + TR("Destination: %s\n", states[i].destination); + TRC("\n\n"); free(chid);