- added RSS feed runningVM
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 31 Aug 2012 09:29:05 +0000 (09:29 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 31 Aug 2012 09:29:05 +0000 (09:29 +0000)
- fix bug (malformed RSS when destination is unknown), more robust feed recognition

org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_rss.c

index 12e3c55..4e7b647 100644 (file)
@@ -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;
index 8b488e1..29edd44 100644 (file)
@@ -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("<![CDATA[<br/>]]>\n");
-               TR("Destination: %s</description>\n", states[i].destination);
-               TRC("</item>\n");
+               TR("Destination: %s\n", states[i].destination);
+               TRC("</description>\n</item>\n");
                
                
                free(chid);