second revision of filling the glue2 attributes, should be all for now (only resource...
authorJan Pospíšil <honik@ntc.zcu.cz>
Tue, 9 Mar 2010 21:17:36 +0000 (21:17 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Tue, 9 Mar 2010 21:17:36 +0000 (21:17 +0000)
org.glite.lb.server/src/ws_lb4agu.c

index 15cb889..16d6f56 100644 (file)
@@ -57,7 +57,6 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb4agu__GetActivityStatus(
                        return SOAP_FAULT;
                }
 
-               /* FIXME: what are the flags? */
                flags = 0;
                if (debug) {
                        char *cjobid = NULL, *cflags = NULL;
@@ -98,65 +97,68 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb4agu__GetActivityStatus(
  */
 static int edg_wll_JobStatusToGlueComputingActivity(
        struct soap *soap,
-       edg_wll_JobStat const *src,
+       edg_wll_JobStat *src,
        struct glue__ComputingActivity_USCOREt *js)
 {
-        //int     i,j;
-        char    buf[1000],*s = NULL;
+        int     i;
+        char    buf[1000],*s = NULL,*aux,*aux2;
 
        memset(js, 0, sizeof(*js));
+
        // ID (required, glue:ID_t) = jobId
        s = edg_wlc_JobIdUnparse(src->jobId); 
        js->ID = soap_strdup(soap,s); 
        free(s); s=NULL;
 
-       // BaseType (required, xsd:string) = type of job?
-       // how does it differ from Type?
-       js->BaseType = soap_lbt__RegJobJobtype2s(soap,src->jobtype);
+       // BaseType (required, xsd:string) = "Activity"?
+       js->BaseType = soap_strdup(soap,"Activity");
 
        // CreationTime (optional, xsd:dateTime) = submission time?
-       js->CreationTime = src->stateEnterTimes[1+EDG_WLL_JOB_SUBMITTED];
+       js->CreationTime = soap_malloc(soap,sizeof *js->CreationTime);
+       *js->CreationTime = src->stateEnterTimes[1+EDG_WLL_JOB_SUBMITTED];
 
-       // Validity (optional, xsd:unsignedLong) = ?
+       // Validity (optional, xsd:unsignedLong) = N/A
        js->Validity = 0;
 
-       // Name (optional, xsd:string) = ?
+       // Name (optional, xsd:string) = N/A
        js->Name = NULL;
 
-       // Type (optional, glue:ComputingActivityType_t) = jobtype ?
+       // Type (optional, glue:ComputingActivityType_t) = jobtype?
        // see glue__ComputingActivityType_USCOREt
+       js->Type = soap_malloc(soap,sizeof *js->Type);
        switch (src->jobtype) {
                case EDG_WLL_STAT_SIMPLE:
-                       js->Type = glue__ComputingActivityType_USCOREt__single;
+                       *js->Type = src->parent_job ? 
+                               glue__ComputingActivityType_USCOREt__collectionelement :
+                               glue__ComputingActivityType_USCOREt__single;
                        break;
                case EDG_WLL_STAT_DAG:
-                       js->Type = glue__ComputingActivityType_USCOREt__parallelelement;
-                       break;
                case EDG_WLL_STAT_COLLECTION:
-                       js->Type = glue__ComputingActivityType_USCOREt__collectionelement;
+               case EDG_WLL_STAT_FILE_TRANSFER_COLLECTION:
+                       *js->Type = glue__ComputingActivityType_USCOREt__single; /* XXX: no equivalent in glue */
                        break;
                case EDG_WLL_STAT_PBS:
                case EDG_WLL_STAT_CONDOR:
                case EDG_WLL_STAT_CREAM:
                case EDG_WLL_STAT_FILE_TRANSFER:
-               case EDG_WLL_STAT_FILE_TRANSFER_COLLECTION:
-                       js->Type = glue__ComputingActivityType_USCOREt__workflownode;
+                       *js->Type = glue__ComputingActivityType_USCOREt__single;
                        break;
                default:
-                       js->Type = glue__ComputingActivityType_USCOREt__single;
+                       *js->Type = glue__ComputingActivityType_USCOREt__single;
                        break;
        }
 
-       // IDFromEndpoint (required, xsd:anyURI) = destination CE?
-       js->IDFromEndpoint = soap_strdup(soap,src->destination);
+       // IDFromEndpoint (required, xsd:anyURI) = globusId?
+       // TODO: put CREAM id here once it's available
+       js->IDFromEndpoint = soap_strdup(soap,src->globusId);
 
-       // LocalIDFromManager (optional, xsd:string) = localId?
+       // LocalIDFromManager (optional, xsd:string) = localId
        js->LocalIDFromManager = soap_strdup(soap,src->localId);
 
-       // JobDescription (required, glue:JobDescription_t) = matched_jdl ?
+       // JobDescription (required, glue:JobDescription_t) = matched_jdl
        js->JobDescription = soap_strdup(soap,src->matched_jdl);
 
-       // State (required, glue:ComputingActivityState_t) = job state?
+       // State (required, glue:ComputingActivityState_t) = state
        // i.e. job status with buf,LB_GLUE_STATE_PREFIX?
        s = edg_wll_StatToString(src->state); 
        snprintf(buf,sizeof buf,LB_GLUE_STATE_PREFIX ":%s",s);
@@ -164,114 +166,186 @@ static int edg_wll_JobStatusToGlueComputingActivity(
        js->State = soap_strdup(soap,buf);
        free(s); s = NULL;
 
-       // RestartState (optional, glue:ComputingActivityState_t) = ?
+       // RestartState (optional, glue:ComputingActivityState_t) = N/A
        js->RestartState = NULL;
 
-       // ExitCode (optional, xsd:int) = ?
-       js->ExitCode = 0;
+       // ExitCode (optional, xsd:int) 
+       js->ExitCode = soap_malloc(soap,sizeof *js->ExitCode);
+       *js->ExitCode = src->exit_code;
 
-       // ComputingManagerExitCode (optional, xsd:string) = ?
-       js->ComputingManagerExitCode = NULL;
+       // ComputingManagerExitCode (optional, xsd:string) = done_code
+       s=edg_wll_DoneStatus_codeToString(src->done_code);
+       js->ComputingManagerExitCode = soap_strdup(soap,s);
+       free(s); s=NULL;
 
-       // Error (optional, xsd:string) = failure_reasons?
-       js->__sizeError = sizeof(src->failure_reasons);
-       js->Error = soap_strdup(soap,src->failure_reasons);
+       // Error (optional, xsd:string) = failure_reasons
+       if (src->failure_reasons) {
+               js->__sizeError = 1;
+               js->Error = soap_malloc(soap,sizeof js->Error[0]);
+               js->Error[0] = soap_strdup(soap,src->failure_reasons);
+       } else {
+               js->__sizeError = 0;
+               js->Error = NULL;
+       }
 
-       // WaitingPosition (optional, xsd:unsignedInt) = ?
+       // WaitingPosition (optional, xsd:unsignedInt) = N/A
        js->WaitingPosition = 0;
 
-       // UserDomain (optional, xsd:string) = ?
-       js->UserDomain = NULL;
+       // UserDomain (optional, xsd:string) = user_fqans?
+       if (src->user_fqans) {
+               aux2 = strdup("");
+               for (i=0; src->user_fqans && src->user_fqans[i]; i++) {
+                       asprintf(&aux,"%s\n%s",aux2,src->user_fqans[i]);
+                       free(aux2); aux2 = aux; aux = NULL;
+               }
+               js->UserDomain = soap_strdup(soap,aux2);
+               free(aux2); aux2 = NULL;
+       } else js->UserDomain = NULL;
 
-       // Owner (required, xsd:string) = ?
+       // Owner (required, xsd:string) = owner
        js->Owner = soap_strdup(soap,src->owner);
 
-       // LocalOwner (optional, xsd:string) = ?
+       // LocalOwner (optional, xsd:string) = N/A
        js->LocalOwner = NULL;
 
-       // RequestedTotalWallTime (optional, xsd:unsignedLong) = ?
-       // from JDL?
+       // RequestedTotalWallTime (optional, xsd:unsignedLong) = N/A
        js->RequestedTotalWallTime = NULL;
 
-       // RequestedTotalCPUTime (optional, xsd:unsignedLong) = ?
-       // from JDL?
+       // RequestedTotalCPUTime (optional, xsd:unsignedLong) = N/A
        js->RequestedTotalCPUTime = 0;
 
-       // RequestedSlots (optional, xsd:unsignedInt) = ?
-       // from JDL?
-       js->RequestedSlots = 0;
+       // RequestedSlots (optional, xsd:unsignedInt) = NodeNumber from JDL
+       s = edg_wll_JDLField(src,"NodeNumber");
+       js->RequestedSlots = soap_malloc(soap,sizeof *js->RequestedSlots);
+       *js->RequestedSlots = s ? atoi(s) : 1;
+       free(s); s = NULL;
 
-       // RequestedApplicationEnvironment = ?
+       // RequestedApplicationEnvironment = N/A
        js->__sizeRequestedApplicationEnvironment = 0;
        js->RequestedApplicationEnvironment = NULL;
 
-       // StdIn (optional, xsd:string) = ?
-       js->StdIn = NULL;
+       // StdIn (optional, xsd:string) = StdInput from JDL
+       if ((s = edg_wll_JDLField(src,"StdInput"))) js->StdIn = soap_strdup(soap,s);
+       free(s); s = NULL;
 
-       // StdOut (optional, xsd:string) = ?
-       js->StdOut = NULL;
+       // StdOut (optional, xsd:string) = StdOutput from JDL
+       if ((s = edg_wll_JDLField(src,"StdOutput"))) js->StdOut = soap_strdup(soap,s);
+       free(s); s = NULL;
 
-       // StdErr (optional, xsd:string) = ?
-       js->StdErr = NULL; 
+       // StdErr (optional, xsd:string) = StdError from JDL
+       if ((s = edg_wll_JDLField(src,"StdError"))) js->StdErr = soap_strdup(soap,s);
+       free(s); s = NULL;
 
-       // LogDir (optional, xsd:string) = ?
+       // LogDir (optional, xsd:string) = N/A
        js->LogDir = NULL;
 
        // ExecutionNode (optional, xsd:string) = ce_node?
-       js->__sizeExecutionNode = sizeof(src->ce_node);
-       js->ExecutionNode = soap_strdup(soap,src->ce_node);
+       if (src->ce_node) {
+               js->__sizeExecutionNode = 1;
+               js->ExecutionNode = soap_malloc(soap,sizeof js->ExecutionNode[0]);
+               js->ExecutionNode[0] = soap_strdup(soap,src->ce_node);
+       } else {
+               js->__sizeExecutionNode = 0;
+               js->ExecutionNode = NULL;
+       }
 
-       // Queue (optional, xsd:string) = ?
-       js->Queue = NULL;
+       // Queue (optional, xsd:string) = destination (ID of CE where the job is being sent)?
+       js->Queue = soap_strdup(soap,src->destination);
 
-       // UsedTotalWallTime (optional, xsd:unsignedLong) = ?
+       // UsedTotalWallTime (optional, xsd:unsignedLong) = N/A
+       // TODO: put resource usage once available
        js->UsedTotalWallTime = 0;
 
        // UsedTotalCPUTime (optional, xsd:unsignedLong) = cpuTime?
-       js->UsedTotalCPUTime = src->cpuTime;
+       // TODO: put resource usage once available
+       js->UsedTotalCPUTime = soap_malloc(soap,sizeof *js->UsedTotalCPUTime);
+       *js->UsedTotalCPUTime = src->cpuTime;
 
-       // UsedMainMemory (optional, xsd:unsignedLong) = ?
+       // UsedMainMemory (optional, xsd:unsignedLong) = N/A
+       // TODO: put resource usage once available
        js->UsedMainMemory = 0;
 
-       // SubmissionTime (optional, xsd:dateTime) = time of JOB_SUBMITTED?
-       // how does it differ from the CreationTime?
-       js->SubmissionTime = src->stateEnterTimes[1+EDG_WLL_JOB_SUBMITTED];
-
-       // ComputingManagerSubmissionTime (optional, xsd:dateTime) = time of JOB_SCHEDULED?
-       js->ComputingManagerSubmissionTime = src->stateEnterTimes[1+EDG_WLL_JOB_SCHEDULED];
-
-       // StartTime (optional, xsd:dateTime) = time of JOB_RUNNING?
-       js->StartTime = src->stateEnterTimes[1+EDG_WLL_JOB_RUNNING];
-
-       // ComputingManagerEndTime (optional, xsd:dateTime) = ?
-       js->ComputingManagerEndTime = 0;
-
-       // EndTime (optional, xsd:dateTime) = time of JOB_DONE?
-       js->EndTime = src->stateEnterTimes[1+EDG_WLL_JOB_DONE];
-
-       // WorkingAreaEraseTime (optional, xsd:dateTime) = time of JOB_CLEARED?
-       js->WorkingAreaEraseTime = src->stateEnterTimes[1+EDG_WLL_JOB_CLEARED];
-
-       // ProxyExpirationTime (optional, xsd:dateTime) = ?
+       // SubmissionTime (optional, xsd:dateTime) = time of JOB_WAITING
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_WAITING]) {
+               js->SubmissionTime = soap_malloc(soap,sizeof *js->SubmissionTime);
+               *js->SubmissionTime = src->stateEnterTimes[1+EDG_WLL_JOB_WAITING];
+       } else js->SubmissionTime = NULL;
+
+       // ComputingManagerSubmissionTime (optional, xsd:dateTime) = time of JOB_SCHEDULED
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_SCHEDULED]) {
+               js->ComputingManagerSubmissionTime = soap_malloc(soap,sizeof *js->ComputingManagerSubmissionTime);
+               *js->ComputingManagerSubmissionTime = src->stateEnterTimes[1+EDG_WLL_JOB_SCHEDULED];
+       } else js->ComputingManagerSubmissionTime = NULL;
+
+       // StartTime (optional, xsd:dateTime) = time of JOB_RUNNING
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_RUNNING]) {
+               js->StartTime = soap_malloc(soap,sizeof *js->StartTime);
+               *js->StartTime = src->stateEnterTimes[1+EDG_WLL_JOB_RUNNING];
+       } else js->StartTime = NULL;
+
+       // ComputingManagerEndTime (optional, xsd:dateTime) = time of JOB_DONE?
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_DONE]) {
+               js->ComputingManagerEndTime = soap_malloc(soap,sizeof *js->ComputingManagerEndTime);
+               *js->ComputingManagerEndTime = src->stateEnterTimes[1+EDG_WLL_JOB_DONE];
+       } else js->ComputingManagerEndTime = NULL;
+
+       // EndTime (optional, xsd:dateTime) = time of JOB_DONE
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_DONE]) {
+               js->EndTime = soap_malloc(soap,sizeof *js->EndTime);
+               *js->EndTime = src->stateEnterTimes[1+EDG_WLL_JOB_DONE];
+       } else js->EndTime = NULL;
+
+       // WorkingAreaEraseTime (optional, xsd:dateTime) = time of JOB_CLEARED
+       if (src->stateEnterTimes[1+EDG_WLL_JOB_CLEARED]) {
+               js->WorkingAreaEraseTime = soap_malloc(soap,sizeof *js->WorkingAreaEraseTime);
+               *js->WorkingAreaEraseTime = src->stateEnterTimes[1+EDG_WLL_JOB_CLEARED];
+       } else js->WorkingAreaEraseTime = NULL;
+
+       // ProxyExpirationTime (optional, xsd:dateTime) = N/A
        js->ProxyExpirationTime = 0;
 
-       // SubmissionHost (optional, xsd:string) = ui_host?
+       // SubmissionHost (optional, xsd:string) = ui_host
        js->SubmissionHost = soap_strdup(soap,src->ui_host);
 
-       // SubmissionClientName (optional, xsd:string) = ?
+       // SubmissionClientName (optional, xsd:string) = N/A
        js->SubmissionClientName = NULL;
 
        // OtherMessages (optional, xsd:string) = reason?
-       js->__sizeOtherMessages = sizeof(src->reason);
-       js->OtherMessages = soap_strdup(soap,src->reason);
+       if (src->reason) {
+               js->__sizeOtherMessages = 1;
+               js->OtherMessages = soap_malloc(soap,sizeof js->OtherMessages[0]);
+               js->OtherMessages[0] = soap_strdup(soap,src->reason);
+       } else {
+               js->__sizeOtherMessages = 0;
+               js->OtherMessages = NULL;
+       }
 
        // Extensions (optional, glue:Extensions_t) =  user tags?
        // see glue__Extensions_USCOREt structure
-       js->Extensions = NULL;
+       if (src->user_tags) {
+               js->Extensions = soap_malloc(soap,sizeof *js->Extensions);
+               for (i=0; src->user_tags[i].tag; i++);
+               js->Extensions->__sizeExtension = i;
+               js->Extensions->Extension = soap_malloc(soap,i*sizeof js->Extensions->Extension[0]);
+
+               for (i=0; src->user_tags[i].tag; i++) {
+                       js->Extensions->Extension[i].Key = soap_strdup(soap,src->user_tags[i].tag);
+                       js->Extensions->Extension[i].__item = soap_strdup(soap,src->user_tags[i].value);
+               }
+       }
+       else js->Extensions = NULL;
 
        // Associations (optional, glue:ComputingActivity_t-Associations) = subjobs?
        // see _glue__ComputingActivity_USCOREt_Associations structure
-       js->Associations = NULL;
+       if (src->children_num) {
+               js->Associations = soap_malloc(soap,sizeof *js->Associations);
+               memset(js->Associations,0,sizeof *js->Associations);
+               js->Associations->__sizeActivityID = src->children_num;
+               js->Associations->ActivityID = soap_malloc(soap,src->children_num * sizeof js->Associations->ActivityID[0]);
+               for (i=0; src->children[i]; i++) js->Associations->ActivityID[i] = soap_strdup(soap,src->children[i]);
+       }
+       else js->Associations = NULL;
+
 
        return SOAP_OK;
 }
@@ -302,8 +376,6 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb4agu__GetActivityInfo(
        if (!in) return SOAP_FAULT;
        if (!in->id) return SOAP_FAULT;
 
-       out = soap_malloc(soap, sizeof(*out));
-
        GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, status, struct glue__ComputingActivity_USCOREt, in->__sizeid);
 
        /* process each request individually: */
@@ -316,8 +388,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb4agu__GetActivityInfo(
                        return SOAP_FAULT;
                }
 
-               /* FIXME: what are the flags? */
-               flags = 0;
+               flags = EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN;
                if (debug) {
                        char *cjobid = NULL, *cflags = NULL;
 
@@ -344,7 +415,6 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb4agu__GetActivityInfo(
                }
        }
        out->__sizestatus = in->__sizeid;
-       GLITE_SECURITY_GSOAP_LIST_DESTROY(soap, out, status);
 
        return SOAP_OK;
 }