CREAM jobs in html interface.
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 11 Sep 2009 13:21:46 +0000 (13:21 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 11 Sep 2009 13:21:46 +0000 (13:21 +0000)
org.glite.lb.server/src/lb_html.c
org.glite.lb.server/src/lb_html.h
org.glite.lb.server/src/lb_proto.c

index 72bd295..7cb3f59 100644 (file)
@@ -178,7 +178,7 @@ int edg_wll_NotificationToHTML(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, ch
 }
 
 /* construct Message-Body of Response-Line for edg_wll_JobStatus */
-int edg_wll_JobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat, char **message)
+int edg_wll_GeneralJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat, char **message)
 {
         char *pomA = NULL, *pomB = NULL;
        int pomL = 0;
@@ -192,7 +192,7 @@ int edg_wll_JobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat
 
        TR("Status","%s",(chstat = edg_wll_StatToString(stat.state)));
        free(chstat);
-       TR("owner","%s",stat.owner);
+       TR("Owner","%s",stat.owner);
        TR("Condor Id","%s",stat.condorId);
        TR("Globus Id","%s",stat.globusId);
        TR("Local Id","%s",stat.localId);
@@ -251,6 +251,52 @@ int edg_wll_JobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat
         return 0;
 }
 
+int edg_wll_CreamJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat, char **message)
+{
+       char *chid, *pomA = NULL, *pomB = NULL, *jdl;
+       int pomL = 0;
+
+       jdl = strdup("");
+
+       chid = edg_wlc_JobIdUnparse(stat.jobId);
+
+       TR("Status", "%s", edg_wll_CreamStatToString(stat.cream_state));
+       TR("Owner", "%s", stat.cream_owner);
+       TR("Endpoint", "%s", stat.cream_endpoint);
+       TR("Reason", "%s", stat.cream_reason);
+       TR("LRMS id", "%s", stat.cream_lrms_id);
+       TR("Node", "%s", stat.cream_node);
+       TR("Cancelling", "%s", stat.cream_cancelling > 0 ? "YES" : "NO");
+       TR("CPU time", "%d", stat.cream_cpu_time);
+       TR("Done code", "%d", stat.cream_done_code);
+        TR("Exit code", "%d", stat.cream_exit_code);
+
+       /*
+                cream_jw_status
+        */
+       
+       if (stat.jdl){
+                char *jdl_unp;
+                if (pretty_print(stat.jdl, &jdl_unp) == 0)
+                        asprintf(&jdl,"<h3>Job description</h3>\r\n"
+                                "<pre>%s</pre>\r\n",jdl_unp);
+                else
+                        asprintf(&jdl,"<h3>Job description (not a ClassAd)"
+                                "</h3>\r\n<pre>%s</pre>\r\n",stat.jdl);
+        }
+        asprintf(&pomA, "<html>\r\n\t<body>\r\n"
+                        "<h2>%s</h2>\r\n"
+                        "<table halign=\"left\">%s</table>"
+                        "%s"
+                        "\t</body>\r\n</html>",
+                        chid,pomB,jdl);
+        free(pomB); free(jdl);
+
+        *message = pomA;
+
+       return 0;
+}
+
 char *edg_wll_ErrorToHTML(edg_wll_Context ctx,int code)
 {
        char    *out,*et,*ed;
index ac1d0e1..40ab712 100644 (file)
@@ -9,7 +9,8 @@
 #include "lb_proto.h"
 
 int edg_wll_QueryToHTML(edg_wll_Context,edg_wll_Event *,char **);
-int edg_wll_JobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **);
+int edg_wll_GeneralJobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **);
+int edg_wll_CreamJobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **);
 int edg_wll_UserInfoToHTML(edg_wll_Context, edg_wlc_JobId *, char **);
 int edg_wll_UserNotifsToHTML(edg_wll_Context ctx, char **notifids, char **message);
 int edg_wll_NotificationToHTML(edg_wll_Context ctx, notifInfo *ni, char **message);
index 6086e61..f014a6c 100644 (file)
@@ -687,7 +687,16 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                case 0: if (text) 
                                                edg_wll_JobStatusToText(ctx,stat,&message); 
                                        else if (html)
-                                               edg_wll_JobStatusToHTML(ctx,stat,&message);
+                                               switch(stat.jobtype){
+                                               case EDG_WLL_STAT_CREAM:
+                                                       edg_wll_CreamJobStatusToHTML(ctx,stat,&message);
+                                                       break;
+                                               default:
+                                                       //XXX need some more implementations
+                                                       edg_wll_GeneralJobStatusToHTML(ctx,stat,&message);
+                                                       break;
+                                               }
+                                       
                                        else ret = HTTP_OK;
                                        break;
                                case ENOENT: ret = HTTP_NOTFOUND; break;