You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(7) |
Feb
|
Mar
|
Apr
(6) |
May
(14) |
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
|
2009 |
Jan
(3) |
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(5) |
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(9) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <tm...@us...> - 2011-08-04 08:20:01
|
Revision: 92 http://bespp.svn.sourceforge.net/bespp/?rev=92&view=rev Author: tmetsch Date: 2011-08-04 08:19:55 +0000 (Thu, 04 Aug 2011) Log Message: ----------- can't test locally need to submit to test on cluster...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 08:17:32 UTC (rev 91) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:19:55 UTC (rev 92) @@ -738,8 +738,9 @@ char *nstr; int i; - nstr = soap_strdup(s, JSDL_HPCPA_NS); + nstr = soap_strdup(s, JSDL_POSIX_NS); if (!nstr) { + fprintf(stderr, "returning with NULL %s...\n", nstr); return NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 08:17:38
|
Revision: 91 http://bespp.svn.sourceforge.net/bespp/?rev=91&view=rev Author: tmetsch Date: 2011-08-04 08:17:32 +0000 (Thu, 04 Aug 2011) Log Message: ----------- test...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 08:15:17 UTC (rev 90) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:17:32 UTC (rev 91) @@ -1186,7 +1186,6 @@ getJSDLFromJobInfo(struct soap *s, struct jobcard *job, struct jsdl__JobDefinition_USCOREType **jsdl_return) { - static char fname[] = "__job__getJSDLFromJobInfo"; struct jsdl__JobDefinition_USCOREType *jsdl; struct jsdl__JobDescription_USCOREType *jdesc; struct jsdl__JobIdentification_USCOREType *ident; @@ -1201,7 +1200,6 @@ if (!job || !jsdl_return) { return SOAP_OK; } - fprintf(stderr, "In %s...\n", fname); jsdl = (struct jsdl__JobDefinition_USCOREType*)soap_malloc(s, sizeof(struct jsdl__JobDefinition_USCOREType)); @@ -1271,23 +1269,18 @@ *res->jsdl__ExclusiveExecution = true_; } jdesc->jsdl__Resources = res; - - fprintf(stderr, "In %s...\n", fname); app->__any = getHPCProfileApplication(s, job); if (app->__any == NULL) { // try POSIX app - printf("-%s\n", app); app->__any == getPOSIXApplication(s, job); - printf("-%s\n", app); if (app->__any == NULL) { return soap_receiver_fault(s, MEM_ALLOC, NULL); } - printf("-%s\n", app); } jdesc->jsdl__Application = app; - fprintf(stderr, "In %s...\n", app); + fprintf(stderr, "app %s...\n", app); jsdl->jsdl__JobDescription = jdesc; *jsdl_return = jsdl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 08:15:23
|
Revision: 90 http://bespp.svn.sourceforge.net/bespp/?rev=90&view=rev Author: tmetsch Date: 2011-08-04 08:15:17 +0000 (Thu, 04 Aug 2011) Log Message: ----------- test...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 08:14:04 UTC (rev 89) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:15:17 UTC (rev 90) @@ -1287,7 +1287,7 @@ } jdesc->jsdl__Application = app; - fprintf(stderr, "In %s...\n", fname); + fprintf(stderr, "In %s...\n", app); jsdl->jsdl__JobDescription = jdesc; *jsdl_return = jsdl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 08:14:10
|
Revision: 89 http://bespp.svn.sourceforge.net/bespp/?rev=89&view=rev Author: tmetsch Date: 2011-08-04 08:14:04 +0000 (Thu, 04 Aug 2011) Log Message: ----------- test...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 08:09:34 UTC (rev 88) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:14:04 UTC (rev 89) @@ -1186,6 +1186,7 @@ getJSDLFromJobInfo(struct soap *s, struct jobcard *job, struct jsdl__JobDefinition_USCOREType **jsdl_return) { + static char fname[] = "__job__getJSDLFromJobInfo"; struct jsdl__JobDefinition_USCOREType *jsdl; struct jsdl__JobDescription_USCOREType *jdesc; struct jsdl__JobIdentification_USCOREType *ident; @@ -1200,6 +1201,7 @@ if (!job || !jsdl_return) { return SOAP_OK; } + fprintf(stderr, "In %s...\n", fname); jsdl = (struct jsdl__JobDefinition_USCOREType*)soap_malloc(s, sizeof(struct jsdl__JobDefinition_USCOREType)); @@ -1270,6 +1272,8 @@ } jdesc->jsdl__Resources = res; + fprintf(stderr, "In %s...\n", fname); + app->__any = getHPCProfileApplication(s, job); if (app->__any == NULL) { // try POSIX app @@ -1283,6 +1287,7 @@ } jdesc->jsdl__Application = app; + fprintf(stderr, "In %s...\n", fname); jsdl->jsdl__JobDescription = jdesc; *jsdl_return = jsdl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 08:09:40
|
Revision: 88 http://bespp.svn.sourceforge.net/bespp/?rev=88&view=rev Author: tmetsch Date: 2011-08-04 08:09:34 +0000 (Thu, 04 Aug 2011) Log Message: ----------- test...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 08:03:27 UTC (rev 87) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:09:34 UTC (rev 88) @@ -1273,10 +1273,13 @@ app->__any = getHPCProfileApplication(s, job); if (app->__any == NULL) { // try POSIX app + printf("-%s\n", app); app->__any == getPOSIXApplication(s, job); + printf("-%s\n", app); if (app->__any == NULL) { return soap_receiver_fault(s, MEM_ALLOC, NULL); } + printf("-%s\n", app); } jdesc->jsdl__Application = app; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 08:03:33
|
Revision: 87 http://bespp.svn.sourceforge.net/bespp/?rev=87&view=rev Author: tmetsch Date: 2011-08-04 08:03:27 +0000 (Thu, 04 Aug 2011) Log Message: ----------- test...(I know this is hacking - but who uses this code anyhow?) Modified Paths: -------------- branches/posix_app_support/besserver/job.c Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-04 06:53:27 UTC (rev 86) +++ branches/posix_app_support/besserver/job.c 2011-08-04 08:03:27 UTC (rev 87) @@ -733,6 +733,176 @@ } struct soap_dom_element * +getPOSIXApplication(struct soap *s, struct jobcard *job) { + struct soap_dom_element *dom, *cur, *next; + char *nstr; + int i; + + nstr = soap_strdup(s, JSDL_HPCPA_NS); + if (!nstr) { + return NULL; + } + + dom = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (!dom) { + return NULL; + } + memset(dom, 0, sizeof(struct soap_dom_element)); + dom->nstr = nstr; + dom->name = soap_strdup(s, "POSIXApplication"); + if (!dom->name) { + return NULL; + } + + cur = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (cur == NULL) { + return NULL; + } + memset(cur, 0, sizeof(struct soap_dom_element)); + cur->nstr = nstr; + cur->prnt = dom; + cur->name = soap_strdup(s, "Executable"); + if (!cur->name) { + return NULL; + } + cur->data = soap_strdup(s, job->executable); + if (!cur->data) { + return NULL; + } + dom->elts = cur; + + for (i = 0; i < job->num_args; i++ ) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "Argument"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->args[i]); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + if (job->input) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "Input"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->input); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + if (job->output) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "Output"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->output); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + if (job->error) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "Error"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->error); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + if (job->wd) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "WorkingDirectory"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->wd); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + if (job->username) { + next = (struct soap_dom_element*)soap_malloc(s, + sizeof(struct soap_dom_element)); + if (next == NULL) { + return NULL; + } + memset(next, 0, sizeof(struct soap_dom_element)); + next->nstr = nstr; + next->prnt = dom; + next->name = soap_strdup(s, "UserName"); + if (!next->name) { + return NULL; + } + next->data = soap_strdup(s, job->username); + if (!next->data) { + return NULL; + } + cur->next = next; + cur = next; + } + + return dom; +} + +struct soap_dom_element * getHPCProfileApplication(struct soap *s, struct jobcard *job) { struct soap_dom_element *dom, *cur, *next; @@ -1102,7 +1272,11 @@ app->__any = getHPCProfileApplication(s, job); if (app->__any == NULL) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); + // try POSIX app + app->__any == getPOSIXApplication(s, job); + if (app->__any == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } } jdesc->jsdl__Application = app; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-04 06:53:33
|
Revision: 86 http://bespp.svn.sourceforge.net/bespp/?rev=86&view=rev Author: tmetsch Date: 2011-08-04 06:53:27 +0000 (Thu, 04 Aug 2011) Log Message: ----------- second shot Modified Paths: -------------- branches/posix_app_support/Make.config branches/posix_app_support/besserver/job.c branches/posix_app_support/besserver/samples/run_server.sh Added Paths: ----------- branches/posix_app_support/besclient/samples/ branches/posix_app_support/besclient/samples/endpoint.xml branches/posix_app_support/besclient/samples/run_client.sh branches/posix_app_support/besclient/samples/sleep.jsdl branches/posix_app_support/besclient/samples/sleep_posix.jsdl branches/posix_app_support/besserver/samples/run_server_nosec.sh Removed Paths: ------------- branches/posix_app_support/besclient/sleep.jsdl Modified: branches/posix_app_support/Make.config =================================================================== --- branches/posix_app_support/Make.config 2011-08-03 16:28:54 UTC (rev 85) +++ branches/posix_app_support/Make.config 2011-08-04 06:53:27 UTC (rev 86) @@ -4,7 +4,7 @@ # You must set this to the location of your compiled gSOAP # source distribution. This directory will contain the # 'import', 'plugin', 'src' and 'wsdl' sub-directories. -GSOAP_TOP = /home/lsfadmin/SolStudioProjects/gsoap-2.7/gsoap +GSOAP_TOP = /home/lsfadmin/dgsi/src/gsoap-2.7/gsoap # # Which resource manager back end to use. Also need to set the @@ -21,12 +21,12 @@ # # LSF_LOC is where the 'include' and architecture specific # directories are located. -LSF_LOC = /opt/platform/lsf/8.0 +LSF_LOC = /usr/share/lsf/8.0 # for lava #LSF_LOC = /usr # Set to the appropriate architecture name depending on # the machine you are building BES++ on. -LSF_ARCH = x86-64-sol10 +LSF_ARCH = linux2.6-glibc2.3-x86_64 #LSF_ARCH = linux2.6-glibc2.3-x86 #LSF_ARCH = macosx LSF_INC = -I$(LSF_LOC)/include @@ -74,14 +74,10 @@ EXTRA_LIBS = -lnsl endif -ifeq "$(OSNAME)" "SunOS" - EXTRA_LIBS = -lsocket -lnsl -endif - -EXTRA_CFLAGS = -m64 -EXTRA_LDFLAGS = -m64 +EXTRA_CFLAGS = +EXTRA_LDFLAGS = # Use this to pass any extra compiler options needed (e.g. -arch) -GCC_OPTS = +GCC_OPTS = ifeq ($(RM),rm_lsf) RM_INC = $(LSF_INC) Added: branches/posix_app_support/besclient/samples/endpoint.xml =================================================================== --- branches/posix_app_support/besclient/samples/endpoint.xml (rev 0) +++ branches/posix_app_support/besclient/samples/endpoint.xml 2011-08-04 06:53:27 UTC (rev 86) @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing"> + <wsa:Address>https://192.168.0.101:443/</wsa:Address> +</wsa:EndpointReference> Added: branches/posix_app_support/besclient/samples/run_client.sh =================================================================== --- branches/posix_app_support/besclient/samples/run_client.sh (rev 0) +++ branches/posix_app_support/besclient/samples/run_client.sh 2011-08-04 06:53:27 UTC (rev 86) @@ -0,0 +1,2 @@ +#!/bin/bash +../besclient -x ../../certs/user.pem -e endpoint.xml create sleep.jsdl activitiy-endpoint.xml Property changes on: branches/posix_app_support/besclient/samples/run_client.sh ___________________________________________________________________ Added: svn:executable + * Added: branches/posix_app_support/besclient/samples/sleep.jsdl =================================================================== --- branches/posix_app_support/besclient/samples/sleep.jsdl (rev 0) +++ branches/posix_app_support/besclient/samples/sleep.jsdl 2011-08-04 06:53:27 UTC (rev 86) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<JobDefinition xmlns="http://schemas.ggf.org/jsdl/2005/11/jsdl"> + <JobDescription> + <JobIdentification> + <JobName>Sleep</JobName> + </JobIdentification> + <Application> + <HPCProfileApplication xmlns="http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa"> + <Executable>sleep</Executable> + <Argument>60</Argument> + <Output>/dev/null</Output> + <WorkingDirectory>/tmp</WorkingDirectory> + </HPCProfileApplication> + </Application> + <Resources> + <TotalCPUCount> + <Exact>1</Exact> + </TotalCPUCount> + </Resources> + </JobDescription> +</JobDefinition> + Added: branches/posix_app_support/besclient/samples/sleep_posix.jsdl =================================================================== --- branches/posix_app_support/besclient/samples/sleep_posix.jsdl (rev 0) +++ branches/posix_app_support/besclient/samples/sleep_posix.jsdl 2011-08-04 06:53:27 UTC (rev 86) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jsdl:JobDefinition xmlns="http://www.example.org/" +xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl" +xmlns:jsdl-posix="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <jsdl:JobDescription> + <jsdl:JobIdentification> + <jsdl:JobName>Sleep</jsdl:JobName> + <jsdl:Description>Simple sleep job</jsdl:Description> + </jsdl:JobIdentification> + <jsdl:Application> + <jsdl-posix:POSIXApplication> + <jsdl-posix:Executable>/bin/sleep</jsdl-posix:Executable> + <jsdl-posix:Argument>10</jsdl-posix:Argument> + </jsdl-posix:POSIXApplication> + </jsdl:Application> + </jsdl:JobDescription> +</jsdl:JobDefinition> Deleted: branches/posix_app_support/besclient/sleep.jsdl =================================================================== --- branches/posix_app_support/besclient/sleep.jsdl 2011-08-03 16:28:54 UTC (rev 85) +++ branches/posix_app_support/besclient/sleep.jsdl 2011-08-04 06:53:27 UTC (rev 86) @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<JobDefinition xmlns="http://schemas.ggf.org/jsdl/2005/11/jsdl"> - <JobDescription> - <JobIdentification> - <JobName>Sleep</JobName> - </JobIdentification> - <Application> - <HPCProfileApplication xmlns="http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa"> - <Executable>sleep</Executable> - <Argument>60</Argument> - <Output>/dev/null</Output> - <WorkingDirectory>/tmp</WorkingDirectory> - </HPCProfileApplication> - </Application> - <Resources> - <TotalCPUCount> - <Exact>1</Exact> - </TotalCPUCount> - </Resources> - </JobDescription> -</JobDefinition> - Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-03 16:28:54 UTC (rev 85) +++ branches/posix_app_support/besserver/job.c 2011-08-04 06:53:27 UTC (rev 86) @@ -211,11 +211,67 @@ } return bes_send_fault(s, fault); } + } else if (isElement(cur, JSDL_POSIX_NS, "Argument")) { + printf("-----Argument = %s\n", cur->data); + if ((rc = addArg(s, jc, cur->data)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_POSIX_NS, "Input")) { + printf("-----Input = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->input = soap_strdup(s, cur->data); + if (jc->input == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + } else if (isElement(cur, JSDL_POSIX_NS, "Output")) { + printf("-----Output = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->output = soap_strdup(s, cur->data); + if (jc->output == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + } else if (isElement(cur, JSDL_POSIX_NS, "Error")) { + printf("-----Error = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->error = soap_strdup(s, cur->data); + if (jc->error == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + } else if (isElement(cur, JSDL_POSIX_NS, "WorkingDirectory")) { + printf("-----WorkingDirectory = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->wd = soap_strdup(s, cur->data); + if (jc->wd == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + } else if (isElement(cur, JSDL_POSIX_NS, "Environment")) { + printf("-----Environment\n"); + if ((rc = addEnv(s, jc, cur)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_POSIX_NS, "UserName")) { + printf("-----UserName = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->username = soap_strdup(s, cur->data); + if (jc->username == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + } else { + struct SOAP_ENV__Fault *fault; + fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); + if (!fault) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + return bes_send_fault(s, fault); } cur = cur->next; } - // TODO: HERE I AM... return SOAP_OK; } Modified: branches/posix_app_support/besserver/samples/run_server.sh =================================================================== --- branches/posix_app_support/besserver/samples/run_server.sh 2011-08-03 16:28:54 UTC (rev 85) +++ branches/posix_app_support/besserver/samples/run_server.sh 2011-08-04 06:53:27 UTC (rev 86) @@ -1,23 +1,24 @@ #!/bin/sh -besserver=/home/csmith/src/bespp/besserver -service_user=service -host=ws.domain.com +besserver=/home/lsfadmin/dgsi/src/bespp/besserver/besserver +service_user=lsfadmin +#host=88.153.235.201 +host=0.0.0.0 endpoint="https://${host}" -certfile=/home/csmith/src/bespp/besserver/server.pem +certfile=/home/lsfadmin/dgsi/src/bespp/certs/server.pem # needed for SSL mutual authentication -capath=/home/csmith/src/bespp/besserver/certs +capath=/home/lsfadmin/dgsi/src/bespp/certs # user to run jobs from users authenticated using SSL -generic_user=generic +generic_user=lsfadmin -if [ -f /ego/lsf/conf/profile.lsf ]; then - . /ego/lsf/conf/profile.lsf +if [ -f /usr/share/lsf/conf/profile.lsf ]; then + . /usr/share/lsf/conf/profile.lsf else echo "$0: can't find profile.lsf" exit 1 fi -$besserver -u $service_user -h $host -e $endpoint -s $certfile -c $capath -g $generic_user +$besserver -u $service_user -h 0.0.0.0 -e $endpoint -s $certfile -c $capath -g $generic_user exit 0 Added: branches/posix_app_support/besserver/samples/run_server_nosec.sh =================================================================== --- branches/posix_app_support/besserver/samples/run_server_nosec.sh (rev 0) +++ branches/posix_app_support/besserver/samples/run_server_nosec.sh 2011-08-04 06:53:27 UTC (rev 86) @@ -0,0 +1,25 @@ +#!/bin/sh + +besserver=/home/lsfadmin/dgsi/bespp/besserver/besserver +service_user=lsfadmin +host=88.153.235.201 +#host=0.0.0.0 +endpoint="https://${host}" +certfile=/home/lsfadmin/dgsi/bespp/certs/server.pem +# needed for SSL mutual authentication +capath=/home/lsfadmin/dgsi/bespp/certs +# user to run jobs from users authenticated using SSL +generic_user=lsfadmin + +if [ -f /usr/share/lsf/conf/profile.lsf ]; then + . /usr/share/lsf/conf/profile.lsf +else + echo "$0: can't find profile.lsf" + exit 1 +fi + +#$besserver -u $service_user -h 0.0.0.0 -e $endpoint -s $certfile -c $capath -g $generic_user +$besserver -u $service_user -h 0.0.0.0 -e http://88.153.235.201:443 + +exit 0 + Property changes on: branches/posix_app_support/besserver/samples/run_server_nosec.sh ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-03 16:29:00
|
Revision: 85 http://bespp.svn.sourceforge.net/bespp/?rev=85&view=rev Author: tmetsch Date: 2011-08-03 16:28:54 +0000 (Wed, 03 Aug 2011) Log Message: ----------- First shot... Modified Paths: -------------- branches/posix_app_support/Make.config branches/posix_app_support/Makefile branches/posix_app_support/README.txt branches/posix_app_support/besserver/Makefile branches/posix_app_support/besserver/job.c branches/posix_app_support/besserver/namespaces.h Modified: branches/posix_app_support/Make.config =================================================================== --- branches/posix_app_support/Make.config 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/Make.config 2011-08-03 16:28:54 UTC (rev 85) @@ -4,7 +4,7 @@ # You must set this to the location of your compiled gSOAP # source distribution. This directory will contain the # 'import', 'plugin', 'src' and 'wsdl' sub-directories. -GSOAP_TOP = /home/csmith/src/gsoap-2.7/gsoap +GSOAP_TOP = /home/lsfadmin/SolStudioProjects/gsoap-2.7/gsoap # # Which resource manager back end to use. Also need to set the @@ -21,12 +21,12 @@ # # LSF_LOC is where the 'include' and architecture specific # directories are located. -LSF_LOC = /cluster/apps/lsf/7.0 +LSF_LOC = /opt/platform/lsf/8.0 # for lava #LSF_LOC = /usr # Set to the appropriate architecture name depending on # the machine you are building BES++ on. -LSF_ARCH = linux2.6-glibc2.3-x86_64 +LSF_ARCH = x86-64-sol10 #LSF_ARCH = linux2.6-glibc2.3-x86 #LSF_ARCH = macosx LSF_INC = -I$(LSF_LOC)/include @@ -74,10 +74,14 @@ EXTRA_LIBS = -lnsl endif -EXTRA_CFLAGS = -EXTRA_LDFLAGS = +ifeq "$(OSNAME)" "SunOS" + EXTRA_LIBS = -lsocket -lnsl +endif + +EXTRA_CFLAGS = -m64 +EXTRA_LDFLAGS = -m64 # Use this to pass any extra compiler options needed (e.g. -arch) -GCC_OPTS = +GCC_OPTS = ifeq ($(RM),rm_lsf) RM_INC = $(LSF_INC) Modified: branches/posix_app_support/Makefile =================================================================== --- branches/posix_app_support/Makefile 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/Makefile 2011-08-03 16:28:54 UTC (rev 85) @@ -1,6 +1,7 @@ all: server client server: + make -C besserver client: Modified: branches/posix_app_support/README.txt =================================================================== --- branches/posix_app_support/README.txt 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/README.txt 2011-08-03 16:28:54 UTC (rev 85) @@ -29,6 +29,8 @@ Building and Installing ======================= +Note: This code only works reasonably well with gsoap 2.7.10. + In order to build the BES++ software you need to use the gSOAP Toolkit (http://sourceforge.net/projects/gsoap2) to generate SOAP proxy code. The version currently used for development is gsoap 2.7.10. Your mileage @@ -270,7 +272,11 @@ See the file gpl.txt for a description of the terms and conditions for copying, distribution and modification. +Notes +===== +When using Solaris make sure flex is installed. + Copyright ========= Modified: branches/posix_app_support/besserver/Makefile =================================================================== --- branches/posix_app_support/besserver/Makefile 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/besserver/Makefile 2011-08-03 16:28:54 UTC (rev 85) @@ -8,9 +8,9 @@ SOAPCPP2 = $(GSOAP_TOP)/src/soapcpp2 -LSxc -I$(GSOAP_IMPORT) WSDL2H = $(GSOAP_TOP)/wsdl/wsdl2h -cdegy -I$(GSOAP_IMPORT) SCHEMAS = http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa \ -# http://schemas.ggf.org/jsdl/2005/11/jsdl-posix + http://schemas.ggf.org/jsdl/2005/11/jsdl-posix -CC = gcc $(GCC_OPTS) +CC = cc $(GCC_OPTS) CXX = g++ $(GCC_OPTS) CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(RM_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) LDFLAGS = -g $(EXTRA_LIB) $(EXTRA_LDFLAGS) Modified: branches/posix_app_support/besserver/job.c =================================================================== --- branches/posix_app_support/besserver/job.c 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/besserver/job.c 2011-08-03 16:28:54 UTC (rev 85) @@ -186,6 +186,40 @@ } return SOAP_OK; } + +int processPOSIXApplication(struct soap *s, struct soap_dom_element *dom, + struct jobcard *jc) { + struct soap_dom_element *cur = dom->elts; + int rc; + + printf("----%s\n", dom->name); + while (cur) { + if (isElement(cur, JSDL_POSIX_NS, "Executable")) { + printf("-----Executable = %s\n", cur->data); + if (cur->data && strlen(cur->data)) { + jc->executable = soap_strdup(s, cur->data); + if (jc->executable == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } + else { + struct SOAP_ENV__Fault *fault; + fault = bes_InvalidRequestFault(s, + "LSF requires JSDL Executable", cur->name); + if (!fault) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + return bes_send_fault(s, fault); + } + } + cur = cur->next; + } + + // TODO: HERE I AM... + return SOAP_OK; +} + + int processHPCProfileApplication(struct soap *s, struct soap_dom_element *dom, struct jobcard *jc) @@ -318,46 +352,6 @@ } int -processApplication(struct soap *s, struct soap_dom_element *dom, - struct jobcard *jc) -{ - struct soap_dom_element *cur = dom->elts; - int rc; - - printf("---%s\n", dom->name); - - while (cur) { - if (isElement(cur, JSDL_NS, "ApplicationName")) { - printf("----ApplicationName = %s\n", cur->data); - jc->appname = soap_strdup(s, cur->data); - if (jc->appname == NULL) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); - } - } else if (isElement(cur, JSDL_NS, "ApplicationVersion")) { - printf("----ApplicationVersion = %s\n", cur->data); - jc->appversion = soap_strdup(s, cur->data); - if (jc->appversion == NULL) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); - } - } else if (isElement(cur, JSDL_HPCPA_NS, "HPCProfileApplication")) { - if ((rc = processHPCProfileApplication(s, cur, jc)) != SOAP_OK) { - return rc; - } - } else { - struct SOAP_ENV__Fault *fault; - fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); - if (!fault) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); - } - return bes_send_fault(s, fault); - } - cur = cur->next; - } - - return SOAP_OK; -} - -int processRangeValue(struct soap *s, struct soap_dom_element *dom, int *value) { struct soap_dom_element *elem; @@ -663,66 +657,6 @@ } int -processJobDescription(struct soap *s, struct soap_dom_element *dom, - struct jobcard *jc) -{ - struct soap_dom_element *cur = dom->elts; - int rc; - - printf("--%s\n", dom->name); - - while (cur) { - if (isElement(cur, JSDL_NS, "JobIdentification")) { - if ((rc = processJobIdentification(s, cur, jc)) != SOAP_OK) { - return rc; - } - } else if (isElement(cur, JSDL_NS, "Application")) { - if ((rc = processApplication(s, cur, jc)) != SOAP_OK) { - return rc; - } - } else if (isElement(cur, JSDL_NS, "Resources")) { - if ((rc = processResources(s, cur, jc)) != SOAP_OK) { - return rc; - } - } else if (isElement(cur, JSDL_NS, "DataStaging")) { - if ((rc = processDataStaging(s, cur, jc)) != SOAP_OK) { - return rc; - } - } else { - struct SOAP_ENV__Fault *fault; - fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); - if (!fault) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); - } - return bes_send_fault(s, fault); - } - cur = cur->next; - } - - return SOAP_OK; -} - -int -processJobDefinition(struct soap *s, struct soap_dom_element *dom, - struct jobcard *jc) -{ - struct soap_dom_element *cur = dom->elts; - - printf("-%s\n", dom->name); - - if (isElement(cur, JSDL_NS, "JobDescription")) { - return processJobDescription(s, cur, jc); - } else { - struct SOAP_ENV__Fault *fault; - fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); - if (!fault) { - return soap_receiver_fault(s, MEM_ALLOC, NULL); - } - return bes_send_fault(s, fault); - } -} - -int processActivityDocument(struct soap *s, struct soap_dom_element *dom, struct jobcard *jc) { @@ -913,7 +847,116 @@ return dom; } +/* + + */ + int +processApplication(struct soap *s, struct soap_dom_element *dom, + struct jobcard *jc) +{ + struct soap_dom_element *cur = dom->elts; + int rc; + + printf("---%s\n", dom->name); + + while (cur) { + if (isElement(cur, JSDL_NS, "ApplicationName")) { + printf("----ApplicationName = %s\n", cur->data); + jc->appname = soap_strdup(s, cur->data); + if (jc->appname == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } else if (isElement(cur, JSDL_NS, "ApplicationVersion")) { + printf("----ApplicationVersion = %s\n", cur->data); + jc->appversion = soap_strdup(s, cur->data); + if (jc->appversion == NULL) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + } else if (isElement(cur, JSDL_HPCPA_NS, "HPCProfileApplication")) { + if ((rc = processHPCProfileApplication(s, cur, jc)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_POSIX_NS, "POSIXApplication")) { + if ((rc = processPOSIXApplication(s, cur, jc)) != SOAP_OK) { + return rc; + } + } + else { + struct SOAP_ENV__Fault *fault; + fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); + if (!fault) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + return bes_send_fault(s, fault); + } + cur = cur->next; + } + + return SOAP_OK; +} + +int +processJobDescription(struct soap *s, struct soap_dom_element *dom, + struct jobcard *jc) +{ + struct soap_dom_element *cur = dom->elts; + int rc; + + printf("--%s\n", dom->name); + + while (cur) { + if (isElement(cur, JSDL_NS, "JobIdentification")) { + if ((rc = processJobIdentification(s, cur, jc)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_NS, "Application")) { + if ((rc = processApplication(s, cur, jc)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_NS, "Resources")) { + if ((rc = processResources(s, cur, jc)) != SOAP_OK) { + return rc; + } + } else if (isElement(cur, JSDL_NS, "DataStaging")) { + if ((rc = processDataStaging(s, cur, jc)) != SOAP_OK) { + return rc; + } + } else { + struct SOAP_ENV__Fault *fault; + fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); + if (!fault) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + return bes_send_fault(s, fault); + } + cur = cur->next; + } + + return SOAP_OK; +} + +int +processJobDefinition(struct soap *s, struct soap_dom_element *dom, + struct jobcard *jc) +{ + struct soap_dom_element *cur = dom->elts; + + printf("-%s\n", dom->name); + + if (isElement(cur, JSDL_NS, "JobDescription")) { + return processJobDescription(s, cur, jc); + } else { + struct SOAP_ENV__Fault *fault; + fault = bes_UnsupportedFault(s, ELEMENT_UNKNOWN, cur->name); + if (!fault) { + return soap_receiver_fault(s, MEM_ALLOC, NULL); + } + return bes_send_fault(s, fault); + } +} + +int getJSDLFromJobInfo(struct soap *s, struct jobcard *job, struct jsdl__JobDefinition_USCOREType **jsdl_return) { Modified: branches/posix_app_support/besserver/namespaces.h =================================================================== --- branches/posix_app_support/besserver/namespaces.h 2011-08-03 14:45:14 UTC (rev 84) +++ branches/posix_app_support/besserver/namespaces.h 2011-08-03 16:28:54 UTC (rev 85) @@ -26,6 +26,7 @@ #define BES_NS "http://schemas.ggf.org/bes/2006/08/bes-factory" #define JSDL_NS "http://schemas.ggf.org/jsdl/2005/11/jsdl" +#define JSDL_POSIX_NS "http://schemas.ggf.org/jsdl/2005/11/jsdl-posix" #define JSDL_HPCPA_NS "http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa" #define SOAP_ENV_NS "http://schemas.xmlsoap.org/soap/envelope" #define SOAP_ENV_NS_WILDCARD "http://www.w3.org/*/soap-envelope" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tm...@us...> - 2011-08-03 14:45:20
|
Revision: 84 http://bespp.svn.sourceforge.net/bespp/?rev=84&view=rev Author: tmetsch Date: 2011-08-03 14:45:14 +0000 (Wed, 03 Aug 2011) Log Message: ----------- Creating branch for Posix App support Added Paths: ----------- branches/posix_app_support/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2010-04-12 18:57:45
|
Revision: 83 http://bespp.svn.sourceforge.net/bespp/?rev=83&view=rev Author: andre-merzky Date: 2010-04-12 18:57:38 +0000 (Mon, 12 Apr 2010) Log Message: ----------- simple commit to test svn permissions. Andre. Modified Paths: -------------- trunk/README.txt Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2010-04-12 18:11:50 UTC (rev 82) +++ trunk/README.txt 2010-04-12 18:57:38 UTC (rev 83) @@ -1,3 +1,4 @@ + Introduction ============ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-04-12 18:12:03
|
Revision: 82 http://bespp.svn.sourceforge.net/bespp/?rev=82&view=rev Author: csmith Date: 2010-04-12 18:11:50 +0000 (Mon, 12 Apr 2010) Log Message: ----------- MACOSX is not the default Modified Paths: -------------- trunk/config.h Modified: trunk/config.h =================================================================== --- trunk/config.h 2010-04-12 18:08:50 UTC (rev 81) +++ trunk/config.h 2010-04-12 18:11:50 UTC (rev 82) @@ -6,7 +6,7 @@ #define QSUBEXEC "qsub" /* Uncomment the next line if you are building on Mac OS X */ -#define MACOSX +/* #define MACOSX */ /* You probably don't need to change these. */ /* Setting the VERSION_STRING macro determines what is output */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-04-12 18:08:57
|
Revision: 81 http://bespp.svn.sourceforge.net/bespp/?rev=81&view=rev Author: csmith Date: 2010-04-12 18:08:50 +0000 (Mon, 12 Apr 2010) Log Message: ----------- Support for SAGA library based RM backend Modified Paths: -------------- trunk/Make.config trunk/besserver/Makefile trunk/besserver/job.c trunk/besserver/job.h trunk/besserver/rm.h trunk/besserver/rm_pbs.c trunk/config.h Added Paths: ----------- trunk/besserver/rm_saga.cpp Modified: trunk/Make.config =================================================================== --- trunk/Make.config 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/Make.config 2010-04-12 18:08:50 UTC (rev 81) @@ -14,6 +14,7 @@ #RM = rm_lava #RM = rm_pbs #RM = rm_sge +#RM = rm_saga # # LSF related variables @@ -50,13 +51,29 @@ # +# SAGA related variables +# +# SAGA_LOC is where the 'include' and 'lib' +# directories are located. +SAGA_LOC = /usr/local/packages/saga/ +SAGA_CFG = $(SAGA_LOC)/bin/saga-config +SAGA_INC = $(shell saga-config --cxxflags) +SAGA_LIBS = $(shell saga-config --ldflags) + +OSNAME = $(shell uname -s) + +# # Any extra include and lib directories, libraries, and compiler/linker flags # # -lnsl needed for Linux systems # #EXTRA_INC = -I/usr/local/include #EXTRA_LIB = -L/usr/local/lib -EXTRA_LIBS = -lnsl + +ifeq "$(OSNAME)" "Linux" + EXTRA_LIBS = -lnsl +endif + EXTRA_CFLAGS = EXTRA_LDFLAGS = # Use this to pass any extra compiler options needed (e.g. -arch) @@ -74,4 +91,8 @@ RM_INC = $(SGE_INC) RM_LIBS = $(SGE_LIBS) endif +ifeq ($(RM),rm_saga) + RM_INC = $(SAGA_INC) + RM_LIBS = $(SAGA_LIBS) +endif Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/besserver/Makefile 2010-04-12 18:08:50 UTC (rev 81) @@ -11,6 +11,7 @@ # http://schemas.ggf.org/jsdl/2005/11/jsdl-posix CC = gcc $(GCC_OPTS) +CXX = g++ $(GCC_OPTS) CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(RM_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) LDFLAGS = -g $(EXTRA_LIB) $(EXTRA_LDFLAGS) LIBS = -lssl -lcrypto -lpam $(RM_LIBS) $(EXTRA_LIBS) @@ -37,14 +38,23 @@ all: besserver besserver: $(BES_OBJ) $(SERVER_OBJ) +ifneq ($(RM),rm_saga) $(CC) $(LDFLAGS) -o besserver $(BES_OBJ) $(SERVER_OBJ) $(LSFLIBS) $(LIBS) +else + $(CXX) $(LDFLAGS) -o besserver $(BES_OBJ) $(SERVER_OBJ) $(LSFLIBS) $(LIBS) +endif besserver.o: besserver.c $(BES_H_FILES) $(SOAP_NS) job.o: job.c $(BES_H_FILES) $(SOAP_NS) faults.o: faults.c $(BES_H_FILES) $(SOAP_NS) auth.o: auth.c $(BES_H_FILES) $(SOAP_NS) -$(RM).o: $(RM).c rm_util.o $(BES_H_FILES) $(SOAP_NS) +ifeq ($(RM),rm_saga) + $(RM).o: $(RM).cpp rm_util.o $(BES_H_FILES) $(SOAP_NS) +else + $(RM).o: $(RM).c rm_util.o $(BES_H_FILES) $(SOAP_NS) +endif + soapServer.o: soapServer.c soapClient.o: soapClient.c soapC.o: soapC.c @@ -55,6 +65,9 @@ rm_util.o: rm_util.c endif +rm_saga.o: rm_saga.cpp + $(CXX) $(CFLAGS) -o $@ -c $< + stdsoap2.o: $(GSOAP_TOP)/stdsoap2.c $(CC) $(CFLAGS) -c $(GSOAP_TOP)/stdsoap2.c Modified: trunk/besserver/job.c =================================================================== --- trunk/besserver/job.c 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/besserver/job.c 2010-04-12 18:08:50 UTC (rev 81) @@ -592,10 +592,10 @@ else if (isElement(cur, JSDL_NS, "DeleteOnTermination")) { printf("----DeleteOnTermination\n"); if (!strcmp(cur->data, "true")) { - file->delete = true_; + file->delete_on_term = true_; } else { - file->delete = false_; + file->delete_on_term = false_; } } else if (isElement(cur, JSDL_NS, "Source")) { Modified: trunk/besserver/job.h =================================================================== --- trunk/besserver/job.h 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/besserver/job.h 2010-04-12 18:08:50 UTC (rev 81) @@ -50,7 +50,7 @@ char *filename; char *filesystemname; enum jsdl__CreationFlagEnumeration creationflag; - enum xsd__boolean delete; + enum xsd__boolean delete_on_term; char *source; char *target; struct credential *credential; Modified: trunk/besserver/rm.h =================================================================== --- trunk/besserver/rm.h 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/besserver/rm.h 2010-04-12 18:08:50 UTC (rev 81) @@ -64,6 +64,17 @@ char *LocalResourceManagerType; }; + +#ifdef CXX +extern "C" int rm_initialize (struct soap*, char*); +extern "C" int rm_submitJob (struct soap*, struct jobcard*, char*, char**); +extern "C" int rm_terminateJob (struct soap*, char*, char*); +extern "C" int rm_getJobInfo (struct soap*, char*, char*, struct jobcard**); +extern "C" int rm_getJobStatus (struct soap*, char*, char*, struct bes__ActivityStatusType**); +extern "C" int rm_getResourceList (struct soap*, struct rm_filter*, struct rm_resource**, int*); +extern "C" int rm_getJobsList (struct soap*, struct rm_filter*, struct rm_job**, int*); +extern "C" int rm_getClusterInfo (struct soap*, struct rm_clusterInfo**); +#else int rm_initialize(struct soap*, char*); int rm_submitJob(struct soap*, struct jobcard*, char*, char**); int rm_terminateJob(struct soap*, char*, char *); @@ -72,6 +83,7 @@ int rm_getResourceList(struct soap *, struct rm_filter*, struct rm_resource**, int*); int rm_getJobsList(struct soap*, struct rm_filter*, struct rm_job**, int*); int rm_getClusterInfo(struct soap*, struct rm_clusterInfo**); +#endif #endif /* _RM_H */ Modified: trunk/besserver/rm_pbs.c =================================================================== --- trunk/besserver/rm_pbs.c 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/besserver/rm_pbs.c 2010-04-12 18:08:50 UTC (rev 81) @@ -650,7 +650,7 @@ fprintf(script,"%s out %s %s %s\n", STAGE_SCRIPT, currentFile->target, currentFile->filename, currentFile->credential->username, currentFile->credential->password); - if(currentFile->delete) + if(currentFile->delete_on_term) fprintf(script,"rm %s\n", currentFile->filename); } currentFile=currentFile->next; @@ -659,7 +659,7 @@ //Remove files which DeleteOnTermination equals true currentFile = jc->files; while(currentFile != NULL){ - if(currentFile->delete){ + if(currentFile->delete_on_term){ fprintf(script, "rm %s\n", currentFile->filename); } currentFile=currentFile->next; Added: trunk/besserver/rm_saga.cpp =================================================================== --- trunk/besserver/rm_saga.cpp (rev 0) +++ trunk/besserver/rm_saga.cpp 2010-04-12 18:08:50 UTC (rev 81) @@ -0,0 +1,618 @@ +/* ---------------------------------------------------------------- + * rm_saga.c + * + * SAGA backend implementation of the OGSA Basic Execution Services + * + * Copyright (C) Andre Merzky <an...@me...> + * CCT, Louisiana State University + * All Rights Reserved. + * + * This file is part of Besserver. + * + * Besserver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#define CXX + +//Includes +#include "rm.h" +#include "rm_util.h" +#include "faults.h" +#include "job.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> + +#include <saga/saga.hpp> +#include <boost/lexical_cast.hpp> + +//! Maximum length of the environment variables string +#define MAXVAR_BUFFER 4096 + +//GLOBAL VARIABLES + +/** + * SAGA does not need any special initialization + */ +extern "C" +int rm_initialize (struct soap * soap, + char * serverName) +{ + return BESE_OK; +} + +/** + * Prints an error message to stderr + * @param message string to print + */ +extern "C" +void printError (char * message) +{ + std::cerr << message << std::flush; +} + +/** + * FIXME + * @return 0 + */ +extern "C" +int getErrNo (void) +{ + return 0; +} + +/** + * Terminates a job. + * @param jobid is the PID assigned by the queue + * @param user is a string with the account of the user who requested the + * job deletion + * @return 0 if correct, non-zero if error + */ +extern "C" +int rm_terminateJob (struct soap * soap, + char * jobid, + char * user) +{ + if ( ! jobid || std::string (jobid).empty () ) + { + // empty jobid - not sure what to do + return BESE_BAD_ARG; + } + + // FIXME: dig js URL from jobid + try + { + saga::job::service js; + saga::job::job j = js.get_job (jobid); + j.cancel (); + } + catch ( const saga::exception & e ) + { + std::cout << "Could not kill job " + << jobid + << " : " + << e.what () + << std::endl; + return BESE_BACKEND; + } + + return BESE_OK; +} + +/** + * Gets the status of the job. + * + * It maps the different states of SAGA jobs to BES states. + * @param jobid is the saga job id + * @param user is a string with the account of the user who requested the + * job status + * @param jobStatus is an output parameter with the status of the job -NULL + * if error- + * @return 0 if correct, non-zero if error + */ +extern "C" +int rm_getJobStatus(struct soap * soap, + char * jobid, + char * user, + struct bes__ActivityStatusType ** jobStatus) +{ + struct bes__ActivityStatusType *activityStatus; + + if ( ! jobid || std::string (jobid).empty () ) + { + // empty jobid - not sure what to do + return BESE_BAD_ARG; + } + + if ( ! jobStatus ) + { + return BESE_BAD_ARG; + } + + activityStatus = (struct bes__ActivityStatusType*) soap_malloc (soap, sizeof (struct bes__ActivityStatusType)); + + if ( activityStatus == NULL ) + { + return BESE_MEM_ALLOC; + } + + ::memset (activityStatus, 0, sizeof (struct bes__ActivityStatusType)); + + bool ok = true; + + try + { + saga::job::service js; + saga::job::job j = js.get_job (jobid); + + switch ( j.get_state () ) + { + case saga::job::New: activityStatus->state = Pending; break; + case saga::job::Running: activityStatus->state = Running; break; + case saga::job::Suspended: activityStatus->state = Running; break; + case saga::job::Canceled: activityStatus->state = Cancelled; break; + case saga::job::Failed: activityStatus->state = Failed; break; + case saga::job::Done: activityStatus->state = Finished; break; + default: ok = false; break; + } + } + catch ( const saga::exception & e ) + { + std::cout << "Could not get job state for " + << jobid + << " : " + << e.what () + << std::endl; + return BESE_BACKEND; + } + + if ( ! ok ) + { + std::cout << "invalid state state for " + << jobid + << std::endl; + return BESE_BACKEND; + } + + *jobStatus = activityStatus; + + return BESE_OK; +} + +/** + * Gets the information about a job. + * + * @param jobid is the PID assigned by the queue + * @param soap + * @param job_info is an output parameter which contains the information + * about the job submission request and the job state (NULL if error). + * @return 0 if correct, non-zero if error + */ +extern "C" +int rm_getJobInfo (struct soap * soap, + char * jobid, + char * user, + struct jobcard ** job_info ) +{ + if ( ! jobid || std::string (jobid).empty () ) + { + // empty jobid - not sure what to do + return BESE_BAD_ARG; + } + + if ( ! job_info ) + { + return BESE_BAD_ARG; + } + + struct jobcard * jc = (struct jobcard *) soap_malloc (soap, sizeof (struct jobcard)); + + try + { + saga::job::service js; + saga::job::job j = js.get_job (jobid); + + jc->jobname = ""; + jc->jobproject = ""; + jc->num_hostnames = 0; + jc->hostnames = NULL; + jc->exclusive = 0; + jc->osname = ""; + jc->osver = ""; + jc->cpuarch = ""; + jc->executable = ""; + jc->num_args = 0; + jc->args = NULL; + jc->input = ""; + jc->output = ""; + jc->error = ""; + jc->wd = "$HOME"; + jc->environment = NULL; + jc->username = ""; + + // while ( env ) + // { + // struct envvar* newEnvVar= (struct envvar *) soap_malloc (soap, + // sizeof (struct envvar)); + // memset (newEnvVar, 0, sizeof (struct envvar)); + // newEnvVar->name = soap_strdup (soap, env.key); + // newEnvVar->val = soap_strdup (soap, env.val); + // newEnvVar->next = job_info->environment; + // + // jc->environment = newEnvVar; + // } + } + catch ( const saga::exception & e ) + { + std::cout << "Could not get job info for " + << jobid + << " : " + << e.what () + << std::endl; + return BESE_BACKEND; + } + + *job_info = jc; + + return BESE_OK; +} + + +/** + * Gets a filtered list of jobs in the queue. + * + * This function issues a qstat and then parses the output file to add to + * the list the jobs that pass the filters. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @param filters are the filters that are going to be applied. See + * HPCBP Advanced Filter Extension. + * @return a list of job ids + */ +extern "C" +int rm_getJobList(struct soap * soap, + struct rm_filter * filters, + struct rm_job ** joblist, + int * numjobs) +{ + struct rm_job * jobList; + char filename[128]; + char command[256]; + struct rm_filter* filter; + int jobid; + int scan; + char ignore[128]; + int numJobs = 0; + + // set up filter maps. + // NOTE: we do not support time and id filters, as ids are not numerical in + // SAGA, and time + std::map <std::string, bool> user_map; + std::map <std::string, bool> state_map; + + // we do not su + std::vector <std::pair <long, long> > id_range_map; + std::vector <std::pair <std::string, std::string> > time_range_map; + + filter = filters; + while ( (filter != NULL) ) + { + if ( filter->user != NULL ) + { + user_map [filter->user] = true; + } + + if ( filter->state != NULL ) + { + state_map [filter->state] = true; + } + + filter = filter->next; + } + + try + { + saga::job::service js; + std::vector <std::string> ids = js.list (); + + for ( unsigned int i = 0; i < ids.size (); i++ ) + { + saga::job::job j = js.get_job (ids[i]); + saga::job::description jd = j.get_description (); + + // FIXME: this gives the user ID for the first session context, not the + // user ID for whoever actually owns this job. Not sure this is possible + // in SAGA... + std::string user = j.get_session ().list_contexts ()[0].get_attribute ("UserID"); + std::string state = boost::lexical_cast <std::string> (j.get_state ()); + + if ( user_map .count (user ) == 0 && + state_map.count (state) == 0 ) + { + struct rm_job * newJob = (struct rm_job *) soap_malloc (soap, + sizeof (struct rm_job)); + if ( ! newJob ) + { + return BESE_MEM_ALLOC; + } + + newJob->jobid = soap_strdup (soap, ids[i].c_str ()); + newJob->next = jobList; + jobList = newJob; + + numJobs++; + } + } + } + catch ( const saga::exception & e ) + { + std::cout << "Could not get job list : " + << e.what () + << std::endl; + return BESE_BACKEND; + } + + *joblist = jobList; + *numjobs = numJobs; + + return BESE_OK; +} + + +extern "C" +int rm_getResourceList (struct soap * soap, + struct rm_filter * filter, + struct rm_resource ** resourcelist, + int * num_resources) +{ + // SAGA does not have resource discovery :-( + return BESE_SYS_ERR; +} + + +/** + * Gets the factory attributes. + * + * This function uses @see loadResourceFile + * and also queries the SGE queue. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @return a struct of type clusterInfo with the information needed for the + * factory attributes document + */ +extern "C" +int rm_getClusterInfo (struct soap * soap, + struct rm_clusterInfo ** clusterInf + /* , int compactResources */ + ) +{ + // SAGA does not have resource discovery :-( + return BESE_SYS_ERR; +} + +/** + * Submits a job to the queuing system. + * + * It generates a script file and sends + * it to the queue. + * @param jc stores all the information about the job + * @param soap is used to allocate memory that can be freed by the gsoap + * library + * @param message is the description of the error ocurred (if any) + * @return job PID if correct, negative integer if error + */ +extern "C" +int rm_submitJob ( struct soap * soap, + struct jobcard * jc, + char * user, + char ** return_jobid) +{ + try + { + using namespace saga::job::attributes; + + saga::url rm; // job service contact + saga::job::description jd; + + if ( ! jc ) + { + return BESE_BAD_ARG; + } + + + if ( jc->executable ) + { + jd.set_attribute (description_executable, jc->executable); + } + else + { + std::cerr << "Error: Need to have the executable name" << std::endl; + return BESE_BAD_ARG; + } + + + if ( jc->input ) + { + jd.set_attribute (description_input, jc->input); + } + + + if ( jc->output ) + { + jd.set_attribute (description_output, jc->output); + } + + + if ( jc->error ) + { + jd.set_attribute (description_error, jc->error); + } + + + if ( jc->osname ) + { + jd.set_attribute (description_operating_system_type, jc->osname); + } + + + if ( jc->cpuarch ) + { + jd.set_attribute (description_cpu_architecture, jc->cpuarch); + } + + + if ( jc->wd ) + { + jd.set_attribute (description_working_directory, jc->wd); + } + + + if ( jc->jobproject ) + { + jd.set_attribute (description_job_project, jc->jobproject); + } + + + // unsupported + // if ( jc->jobname != NULL ) + // { + // jd.set_attribute (description_jobname, jc->jobname); + // } + // + + if ( jc->icpu != 0 ) + { + jd.set_attribute (description_total_cpu_count, + boost::lexical_cast <std::string> (jc->icpu)); + } + + + if ( jc->ipmem != 0 ) + { + jd.set_attribute (description_total_physical_memory, + boost::lexical_cast <std::string> (jc->ipmem)); + } + + + // unsupported by SAGA + // if ( jc->ivmem != 0 ) + // { + // jd.set_attribute (description_vmem, + // boost::lexical_cast <std::string> (jc->ivmem)); + // } + + + std::vector <std::string> args; + for ( int i = 0; i < jc->num_args; i++ ) + { + args.push_back (jc->args[i]); + } + jd.set_vector_attribute (description_arguments, args); + + + std::vector <std::string> chosts; + for ( int i = 0; i < jc->num_hostnames; i++ ) + { + if ( jc->hostnames[i] ) + { + chosts.push_back (jc->hostnames[i]); + } + } + jd.set_vector_attribute (description_candidate_hosts, chosts); + + + // Store the submitting info in environment variables for later use + std::vector <std::string> env; + struct envvar* variableList = jc->environment; + for ( ; variableList != NULL; variableList = variableList->next ) + { + std::string key = variableList->name; + std::string val = variableList->val; + + env.push_back (key + "=" + val); + + } + jd.set_vector_attribute (description_environment, env); + + + std::vector <std::string> transfers; + bool delete_on_term = true; // clean all or none + struct fileStage * stage = jc->files; + while ( stage != NULL ) + { + if ( stage->credential ) + { + std::cerr << "Warning: user/pass unsupported for file staging" + << std::endl; + } + + if ( stage->source != NULL ) + { + std::string tmp (stage->source); + tmp += " > "; + tmp += stage->filename; + } + else if ( stage->target != NULL ) + { + std::string tmp (stage->filename); + tmp += " < "; + tmp += stage->target; + } + + // if any file needs to be kept, do *not* set the delete flag + if ( ! stage->delete_on_term ) + { + delete_on_term = false; + } + + stage = stage->next; + } + + if ( ! transfers.empty () ) + { + jd.set_vector_attribute (description_file_transfer, transfers); + } + + jd.set_attribute (description_cleanup, boost::lexical_cast <std::string> (delete_on_term)); + + + // create and run job + saga::job::service js; + saga::job::job j = js.create_job (jd); + j.run (); + + * return_jobid = soap_strdup (soap, j.get_job_id ().c_str ()); + } + catch ( const saga::exception & e ) + { + std::cerr << "Error in job submission: " + << std::endl + << e.what () + << std::endl; + + return BESE_SYS_ERR; + } + + return BESE_OK; +} + Modified: trunk/config.h =================================================================== --- trunk/config.h 2010-04-12 18:00:39 UTC (rev 80) +++ trunk/config.h 2010-04-12 18:08:50 UTC (rev 81) @@ -6,7 +6,7 @@ #define QSUBEXEC "qsub" /* Uncomment the next line if you are building on Mac OS X */ -/* #define MACOSX */ +#define MACOSX /* You probably don't need to change these. */ /* Setting the VERSION_STRING macro determines what is output */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-04-12 18:00:52
|
Revision: 80 http://bespp.svn.sourceforge.net/bespp/?rev=80&view=rev Author: csmith Date: 2010-04-12 18:00:39 +0000 (Mon, 12 Apr 2010) Log Message: ----------- Added GCC_OPTS to compile command Modified Paths: -------------- trunk/Make.config trunk/besclient/Makefile trunk/besserver/Makefile Modified: trunk/Make.config =================================================================== --- trunk/Make.config 2010-02-11 19:01:25 UTC (rev 79) +++ trunk/Make.config 2010-04-12 18:00:39 UTC (rev 80) @@ -59,6 +59,8 @@ EXTRA_LIBS = -lnsl EXTRA_CFLAGS = EXTRA_LDFLAGS = +# Use this to pass any extra compiler options needed (e.g. -arch) +GCC_OPTS = ifeq ($(RM),rm_lsf) RM_INC = $(LSF_INC) Modified: trunk/besclient/Makefile =================================================================== --- trunk/besclient/Makefile 2010-02-11 19:01:25 UTC (rev 79) +++ trunk/besclient/Makefile 2010-04-12 18:00:39 UTC (rev 80) @@ -10,7 +10,7 @@ SCHEMAS = http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa \ http://schemas.ggf.org/jsdl/2005/11/jsdl-posix -CC = gcc +CC = gcc $(GCC_OPTS) CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) LDFLAGS = -g -L. $(EXTRA_LIB) $(EXTRA_LDFLAGS) LIBS = -lbes -lssl -lcrypto $(EXTRA_LIBS) Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2010-02-11 19:01:25 UTC (rev 79) +++ trunk/besserver/Makefile 2010-04-12 18:00:39 UTC (rev 80) @@ -10,7 +10,7 @@ SCHEMAS = http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa \ # http://schemas.ggf.org/jsdl/2005/11/jsdl-posix -CC = gcc +CC = gcc $(GCC_OPTS) CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(RM_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) LDFLAGS = -g $(EXTRA_LIB) $(EXTRA_LDFLAGS) LIBS = -lssl -lcrypto -lpam $(RM_LIBS) $(EXTRA_LIBS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-02-11 19:01:32
|
Revision: 79 http://bespp.svn.sourceforge.net/bespp/?rev=79&view=rev Author: csmith Date: 2010-02-11 19:01:25 +0000 (Thu, 11 Feb 2010) Log Message: ----------- - pass extra parameters to compiler/linker Modified Paths: -------------- trunk/Make.config trunk/besclient/Makefile trunk/besserver/Makefile Modified: trunk/Make.config =================================================================== --- trunk/Make.config 2010-02-10 20:38:51 UTC (rev 78) +++ trunk/Make.config 2010-02-11 19:01:25 UTC (rev 79) @@ -50,13 +50,15 @@ # -# Any extra include and lib directories, or libraries +# Any extra include and lib directories, libraries, and compiler/linker flags # # -lnsl needed for Linux systems # #EXTRA_INC = -I/usr/local/include #EXTRA_LIB = -L/usr/local/lib EXTRA_LIBS = -lnsl +EXTRA_CFLAGS = +EXTRA_LDFLAGS = ifeq ($(RM),rm_lsf) RM_INC = $(LSF_INC) Modified: trunk/besclient/Makefile =================================================================== --- trunk/besclient/Makefile 2010-02-10 20:38:51 UTC (rev 78) +++ trunk/besclient/Makefile 2010-02-11 19:01:25 UTC (rev 79) @@ -11,8 +11,8 @@ http://schemas.ggf.org/jsdl/2005/11/jsdl-posix CC = gcc -CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(EXTRA_INC) -LDFLAGS = -g -L. $(EXTRA_LIB) +CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) +LDFLAGS = -g -L. $(EXTRA_LIB) $(EXTRA_LDFLAGS) LIBS = -lbes -lssl -lcrypto $(EXTRA_LIBS) BES_WSDL = bes-factory.wsdl Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2010-02-10 20:38:51 UTC (rev 78) +++ trunk/besserver/Makefile 2010-02-11 19:01:25 UTC (rev 79) @@ -11,8 +11,8 @@ # http://schemas.ggf.org/jsdl/2005/11/jsdl-posix CC = gcc -CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(RM_INC) $(EXTRA_INC) -LDFLAGS = -g $(EXTRA_LIB) +CFLAGS = -g $(GSOAP_DEF) -I. $(GSOAP_INC) $(RM_INC) $(EXTRA_INC) $(EXTRA_CFLAGS) +LDFLAGS = -g $(EXTRA_LIB) $(EXTRA_LDFLAGS) LIBS = -lssl -lcrypto -lpam $(RM_LIBS) $(EXTRA_LIBS) BES_WSDL = bes-factory.wsdl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-02-10 20:38:57
|
Revision: 78 http://bespp.svn.sourceforge.net/bespp/?rev=78&view=rev Author: csmith Date: 2010-02-10 20:38:51 +0000 (Wed, 10 Feb 2010) Log Message: ----------- - small change to exceptions around distributing source with object code Modified Paths: -------------- trunk/license-exceptions-client.txt Modified: trunk/license-exceptions-client.txt =================================================================== --- trunk/license-exceptions-client.txt 2010-02-10 17:57:28 UTC (rev 77) +++ trunk/license-exceptions-client.txt 2010-02-10 20:38:51 UTC (rev 78) @@ -31,15 +31,8 @@ b. all identifiable sections of the Derivative Work which are not derived from the Program, and which can reasonably be considered independent and separate works - in themselves, - i. are distributed subject to one of the FLOSS licenses - listed below, and - ii. the object code or executable form of those sections - are accompanied by the complete corresponding - machine-readable source code for those sections on - the same medium and under the same FLOSS license as - the corresponding object code or executable forms of - those sections, and + in themselves, are distributed subject to one of the FLOSS + licenses listed below, and c. any works which are aggregated with the Program or with a Derivative Work on a volume of a storage or distribution medium in accordance with the GPL, can reasonably be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-02-10 17:57:35
|
Revision: 77 http://bespp.svn.sourceforge.net/bespp/?rev=77&view=rev Author: csmith Date: 2010-02-10 17:57:28 +0000 (Wed, 10 Feb 2010) Log Message: ----------- - Fix for issue 2893102 Modified Paths: -------------- trunk/besserver/job.c Modified: trunk/besserver/job.c =================================================================== --- trunk/besserver/job.c 2010-02-10 17:57:04 UTC (rev 76) +++ trunk/besserver/job.c 2010-02-10 17:57:28 UTC (rev 77) @@ -68,6 +68,7 @@ if (newvar == NULL) { return soap_receiver_fault(s, MEM_ALLOC, NULL); } + memset(newvar, 0, sizeof(struct envvar)); newvar->val = soap_strdup(s, dom->data); if (newvar->val == NULL) { @@ -87,12 +88,17 @@ return soap_receiver_fault(s, "Environment element missing name", NULL); } - cur = jc->environment; - while (cur->next) { - cur = cur->next; + if (jc->environment == NULL) { + jc->environment = newvar; } - cur->next = newvar; - + else { + cur = jc->environment; + while (cur->next) { + cur = cur->next; + } + cur->next = newvar; + } + return SOAP_OK; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-02-10 17:57:10
|
Revision: 76 http://bespp.svn.sourceforge.net/bespp/?rev=76&view=rev Author: csmith Date: 2010-02-10 17:57:04 +0000 (Wed, 10 Feb 2010) Log Message: ----------- - Fix for issue #2912499 Modified Paths: -------------- trunk/besserver/rm_pbs.c Modified: trunk/besserver/rm_pbs.c =================================================================== --- trunk/besserver/rm_pbs.c 2010-02-10 17:45:12 UTC (rev 75) +++ trunk/besserver/rm_pbs.c 2010-02-10 17:57:04 UTC (rev 76) @@ -239,22 +239,22 @@ { if(!strcmp(attrList->name, ATTR_state)) { - if(strcmp(attrList->value, "T")) { + if(!strcmp(attrList->value, "T")) { activityStatus->state = Pending; } - else if(strcmp(attrList->value, "Q")) { + else if(!strcmp(attrList->value, "Q")) { activityStatus->state = Pending; } - else if(strcmp(attrList->value,"H")) { + else if(!strcmp(attrList->value,"H")) { activityStatus->state = Pending; } - else if(strcmp(attrList->value,"W")){ + else if(!strcmp(attrList->value,"W")){ activityStatus->state = Pending; } - else if(strcmp(attrList->value,"R")){ + else if(!strcmp(attrList->value,"R")){ activityStatus->state = Running; } - else if(strcmp(attrList->value,"E")) { + else if(!strcmp(attrList->value,"E")) { activityStatus->state = Finished; } pbs_statfree(status); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2010-02-10 17:45:19
|
Revision: 75 http://bespp.svn.sourceforge.net/bespp/?rev=75&view=rev Author: csmith Date: 2010-02-10 17:45:12 +0000 (Wed, 10 Feb 2010) Log Message: ----------- - adding license exemption for non-GPL compatible OSS licenses to use the BES++ client libraries Added Paths: ----------- trunk/license-exceptions-client.txt Added: trunk/license-exceptions-client.txt =================================================================== --- trunk/license-exceptions-client.txt (rev 0) +++ trunk/license-exceptions-client.txt 2010-02-10 17:45:12 UTC (rev 75) @@ -0,0 +1,120 @@ +BES++ FLOSS License Exception + +The Platform Computing Corporation Exception for Free/Libre and Open +Source Software-only Applications Using the BES++ Client Libraries +the "FLOSS Exception"). + +Version 1.0, 10 Feb 2010 + +Exception Intent + +We want specified Free/Libre and Open Source Software (``FLOSS'') +applications to be able to use specified GPL-licensed BES++ client +libraries (the ``Program'') despite the fact that not all FLOSS +licenses are compatible with version 2 of the GNU General Public +License (the ``GPL''). + +Legal Terms and Conditions + +As a special exception to the terms and conditions of version 2.0 +of the GPL: + + 1. You are free to distribute a Derivative Work that is formed + entirely from the Program and one or more works (each, a + "FLOSS Work") licensed under one or more of the licenses + listed below in section 1, as long as: + a. You obey the GPL in all respects for the Program and the + Derivative Work, except for identifiable sections of the + Derivative Work which are not derived from the Program, + and which can reasonably be considered independent and + separate works in themselves, + b. all identifiable sections of the Derivative Work which + are not derived from the Program, and which can + reasonably be considered independent and separate works + in themselves, + i. are distributed subject to one of the FLOSS licenses + listed below, and + ii. the object code or executable form of those sections + are accompanied by the complete corresponding + machine-readable source code for those sections on + the same medium and under the same FLOSS license as + the corresponding object code or executable forms of + those sections, and + c. any works which are aggregated with the Program or with a + Derivative Work on a volume of a storage or distribution + medium in accordance with the GPL, can reasonably be + considered independent and separate works in themselves + which are not derivatives of either the Program, a + Derivative Work or a FLOSS Work. + If the above conditions are not met, then the Program may only + be copied, modified, distributed or used under the terms and + conditions of the GPL or another valid licensing option from + Platform Computing Corporation. + + 2. FLOSS License List + +License name Version(s)/Copyright Date +Academic Free License 2.0 +Apache Software License 1.0/1.1/2.0 +Apple Public Source License 2.0 +Artistic license From Perl 5.8.0 +Boost Software License 1.0 +BSD license "July 22 1999" +Common Development and Distribution License (CDDL) 1.0 +Common Public License 1.0 +Eclipse Public License 1.0 +GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1 +Jabber Open Source License 1.0 +MIT license (As listed in file MIT-License.txt) --- +Mozilla Public License (MPL) 1.0/1.1 +Open Software License 2.0 +OpenSSL license (with original SSLeay license) "2003" ("1998") +PHP License 3.0 +Python license (CNRI Python License) --- +Python Software Foundation License 2.1.1 +Sleepycat License "1999" +University of Illinois/NCSA Open Source License --- +W3C License "2001" +X11 License "2001" +Zlib/libpng License --- +Zope Public License 2.0 + + Due to the many variants of some of the above licenses, we + require that any version follow the 2003 version of the Free + Software Foundation's Free Software Definition + (http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of + the Open Source Definition by the Open Source Initiative + (http://www.opensource.org/docs/definition.php). + + 3. Definitions + + a. Terms used, but not defined, herein shall have the + meaning provided in the GPL. + b. Derivative Work means a derivative work under copyright + law. + + 4. Applicability: This FLOSS Exception applies to all Programs + that contain a notice placed by Platform Computing Corporation + saying that the Program may be distributed under the terms of + this FLOSS Exception. If you create or distribute a work which + is a Derivative Work of both the Program and any other work + licensed under the GPL, then this FLOSS Exception is not + available for that work; thus, you must remove the FLOSS + Exception notice from that work and comply with the GPL in all + respects, including by retaining all GPL notices. You may + choose to redistribute a copy of the Program exclusively under + the terms of the GPL by removing the FLOSS Exception notice + from that copy of the Program, provided that the copy has + never been modified by you or any third party. + +Appendix A. Qualified Libraries and Packages + +The following is a non-exhaustive list of libraries and packages +which are covered by the FLOSS License Exception. Please note that +this appendix is provided merely as an additional service to +specific FLOSS projects wishing to simplify licensing information +for their users. Compliance with one of the licenses noted under +the "FLOSS license list" section remains a prerequisite. + +Package Name Qualifying License and Version +Apache Portable Runtime (APR) Apache Software License 2.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-09-11 16:44:48
|
Revision: 74 http://bespp.svn.sourceforge.net/bespp/?rev=74&view=rev Author: csmith Date: 2009-09-11 16:44:40 +0000 (Fri, 11 Sep 2009) Log Message: ----------- - added support for Lava resource manager Modified Paths: -------------- trunk/Make.config trunk/besserver/Makefile Added Paths: ----------- trunk/besserver/rm_lava.c Modified: trunk/Make.config =================================================================== --- trunk/Make.config 2009-09-02 16:47:49 UTC (rev 73) +++ trunk/Make.config 2009-09-11 16:44:40 UTC (rev 74) @@ -4,14 +4,15 @@ # You must set this to the location of your compiled gSOAP # source distribution. This directory will contain the # 'import', 'plugin', 'src' and 'wsdl' sub-directories. -GSOAP_TOP = /home/ar5je/centurion/gsoap/gsoap +GSOAP_TOP = /home/csmith/src/gsoap-2.7/gsoap # # Which resource manager back end to use. Also need to set the # locations of resource manager specific includes and libraries # -#RM = rm_lsf -RM = rm_pbs +RM = rm_lsf +#RM = rm_lava +#RM = rm_pbs #RM = rm_sge # @@ -19,7 +20,9 @@ # # LSF_LOC is where the 'include' and architecture specific # directories are located. -LSF_LOC = /usr/local/lsf/7.0 +LSF_LOC = /cluster/apps/lsf/7.0 +# for lava +#LSF_LOC = /usr # Set to the appropriate architecture name depending on # the machine you are building BES++ on. LSF_ARCH = linux2.6-glibc2.3-x86_64 @@ -27,9 +30,13 @@ #LSF_ARCH = macosx LSF_INC = -I$(LSF_LOC)/include LSF_LIB = $(LSF_LOC)/$(LSF_ARCH)/lib +# for lava +#LSF_LIB = $(LSF_LOC)/lib # need to uncomment only one of the following #LSF_LIBS = -L$(LSF_LIB) -lbat -llsf LSF_LIBS = $(LSF_LIB)/libbat.a $(LSF_LIB)/liblsf.a +# for lava +#LSF_LIBS = $(LSF_LIB)/liblsfbat.a $(LSF_LIB)/liblsf.a # # PBS related variables Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2009-09-02 16:47:49 UTC (rev 73) +++ trunk/besserver/Makefile 2009-09-11 16:44:40 UTC (rev 74) @@ -20,6 +20,8 @@ BES_H_FILES = job.h namespaces.h faults.h auth.h rm.h ifneq ($(RM),rm_lsf) BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o rm_util.o +else ifneq ($(RM),rm_lava) + BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o rm_util.o else BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o endif @@ -49,6 +51,9 @@ ifneq ($(RM),rm_lsf) rm_util.o: rm_util.c endif +ifneq ($(RM),rm_lava) + rm_util.o: rm_util.c +endif stdsoap2.o: $(GSOAP_TOP)/stdsoap2.c $(CC) $(CFLAGS) -c $(GSOAP_TOP)/stdsoap2.c Added: trunk/besserver/rm_lava.c =================================================================== --- trunk/besserver/rm_lava.c (rev 0) +++ trunk/besserver/rm_lava.c 2009-09-11 16:44:40 UTC (rev 74) @@ -0,0 +1,816 @@ +/* ---------------------------------------------------------------- + * rm_lava.c + * + * Copyright (C) 2006-2009, Platform Computing Corporation. All Rights Reserved. + * + * + * This file is part of BESserver. + * + * BESserver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#include <stdlib.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> + +#include <lsf/lsf.h> +#include <lsf/lsbatch.h> + +#include "rm.h" + + +int +rm_initialize(struct soap *s, char *servername) +{ + if (lsb_init("besserver")) { + lsb_perror("rm_initialize: lsb_init"); + return -1; + } + return 0; +} + +static int +createJobWrapperScript(struct jobcard *jc, char *osuser, char *scriptname, int namelen) +{ + static char fname[] = "createJobWrapperScript"; + char wrappername[MAXPATHLEN]; + FILE *wrapper; + int fd, i; + struct passwd *pw; + uid_t service_uid; + struct fileStage *file; + char *cp; + + if (!jc || !osuser || !scriptname) { + return BESE_OTHER; + } + + if ((pw = getpwnam(osuser)) == NULL) { + fprintf(stderr, "%s: couldn't get user %s from passwd\n", fname, osuser); + return BESE_BAD_ARG; + } + + service_uid = geteuid(); + + if (seteuid(0)) { + perror("createJobWrapperScript: seteuid 0 (1)"); + return BESE_SYS_ERR; + } + + if (seteuid(pw->pw_uid)) { + perror("createJobWrapperScript: seteuid user"); + return BESE_SYS_ERR; + } + + if (strlen(pw->pw_dir) + strlen("/jobscript.XXXXXX") + 1 > MAXPATHLEN) { + fprintf(stderr, "%s: cannot generate wrapper script: path too long\n", fname); + return BESE_SYS_ERR; + } + + sprintf(wrappername, "%s/jobscript.XXXXXX", pw->pw_dir); + fd = mkstemp(wrappername); + if (fd == -1) { + perror("createJobWrapperScript: mkstemp"); + return BESE_SYS_ERR; + } + + if (fchmod(fd, S_IRWXU)) { + perror("createJobWrapperScript: fchmod"); + unlink(wrappername); + return BESE_SYS_ERR; + } + + wrapper = fdopen(fd, "w"); + if (wrapper == NULL) { + perror("createJobWrapperScript: fdopen"); + unlink(wrappername); + return BESE_SYS_ERR; + } + + fprintf(wrapper, "#!/bin/sh\n"); + + file = jc->files; + while (file) { + if (file->source) { + cp = strstr(file->source, "ftp://"); + if (!cp) { + fprintf(stderr, "%s: malformed source URI for file transfer %s\n", fname, file->source); + fprintf(stderr, "%s: only support ftp URIs at this time\n", fname); + unlink(wrappername); + return BESE_OTHER; + } + cp = cp + strlen("ftp://"); + + fprintf(wrapper, "%s -o %s ftp://", FTP_PROGRAM, file->filename); + if (file->credential) { + fprintf(wrapper, "%s:%s@", file->credential->username, file->credential->password); + } + fprintf(wrapper, "%s\n", cp); + } + file = file->next; + } + + if (jc->executable) { + fprintf(wrapper, "%s", jc->executable); + } + for (i = 0; i < jc->num_args; i++) { + fprintf(wrapper, " %s", jc->args[i]); + } + fprintf(wrapper, "\n"); + + fprintf(wrapper, "rc=$?\n"); + + file = jc->files; + while (file) { + if (file->target) { + cp = strstr(file->target, "ftp://"); + if (!cp) { + fprintf(stderr, "%s: malformed target URI for file transfer %s\n", fname, file->target); + fprintf(stderr, "%s: only support ftp URIs at this time\n", fname); + unlink(wrappername); + return BESE_OTHER; + } + cp = cp + strlen("ftp://"); + + fprintf(wrapper, "%s -u ftp://", FTP_PROGRAM); + if (file->credential) { + fprintf(wrapper, "%s:%s@", file->credential->username, file->credential->password); + } + fprintf(wrapper, "%s %s\n", cp, file->filename); + } + file = file->next; + } + + fprintf(wrapper, "rm $0\n"); + + fprintf(wrapper, "exit $rc\n"); + + fclose(wrapper); + + if (seteuid(0)) { + perror("createJobWrapperScript: seteuid 0 (2)"); + unlink(wrappername); + return BESE_SYS_ERR; + } + + if (seteuid(service_uid)) { + perror("createJobWrapperScript: seteuid service_uid"); + unlink(wrappername); + return BESE_SYS_ERR; + } + + strncpy(scriptname, wrappername, namelen-1); + + return BESE_OK; +} + +static int +runBsubScriptAsUser(char *scriptname, char *user) +{ + static char fname[] = "runBsubScriptAsUser"; + FILE *fp; + pid_t pid; + int pfd[2], jobid = 0; + struct passwd *pw; + char *arg0, buf[512]; + + if (!scriptname || !user) { + return -1; + } + + if ((pw = getpwnam(user)) == NULL) { + fprintf(stderr, "%s: couldn't get user %s from passwd\n", fname, user); + return -1; + } + + if (pipe(pfd) < 0) { + perror("runBsubScriptAsUser: pipe"); + return -1; + } + + if ((pid = fork()) < 0) { + perror("runBsubScriptAsUser: fork"); + return -1; + } + + if (pid == 0) { + /* child process */ + close(pfd[0]); + if (pfd[1] != STDOUT_FILENO) { + if (dup2(pfd[1], STDOUT_FILENO) != STDOUT_FILENO) { + perror("runBsubScriptAsUser (child): dup2"); + _exit(1); + } + close(pfd[1]); + } + if (seteuid(0)) { + perror("runBsubScriptAsUser (child): seteuid 0"); + _exit(1); + } + if (setgid(pw->pw_gid)) { + perror("runBsubScriptAsUser (child): setgid"); + _exit(1); + } + if (setuid(pw->pw_uid)) { + perror("runBsubScriptAsUser (child): setuid"); + _exit(1); + } + arg0 = strrchr(scriptname, '/'); + if (arg0) arg0++; + execl(scriptname, arg0, NULL); + perror("runBsubScriptAsUser (child): execl"); + _exit(1); + } + + /* In the parent */ + close(pfd[1]); + fp = fdopen(pfd[0], "r"); + if (fp == NULL) { + perror("runBsubScriptAsUser: fdopen"); + } + while (fgets(buf, 512, fp)) { + sscanf(buf, "Job <%d> is submitted to default queue <%*s>.\n", &jobid); + } + fclose(fp); + + if (waitpid(pid, NULL, 0) < 0) { + perror("runBsubScriptAsUser: waitpid"); + return -1; + } + + return jobid; +} + +int +rm_submitJob(struct soap *s, struct jobcard *jc, + char *osuser, char **return_jobid) +{ + static char fname[] = "rm_submitJob"; + char scriptname[MAXPATHLEN], wrappername[MAXPATHLEN]; + char buf[512]; + int fd, i, rc, jobid = 0, rr = 0; + FILE *script; + struct envvar *cur; + + fprintf(stderr, "In rm_submitJob...\n"); + + if (!jc || !jc->executable) { + fprintf(stderr, "%s: Need to have the executable name\n", fname); + return BESE_OTHER; + } + if (!osuser) { + fprintf(stderr, "%s: Need to have the os user\n", fname); + return BESE_OTHER; + } + + strcpy(scriptname, "/tmp/besserver.XXXXXX"); + fd = mkstemp(scriptname); + if (fd == -1) { + perror("rm_submitJob: mkstemp"); + return BESE_OTHER; + } + script = fdopen(fd, "w"); + if (script == NULL) { + perror("rm_submitJob: fdopen"); + return BESE_OTHER; + } + + fprintf(script, "#!/bin/sh\n"); + if (jc->wd) + fprintf(script, "LSB_JOB_LONG_CWD=%s; export LSB_JOB_LONG_CWD\n", + jc->wd); + for (cur = jc->environment; cur; cur = cur->next) { + fprintf(script, "%s=%s; export %s\n", cur->name, cur->val, cur->name); + } + fprintf(script, "bsub "); + if (jc->appname) { + fprintf(script, "-a %s ", jc->appname); + if (LSF_VERSION >= 17) { + fprintf(script, "-app %s ", jc->appname); + } + } + if (jc->jobname) + fprintf(script, "-J %s ", jc->jobname); + if (jc->jobproject) + fprintf(script, "-P %s ", jc->jobproject); + if (jc->num_hostnames) { + fprintf(script, "-m \""); + for (i = 0; i < jc->num_hostnames; i++) + fprintf(script, "%s ", jc->hostnames[i]); + fprintf(script, "\" "); + } + if (jc->exclusive) + fprintf(script, "-x "); + if (jc->tcpu) + fprintf(script, "-n %d ", jc->tcpu); + if (jc->input) + fprintf(script, "-i %s ", jc->input); + if (jc->output) + fprintf(script, "-o %s ", jc->output); + if (jc->error) + fprintf(script, "-e %s ", jc->error); + if (jc->osname) { + if (!rr) { + fprintf(script, "-R \""); + rr = 1; + } else { + fprintf(script, " && "); + } + fprintf(script, "osname == %s", jc->osname); + } + if (jc->osver) { + if (!rr) { + fprintf(script, "-R \""); + rr = 1; + } else { + fprintf(script, " && "); + } + fprintf(script, "osver == %s", jc->osver); + } + if (jc->cpuarch) { + if (!rr) { + fprintf(script, "-R \""); + rr = 1; + } else { + fprintf(script, " && "); + } + fprintf(script, "cpuarch == %s", jc->cpuarch); + } + if (rr) { + fprintf(script, "\" "); + } + + if ((rc = createJobWrapperScript(jc, osuser, wrappername, MAXPATHLEN)) != BESE_OK) { + fclose(script); + unlink(scriptname); + return rc; + } + + fprintf(script, "%s\n", wrappername); + + fclose(script); + + if (chmod(scriptname, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)) { + perror("submitLSFJob: chmod"); + unlink(wrappername); + unlink(scriptname); + return BESE_OTHER; + } + + jobid = runBsubScriptAsUser(scriptname, osuser); + + unlink(scriptname); + + if (jobid < 1) { + return BESE_OTHER; + } + + sprintf(buf, "%ld", jobid); + *return_jobid = soap_strdup(s, buf); + if (!*return_jobid) { + return BESE_MEM_ALLOC; + } + + return BESE_OK; +} + +int +rm_terminateJob(struct soap *s, char *job_id, char *osuser) +{ + static char fname[] = "rm_terminateJob"; + struct passwd *pw; + pid_t pid; + int pfd[2], lsb_rc = LSBE_NO_ERROR; + LS_LONG_INT jobid; + + if (!job_id) { + fprintf(stderr, "%s: missing job id\n", fname); + return BESE_BAD_ARG; + } + jobid = strtol(job_id, NULL, 0); + if (errno == ERANGE || errno == EINVAL) { + fprintf(stderr, "%s: job id should be an integer\n", fname); + return BESE_BAD_ARG; + } + + if (!osuser) { + fprintf(stderr, "%s: need to provide os user\n", fname); + return BESE_BAD_ARG; + } + + if ((pw = getpwnam(osuser)) == NULL) { + fprintf(stderr, "%s: couldn't get user %s from passwd\n", fname, osuser); + return BESE_SYS_ERR; + } + + if (pipe(pfd) < 0) { + perror("rm_terminateJob: pipe"); + return BESE_SYS_ERR; + } + + if ((pid = fork()) < 0) { + perror("rm_terminateJob: fork"); + return BESE_SYS_ERR; + } + + if (pid == 0) { + /* child process */ + close(pfd[0]); + + if (seteuid(0)) { + perror("rm_terminateJob (child): seteuid 0"); + _exit(1); + } + if (setgid(pw->pw_gid)) { + perror("rm_terminateJob (child): setgid"); + _exit(1); + } + if (setuid(pw->pw_uid)) { + perror("rm_terminateJob (child): setuid"); + _exit(1); + } + + if (lsb_signaljob(jobid, SIGKILL)) { + lsb_perror("rm_terminateJob (child)"); + lsb_rc = lsberrno; + } + + if (write(pfd[1], (void*)&lsb_rc, sizeof(lsb_rc)) != sizeof(lsb_rc)) { + perror("rm_terminateJob (child): write"); + _exit(1); + } + _exit(0); + } + + /* In the parent */ + close(pfd[1]); + if (read(pfd[0], (void*)&lsb_rc, sizeof(lsb_rc)) != sizeof(lsb_rc)) { + perror("rm_terminateJob: read"); + lsb_rc = -1; + } + close(pfd[0]); + + if (waitpid(pid, NULL, 0) < 0) { + perror("rm_terminateJob: waitpid"); + return BESE_SYS_ERR; + } + + switch (lsb_rc) { + case -1: + return BESE_SYS_ERR; + break; + case LSBE_NO_ERROR: + return BESE_OK; + break; + case LSBE_PERMISSION: + return BESE_PERMISSION; + break; + case LSBE_NO_JOB: + return BESE_NO_ACTIVITY; + break; + default: + return BESE_BACKEND; + } +} + +int +rm_getJobStatus(struct soap *s, char *job_id, char *osuser, + struct bes__ActivityStatusType **job_status) +{ + struct jobInfoEnt *job; + struct bes__ActivityStatusType *status; + int rc; + LS_LONG_INT jobid; + + if (!job_id || !job_status) { + return BESE_BAD_ARG; + } + jobid = strtol(job_id, NULL, 0); + if (errno == ERANGE || errno == EINVAL) { + fprintf(stderr, "rm_getJobStatus: job id should be an integer\n"); + return BESE_BAD_ARG; + } + + rc = lsb_openjobinfo(jobid, NULL, "all", NULL, NULL, ALL_JOB); + if (rc == -1) { + if (lsberrno == LSBE_NO_JOB) { + return BESE_NO_ACTIVITY; + } + lsb_perror("rm_getJobStatus: lsb_openjobinfo"); + return BESE_BACKEND; + } + + job = lsb_readjobinfo(NULL); + if (job == NULL) { + lsb_perror("rm_getJobStatus: lsb_readjobinfo"); + lsb_closejobinfo(); + return BESE_BACKEND; + } + + status = (struct bes__ActivityStatusType*)soap_malloc(s, sizeof(struct bes__ActivityStatusType)); + if (status == NULL) { + return BESE_MEM_ALLOC; + } + memset(status, 0, sizeof(struct bes__ActivityStatusType)); + + if (IS_PEND(job->status)) { + status->state = Pending; + } + else if (IS_START(job->status)) { + status->state = Running; + } + else if (IS_FINISH(job->status)) { + status->state = Finished; + } + + lsb_closejobinfo(); + + *job_status = status; + + return BESE_OK; +} + +int +rm_getJobInfo(struct soap *s, char *job_id, char *osuser, struct jobcard **job_info) +{ + struct jobInfoEnt *job; + struct jobcard *jc; + char *command, *cp, **cpp; + int rc, i; + LS_LONG_INT jobid; + + if (!job_id || !job_info) { + return BESE_BAD_ARG; + } + jobid = strtol(job_id, NULL, 0); + if (errno == ERANGE || errno == EINVAL) { + fprintf(stderr, "rm_getJobInfo: job id should be an integer\n"); + return BESE_BAD_ARG; + } + + rc = lsb_openjobinfo(jobid, NULL, "all", NULL, NULL, ALL_JOB); + if (rc == -1) { + if (lsberrno == LSBE_NO_JOB) { + return BESE_NO_ACTIVITY; + } + lsb_perror("rm_getJobInfo: lsb_openjobinfo"); + return BESE_BACKEND; + } + + job = lsb_readjobinfo(NULL); + if (job == NULL) { + lsb_perror("rm_getJobInfo: lsb_readjobinfo"); + lsb_closejobinfo(); + return BESE_BACKEND; + } + + jc = (struct jobcard*)soap_malloc(s, sizeof(struct jobcard)); + if (jc == NULL) { + return BESE_MEM_ALLOC; + } + memset(jc, 0, sizeof(struct jobcard)); + + if (job->submit.jobName) { + jc->jobname = soap_strdup(s, job->submit.jobName); + } + if (job->submit.projectName) { + jc->jobproject = soap_strdup(s, job->submit.projectName); + } + if (job->numExHosts) { + jc->num_hostnames = job->numExHosts; + jc->hostnames = (char**)soap_malloc(s, sizeof(char*)*job->numExHosts); + if (!jc->hostnames) { + return BESE_MEM_ALLOC; + } + for (i = 0; i < job->numExHosts; i++) { + jc->hostnames[i] = soap_strdup(s, job->exHosts[i]); + } + jc->tcpu = job->numExHosts; + } + if (job->submit.options & SUB_EXCLUSIVE) { + jc->exclusive = 1; + } + if (job->submit.inFile) { + jc->input = soap_strdup(s, job->submit.inFile); + } + if (job->submit.outFile) { + jc->output = soap_strdup(s, job->submit.outFile); + } + if (job->submit.errFile) { + jc->error = soap_strdup(s, job->submit.errFile); + } + if (job->execCwd) { + jc->wd = soap_strdup(s, job->execCwd); + } + if (job->execUsername) { + jc->username = soap_strdup(s, job->execUsername); + } + + /* first pass copies the command and counts arguments */ + command = soap_strdup(s, job->submit.command); + if (!command) { + return BESE_MEM_ALLOC; + } + cpp = &command; + cp = strsep(cpp, " \t"); + jc->executable = soap_strdup(s, cp); + if (!jc->executable) { + return BESE_MEM_ALLOC; + } + while (cp = strsep(cpp, " \t")) { + jc->num_args++; + } + + /* this second pass copies the arguments */ + if (jc->num_args) { + jc->args = (char**)soap_malloc(s, sizeof(char*)*jc->num_args); + if (!jc->args) { + return BESE_MEM_ALLOC; + } + command = soap_strdup(s, job->submit.command); + if (!command) { + return BESE_MEM_ALLOC; + } + cpp = &command; + cp = strsep(cpp, " \t"); + i = 0; + while (cp = strsep(cpp, " \t")) { + jc->args[i++] = soap_strdup(s, cp); + } + } + + lsb_closejobinfo(); + + *job_info = jc; + + return BESE_OK; +} + +int +rm_getResourceList(struct soap *s, struct rm_filter *filter, + struct rm_resource **resourcelist, int *num_resources) +{ + struct rm_resource *res, *end, *reslist; + struct hostInfo *hinfo; + char *cpuarch, *osname, *osver; + int numhosts = 0, num_res = 0, i; + + hinfo = ls_gethostinfo(NULL, &numhosts, NULL, 0, 0); + if (hinfo == NULL) { + fprintf(stderr, "rm_getResourceList: ls_gethostinfo error: %s\n", ls_sysmsg()); + return BESE_BACKEND; + } + + reslist = end = NULL; + for (i = 0; i < numhosts; i++) { + + if (hinfo[i].maxCpus == 0) { + /* host unavailable at this time */ + continue; + } + + res = (struct rm_resource*)soap_malloc(s, sizeof(struct rm_resource)); + if (res == NULL) { + return BESE_MEM_ALLOC; + } + memset(res, 0, sizeof(struct rm_resource)); + + res->ResourceName = soap_strdup(s, hinfo[i].hostName); + if (res->ResourceName == NULL) { + return BESE_MEM_ALLOC; + } + + res->CPUCount = (double*)soap_malloc(s, sizeof(double)); + if (res->CPUCount == NULL) { + return BESE_MEM_ALLOC; + } + *res->CPUCount = (double)hinfo[i].maxCpus; + + res->PhysicalMemory = (double*)soap_malloc(s, sizeof(double)); + if (res->PhysicalMemory == NULL) { + return BESE_MEM_ALLOC; + } + *res->PhysicalMemory = 1024.0*1024.0*(double)hinfo[i].maxMem; + + res->VirtualMemory = (double*)soap_malloc(s, sizeof(double)); + if (res->VirtualMemory == NULL) { + return BESE_MEM_ALLOC; + } + *res->VirtualMemory = 1024.0*1024.0*(double)hinfo[i].maxSwap; + + if (reslist == NULL) reslist = res; + if (end) end->next = res; + end = res; + num_res++; + } + + if (resourcelist) *resourcelist = reslist; + if (num_resources) *num_resources = num_res; + return BESE_OK; +} + +int +rm_getJobList(struct soap *s, struct rm_filter *filter, struct rm_job **joblist, int *numjobs) +{ + struct rm_job *job, *end, *jlist; + struct jobInfoEnt *jinfo; + char jobid[128]; + int num_jobs, i; + + num_jobs = lsb_openjobinfo(0, NULL, "all", NULL, NULL, ALL_JOB); + if (num_jobs == -1) { + if (lsberrno != LSBE_NO_JOB) { + fprintf(stderr, "rm_getJobList: lsb_openjobinfo: %s\n", lsb_sysmsg()); + return BESE_BACKEND; + } + else { + num_jobs = 0; + jlist = NULL; + } + } + jlist = end = NULL; + for (i = 0; i < num_jobs; i++) { + jinfo = lsb_readjobinfo(NULL); + if (jinfo == NULL) { + fprintf(stderr, "rm_getJobList: lsb_readjobinfo: %s\n", lsb_sysmsg()); + lsb_closejobinfo(); + return BESE_BACKEND; + } + job = (struct rm_job*)soap_malloc(s, sizeof(struct rm_job)); + if (job == NULL) { + lsb_closejobinfo(); + return BESE_MEM_ALLOC; + } + sprintf(jobid, "%ld", jinfo->jobId); + job->jobid = soap_strdup(s, jobid); + if (job->jobid == NULL) { + lsb_closejobinfo(); + return BESE_MEM_ALLOC; + } + if (jlist == NULL) jlist = job; + if (end) end->next = job; + end = job; + } + lsb_closejobinfo(); + + if (joblist) *joblist = jlist; + if (numjobs) *numjobs = num_jobs; + return BESE_OK; +} + +int +rm_getClusterInfo(struct soap *s, struct rm_clusterInfo **clusterinfo) +{ + struct rm_clusterInfo *cinfo; + char *clustername; + + if (!clusterinfo) { + return BESE_BAD_ARG; + } + + cinfo = (struct rm_clusterInfo*)soap_malloc(s, sizeof(struct rm_clusterInfo)); + if (cinfo == NULL) { + return BESE_MEM_ALLOC; + } + memset(cinfo, 0, sizeof(struct rm_clusterInfo)); + + cinfo->IsAcceptingNewActivities = true_; + + clustername = ls_getclustername(); + if (clustername == NULL) { + fprintf(stderr, "rm_getClusterInfo: ls_getclustername: %s\n", ls_sysmsg()); + return BESE_BACKEND; + } + cinfo->CommonName = soap_strdup(s, clustername); + if (cinfo->CommonName == NULL) { + return BESE_MEM_ALLOC; + } + + cinfo->LocalResourceManagerType = (char*)soap_malloc(s, + strlen("http://www.platform.com/bes/2006/08/resourcemanager/LSF") + + strlen(LAVA_CURRENT_VERSION)+1); + if (cinfo->LocalResourceManagerType == NULL) { + return BESE_MEM_ALLOC; + } + sprintf(cinfo->LocalResourceManagerType, + "http://www.platform.com/bes/2006/08/resourcemanager/LSF%s", + LAVA_CURRENT_VERSION); + + *clusterinfo = cinfo; + return BESE_OK; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-09-02 16:48:02
|
Revision: 73 http://bespp.svn.sourceforge.net/bespp/?rev=73&view=rev Author: arkaitzr Date: 2009-09-02 16:47:49 +0000 (Wed, 02 Sep 2009) Log Message: ----------- Added variables from compilation of PBS and SGE Modified Paths: -------------- trunk/Make.config trunk/README.txt trunk/config.h Modified: trunk/Make.config =================================================================== --- trunk/Make.config 2009-09-02 16:37:28 UTC (rev 72) +++ trunk/Make.config 2009-09-02 16:47:49 UTC (rev 73) @@ -4,19 +4,16 @@ # You must set this to the location of your compiled gSOAP # source distribution. This directory will contain the # 'import', 'plugin', 'src' and 'wsdl' sub-directories. -GSOAP_TOP = /home/csmith/src/gsoap-2.7/gsoap +GSOAP_TOP = /home/ar5je/centurion/gsoap/gsoap # # Which resource manager back end to use. Also need to set the # locations of resource manager specific includes and libraries # -RM = rm_lsf -#RM = rm_pbs +#RM = rm_lsf +RM = rm_pbs #RM = rm_sge -RM_INC = $(LSF_INC) -RM_LIBS = $(LSF_LIBS) - # # LSF related variables # @@ -35,6 +32,17 @@ LSF_LIBS = $(LSF_LIB)/libbat.a $(LSF_LIB)/liblsf.a # +# PBS related variables +# +# PBS_LOC is where the 'include' and 'lib' +# directories are located. +PBS_LOC = /usr/pbs +PBS_INC = -I$(PBS_LOC)/include +PBS_LIB = $(PBS_LOC)/lib +PBS_LIBS = -L $(PBS_LIB) -lpbs + + +# # Any extra include and lib directories, or libraries # # -lnsl needed for Linux systems @@ -43,3 +51,16 @@ #EXTRA_LIB = -L/usr/local/lib EXTRA_LIBS = -lnsl +ifeq ($(RM),rm_lsf) + RM_INC = $(LSF_INC) + RM_LIBS = $(LSF_LIBS) +endif +ifeq ($(RM),rm_pbs) + RM_INC = $(PBS_INC) + RM_LIBS = $(PBS_LIBS) +endif +ifeq ($(RM),rm_sge) + RM_INC = $(SGE_INC) + RM_LIBS = $(SGE_LIBS) +endif + Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2009-09-02 16:37:28 UTC (rev 72) +++ trunk/README.txt 2009-09-02 16:47:49 UTC (rev 73) @@ -34,9 +34,11 @@ may vary with other versions. Before building BES++, make sure and compile the gSOAP distribution (you don't actually need to install it). -Currently BES++ only supports the Platform LSF resource manager. Make -sure that LSF is installed on the machine on which you are building the -BES++ code, as you will need access to the LSF header files and libraries. +Currently BES++ supports the Platform LSF resource manager, the Portable +Batch System and the Sun Grid Engine. Make sure that LSF or PBS are +installed on the machine on which you are building the BES++ code, as +you will need access to the header files and libraries. This is not +necessary for SGE. Building the software --------------------- @@ -54,7 +56,9 @@ building on. If you are not sure which architecture to use, and your environment is already setup to use LSF, you can run a command like 'which lsid' to see which architecture specific - directory is appropriate for your machine. + directory is appropriate for your machine. + For PBS, the process is similar. For SGE, there are no variables + to adjust except for RM. c) If you need to set any extra paths to headers files or libraries, use the EXTRA_* macros. @@ -63,12 +67,20 @@ in the besclient sub-directory, and a besserver binary in the besserver sub-directory. +4. In order to interact with PBS and SGE, a Python installation is + required with the pexpect module (http://sourceforge.net/projects/pexpect/). + This module can be downloaded and copied to the besserver/scripts + subdirectory. + Installing the software ----------------------- -You can copy the besclient and besserver binaries wherever you wish -as they have no components which are required to be in any particular -directory. +If used with an LSF resource manager, you can copy the besclient and +besserver binaries wherever you wish as they have no components which +are required to be in any particular directory. For PBS and SGE, however +it is necessary that besserver can execute the Python scripts which are +located under the besserver/scripts subdirectory. The location for these +scripts is defined in config.h. If you would like to support the use of user name and password authentication using PAM, you will need to create a PAM configuration file and install @@ -87,8 +99,8 @@ ===================== Note: in order to run the besserver, it must be able to connect to -your LSF environment. The besserver can be run on any node in the LSF -cluster (including a client-only machine). Make sure and have the LSF +your LSF/PBS/SGE environment. The besserver can be run on any node in the +cluster (including a client-only machine). Make sure and have the environment variables properly initialized before starting the besserver. This can be easily accomplished with a shell script wrapper. There is a sample wrapper in the besserver/samples sub-directory. Modified: trunk/config.h =================================================================== --- trunk/config.h 2009-09-02 16:37:28 UTC (rev 72) +++ trunk/config.h 2009-09-02 16:47:49 UTC (rev 73) @@ -1,6 +1,9 @@ #ifndef _CONFIG_H /* You can set project global definitions and includes here */ +#define BESSERVER_TOP "/home/ar5je/bes++project/trunk/besserver" +#define QSUB "/usr/pbs/bin/qsub" +#define QSUBEXEC "qsub" /* Uncomment the next line if you are building on Mac OS X */ /* #define MACOSX */ @@ -9,6 +12,10 @@ /* Setting the VERSION_STRING macro determines what is output */ /* when using the -V option to besclient and besserver */ #define VERSION_STRING "BES++ 1.1.0, 2009-01-12" +#define STAGE_SCRIPT BESSERVER_TOP "/scripts/stage.py" +#define CRED_SCRIPT BESSERVER_TOP "/scripts/cred.py" +#define PBS_SCRIPT BESSERVER_TOP "/scripts/pbs.py" +#define SGE_SCRIPT BESSERVER_TOP "/scripts/sge.py" /* Don't change this one */ #define COPYRIGHT "Copyright (C) 2006-2009 Platform Computing Corporation" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-09-02 16:37:35
|
Revision: 72 http://bespp.svn.sourceforge.net/bespp/?rev=72&view=rev Author: arkaitzr Date: 2009-09-02 16:37:28 +0000 (Wed, 02 Sep 2009) Log Message: ----------- Added missing #include Modified Paths: -------------- trunk/besserver/rm_pbs.c Modified: trunk/besserver/rm_pbs.c =================================================================== --- trunk/besserver/rm_pbs.c 2009-09-02 16:35:14 UTC (rev 71) +++ trunk/besserver/rm_pbs.c 2009-09-02 16:37:28 UTC (rev 72) @@ -31,6 +31,7 @@ #include "rm_util.h" #include "faults.h" #include "job.h" +#include "../config.h" #include <pbs_error.h> #include <pbs_ifl.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-09-02 16:35:29
|
Revision: 71 http://bespp.svn.sourceforge.net/bespp/?rev=71&view=rev Author: arkaitzr Date: 2009-09-02 16:35:14 +0000 (Wed, 02 Sep 2009) Log Message: ----------- Added Python scripts necessary for file staging in PBS Added SGE support Modified Paths: -------------- trunk/besserver/rm_pbs.c trunk/besserver/rm_util.c trunk/besserver/rm_util.h Added Paths: ----------- trunk/besserver/rm_sge.c trunk/besserver/scripts/ trunk/besserver/scripts/cred.py trunk/besserver/scripts/pbs.py trunk/besserver/scripts/sge.py trunk/besserver/scripts/stageFile.py Modified: trunk/besserver/rm_pbs.c =================================================================== --- trunk/besserver/rm_pbs.c 2009-03-06 19:38:26 UTC (rev 70) +++ trunk/besserver/rm_pbs.c 2009-09-02 16:35:14 UTC (rev 71) @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------- - * bespbs.c + * rm_pbs.c * * PBS server implementation of the OGSA Basic Execution Services * @@ -44,13 +44,6 @@ #include <unistd.h> #include <pwd.h> - -#define PBSLOCATION "/usr/pbs/bin" - -#define QDEL "/usr/pbs/bin/qdel" -#define QDELEXEC "qdel" -#define QSUB "/usr/pbs/bin/qsub" -#define QSUBEXEC "qsub" #define PBS "PBS Resource Manager" //GLOBAL VARIABLES @@ -149,10 +142,10 @@ void printError(char* userMessage) { char *errorMessage; - int connectionIdentifier=pbs_connect(server); - errorMessage=pbs_geterrmsg(connectionIdentifier); + int connectionIdentifier = pbs_connect(server); + errorMessage = pbs_geterrmsg(connectionIdentifier); pbs_disconnect(connectionIdentifier); - fprintf(stderr,"%s\n%s\n",userMessage,errorMessage); + fprintf(stderr, "%s\n%s\n", userMessage, errorMessage); } @@ -274,41 +267,7 @@ } /** - * Gets a month string and returns the month number - * @param month is a 3 letter string with the name of the month - * @return integer number of month -*/ -int monthToInt(char*month) -{ - if(!strcmp(month,"Jan")) - return 1; - if(!strcmp(month,"Feb")) - return 2; - if(!strcmp(month,"Mar")) - return 3; - if(!strcmp(month,"Apr")) - return 4; - if(!strcmp(month,"May")) - return 5; - if(!strcmp(month,"Jun")) - return 6; - if(!strcmp(month,"Jul")) - return 7; - if(!strcmp(month,"Aug")) - return 8; - if(!strcmp(month,"Sep")) - return 9; - if(!strcmp(month,"Oct")) - return 10; - if(!strcmp(month,"Nov")) - return 11; - if(!strcmp(month,"Dec")) - return 12; - return 0; -} - -/** - * Gets a fitlered list of jobs in the queue. + * Gets a filtered list of jobs in the queue. * * This function issues a qstat and then parses the output file to add to * the list the jobs that pass the filters. @@ -316,7 +275,8 @@ * gsoap library after. * @param filters are the filters that are going to be applied. See * HPCBP Advanced Filter Extension. - * @return a list of job ids + * @param joblist list of jobs to return + * @param numjobs number of jobs returned */ int rm_getJobList(struct soap*soap, struct rm_filter* filters, struct rm_job** joblist, int* numjobs) @@ -456,7 +416,7 @@ * and also queries the PBS queue. * @param soap is needed to allocate memory that can be deallocated by the * gsoap library after. - * @return a struct of type clusterInfo with the information needed for the + * @param clusterInf a struct of type clusterInfo with the information needed for the * factory attributes document */ int rm_getClusterInfo(struct soap*soap, struct rm_clusterInfo** clusterInf @@ -489,7 +449,7 @@ struct attrl* attributeList = status->attribs; while(attributeList != NULL) { - //Server_host fot the CommonName element + //Server_host for the CommonName element if(!strcmp(attributeList->name, "server_host")) { clusterInfo->CommonName = soap_strdup(soap, @@ -506,7 +466,7 @@ else if(!strcmp(attributeList->name, "total_jobs")) { //clusterInfo->TotalNumberOfActivities = - // atoi(attributeList->value); + // atoi(attributeList->value); }//pbs_version for the LocalResourceManagerType element else if(!strcmp(attributeList->name, "pbs_version")) { @@ -558,40 +518,6 @@ return BESE_BAD_ARG; } - /* FIXME need to retrive a rm_resource structure instead of the old - * clusterInfo on initialization and getfactoryattribtuesdocument - * if(jc->osname){ - int osNotFound=1; - OSListNode* os=clusterInfo->osList; - while(os->OperatingSystem!=NULL){ - if(!strcmp(os->OperatingSystem,jc->osname)){ - osNotFound=0; - break; - } - os=os->next; - } - if(osNotFound){ - *message="OS not present in the cluster"; - return BESE_BAD_ARG; - } - } - - if(jc->cpuarch){ - int archNotFound=1; - ArchListNode* arch=clusterInfo->archList; - while(arch->CPUArchitecture!=NULL){ - if(!strcmp(arch->CPUArchitecture,jc->cpuarch)){ - archNotFound=0; - break; - } - arch=arch->next; - } - if(archNotFound){ - *message="Architecture not present in the cluster"; - return BESE_BAD_ARG; - } - }*/ - strcpy(scriptname, "/tmp/besserver.XXXXXX"); //Compose the script fd = mkstemp(scriptname); @@ -683,18 +609,15 @@ currentFile->credential->username, currentFile->credential->password); } - /* FIXME - * if(currentFile->userSource == NULL) - fprintf(script,"%s in %s %s\n", STAGESCRIPT, currentFile->source, - currentFile->filename, - currentFile->userSource, - currentFile->passwordSource); - else if(currentFile->passwordSource == NULL) - fprintf(script,"%s in %s %s %s\n",STAGESCRIPT,currentFile->source, - currentFile->filename,currentFile->userSource); - else - fprintf(script,"%s in %s %s %s %s\n",STAGESCRIPT,currentFile->source, - currentFile->filename,currentFile->userSource,currentFile->passwordSource);*/ + //Stage in files + if(currentFile->credential == NULL) + fprintf(script,"%s in %s %s\n", STAGE_SCRIPT, + currentFile->source, currentFile->filename); + else if((currentFile->credential->username != NULL) && + (currentFile->credential->password != NULL)) + fprintf(script,"%s in %s %s %s\n", STAGE_SCRIPT, currentFile->source, + currentFile->filename, currentFile->credential->username, + currentFile->credential->password); } currentFile=currentFile->next; } @@ -712,35 +635,25 @@ fprintf(script," 2> %s ", trim(soap, jc->error)); fprintf(script, "\n"); - /*//Obtain myproxy credentials and start proxy - credentials=jc->credentials; - while(credentials!=NULL) - { - if(!strncmp(credentials->endpoint,"myproxy://",10)) - { - fprintf(script,"%s %s %s %s\n",CRED_SCRIPT,credentials->endpoint, - credentials->username,credentials->password); - } - credentials=credentials->next; - } //Stage out files currentFile = jc->files; - while(currentFile!=NULL) + while(currentFile != NULL) { - if(currentFile->target!=NULL) + if(currentFile->target != NULL) { - if(currentFile->userTarget==NULL) - fprintf(script,"%s out %s %s\n",STAGE_SCRIPT,currentFile->target, - currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); - else if(currentFile->passwordTarget==NULL) - fprintf(script,"%s out %s %s %s\n",STAGE_SCRIPT,currentFile->target, - currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); - else - fprintf(script,"%s out %s %s %s %s\n",STAGE_SCRIPT,currentFile->target, - currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); + if(currentFile->credential == NULL) + fprintf(script,"%s out %s %s\n", STAGE_SCRIPT, currentFile->target, + currentFile->filename); + else if((currentFile->credential->username != NULL) && + (currentFile->credential->password != NULL)) + fprintf(script,"%s out %s %s %s\n", STAGE_SCRIPT, currentFile->target, + currentFile->filename, currentFile->credential->username, + currentFile->credential->password); + if(currentFile->delete) + fprintf(script,"rm %s\n", currentFile->filename); } currentFile=currentFile->next; - }*/ + } //Remove files which DeleteOnTermination equals true currentFile = jc->files; @@ -786,7 +699,7 @@ //Get the information about the current nodes strcpy(outputFile, "/tmp/nodeInfo.XXXXXX"); - rc = executeScriptSameUser(PBS_SCRIPT, PBS_SCRIPT_EXEC, "factory", + rc = executeScriptSameUser(PBS_SCRIPT, "pbs.py", "factory", "", outputFile); strcpy(resource, outputFile); strcat(resource, "RS"); @@ -869,7 +782,7 @@ _exit(1); } #endif - execl(QSUB,QSUBEXEC,scriptname,"-v",variables,(char*)NULL); + execl(QSUB, QSUBEXEC, scriptname,"-v",variables,(char*)NULL); perror("runBsubScriptAsUser (child): execl"); close(pfd[0]); _exit(1); Added: trunk/besserver/rm_sge.c =================================================================== --- trunk/besserver/rm_sge.c (rev 0) +++ trunk/besserver/rm_sge.c 2009-09-02 16:35:14 UTC (rev 71) @@ -0,0 +1,803 @@ +/* ---------------------------------------------------------------- + * rm_pbs.c + * + * SGE server implementation of the OGSA Basic Execution Services + * + * Copyright (C) Arkaitz Ruiz Alvarez. + * ar...@cs... + * Platform Computing Corporation. + * All Rights Reserved. + * + * This file is part of Besserver. + * + * Besserver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +//Includes +#include "rm.h" +#include "rm_util.h" +#include "faults.h" +#include "job.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> + +//! Complete route of the python script to call, defined in Makefile +#define SCRIPT_SGE "./scripts/" +//! Name of the python script to call +#define SCRIPT_SGE_EXEC "sge.py" + +//! Maximum length of the environment variables string +#define MAXVAR_BUFFER 4096 + +//GLOBAL VARIABLES + +//! Python script for SGE communication (absolute route) +char* script_sge; +//! Name of the Python script for SGE communication +char* script_sge_exec; +//! information about the cluster (factory) +struct clusterInfo* clusterInfo; + +/** + * Loads the cluster info and sets the location of the SGE python script. + * @param soap is used to allocate memory deallocatable by the gSOAP library + * @param serverName is not used for the SGE implementation + * @return 0 if connection established, 1 if error + */ +int rm_initialize(struct soap* soap, char* serverName) +{ + char* scriptLocation = (char*) malloc(strlen(SCRIPT_SGE) + + strlen(SCRIPT_SGE_EXEC) + 5); + memset(scriptLocation, 0 ,sizeof(strlen(SCRIPT_SGE) + + strlen(SCRIPT_SGE_EXEC) + 5)); + + scriptLocation = strcat(scriptLocation,SCRIPT_SGE); + scriptLocation = strcat(scriptLocation,"/"); + scriptLocation = strcat(scriptLocation,SCRIPT_SGE_EXEC); + script_sge = scriptLocation; + script_sge_exec = SCRIPT_SGE_EXEC; + + return BESE_OK; +} + +/** + * Prints an error message to stderr + * @param message string to print + */ +void printError(char* message) +{ + fprintf(stderr,message); +} + +/** + * Returns 0 as the code of the last error that occurred since this does + * not apply to the SGE implementation + * @return 0 + */ +int getErrNo() +{ + return 0; +} + +/** + * Terminates a job. + * @param jobid is the PID assigned by the queue + * @param user is a string with the account of the user who requested the + * job deletion + * @return 0 if correct, non-zero if error + */ +int rm_terminateJob(struct soap*s, char* jobid, char* user) +{ + char outputFile[256]; + FILE* fd; + int rc; + int deleted; + + strcpy(outputFile, "/tmp/besserver.XXXXXX"); + + rc = executeScript(user, script_sge, script_sge_exec, "delete", + jobid, outputFile); + if (rc) + { + //There was an error deleting the job + unlink(outputFile); + return rc; + } + else { + fd = fopen(outputFile, "r"); + fscanf(fd, "%d", &deleted); + unlink(outputFile); + if (deleted) + return BESE_BACKEND; + else + return BESE_OK; + } +} + +/** + * Gets the status of the job. + * + * It maps the different states of SGE jobs to + * pending and running. It does not make a difference between finished, + * cancelled, terminated and unknown jobs since SGE does not store this info. + * @param jobid is the PID assigned by the queue + * @param user is a string with the account of the user who requested the + * job status + * @param jobStatus is an output parameter with the status of the job -NULL + * if error- + * @return 0 if correct, non-zero if error + */ + +int rm_getJobStatus(struct soap*s, char* jobid, char* user, struct bes__ActivityStatusType** jobStatus) +{ + struct bes__ActivityStatusType *activityStatus; + char outputFile[256]; + FILE* fd; + int rc; + char status; + + if (!jobid || !jobStatus) { + return BESE_BAD_ARG; + } + + activityStatus = (struct bes__ActivityStatusType*)soap_malloc(s, sizeof(struct bes__ActivityStatusType)); + if (activityStatus == NULL) { + return BESE_MEM_ALLOC; + } + memset(activityStatus, 0, sizeof(struct bes__ActivityStatusType)); + + strcpy(outputFile, "/tmp/besserver.XXXXXX"); + + rc = executeScript(user, script_sge, script_sge_exec, "status", + jobid, outputFile); + if (rc) + { + //There was an error + *jobStatus = NULL; + unlink(outputFile); + return BESE_BACKEND; + } + else { + fd = fopen(outputFile,"r"); + fscanf(fd,"%c",&status); + unlink(outputFile); + switch(status){ + case 'u': return BESE_NO_ACTIVITY; + case 'd': activityStatus->state = Finished; break; + case 't': activityStatus->state = Pending; break; + case 'r': activityStatus->state = Running; break; + case 'R': activityStatus->state = Running; break; + case 's': activityStatus->state = Pending; break; + case 'S': activityStatus->state = Pending; break; + case 'T': activityStatus->state = Pending; break; + case 'w': activityStatus->state = Pending; break; + case 'h': activityStatus->state = Pending; break; + default: return BESE_BACKEND; + } + *jobStatus = activityStatus; + return BESE_OK; + } +} + +/** + * Gets the information about a job. + * + * @param jobid is the PID assigned by the queue + * @param soap + * @param jobInfo is an output parameter which contains the information + * about the job submission request and the job state (NULL if error). + * @return 0 if correct, non-zero if error + */ +int rm_getJobInfo(struct soap* soap, char* jobid, char*user, struct jobcard** jobInfo ) +{ + char outputFile[256]; + char *list; + int size; + char character; + int rc; + FILE* fd; + + *jobInfo = NULL; + strcpy(outputFile, "/tmp/besserver.XXXXXX"); + + rc = executeScriptSameUser( script_sge, script_sge_exec, "activity", + jobid, outputFile); + if (rc) + { + //There was an error + *jobInfo = NULL; + unlink(outputFile); + return rc; + } + else { + fd = fopen(outputFile, "r"); + character = fgetc(fd); + size = 0; + while(character != EOF){ + size++; + character = fgetc(fd); + } + fseek (fd, 0 , SEEK_SET ); + list = (char*) soap_malloc( soap, sizeof(char)*size + 5); + memset(list, 0 , sizeof(char)*size + 5); + fscanf(fd, "%s", list); + fclose(fd); + unlink(outputFile); + if ((list==NULL) && (!strcmp(list,"list=NULL"))) + return BESE_NO_ACTIVITY; + } + + *jobInfo = (struct jobcard*) soap_malloc(soap, sizeof(struct jobcard)); + fillJobStatusDefaults(*jobInfo); + getRequestInfo(soap, list, *jobInfo); + return BESE_OK; +} + + +/** + * Gets a filtered list of jobs in the queue. + * + * This function issues a qstat and then parses the output file to add to + * the list the jobs that pass the filters. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @param filters are the filters that are going to be applied. See + * HPCBP Advanced Filter Extension. + * @return a list of job ids + */ +int rm_getJobList(struct soap* s, struct rm_filter* filters, + struct rm_job** joblist, int* numjobs) +{ + struct rm_job* jobList; + char filename[128]; + char command[256]; + struct rm_filter* filter; + int jobid; + int scan; + char ignore[128]; + int numJobs = 0; + + strcpy(filename, "/tmp/queueStatus.XXXXXX"); + int fd = mkstemp(filename); + if (fd == -1) { + return BESE_SYS_ERR; + } + close(fd); + + sprintf(command, "qstat -f | grep '\\(Job Id\\)\\|\\(Job_Owner\\)\\|\\(qtime\\)\\|\\(job_state\\)' > %s ", filename); + //printf(command); + + system(command); + + FILE* in = fopen(filename, "r"); + if (in == NULL) + return BESE_SYS_ERR; + + scan = fscanf(in, "Job Id: %d.%s\n", &jobid, ignore); + filter = filters; + while (scan != EOF) { + char state[64]; + char user[32]; + char week[16],month[16]; + int day, hour, minute, second, year; + int skip = 0, found = 0, filterPresent = 0; + fscanf(in, "\tJob_Owner = %s\n", user); + fscanf(in, "job_state = %s\n", state); + fscanf(in, "qtime = %s %s %d %d:%d:%d %d\n", week, month, &day, &hour, + &minute, &second, &year); + + //Chek for the users if we have to + filter = filters; + found = 0; + filterPresent = 0; + while ((filter != NULL) && (!found)){ + if (filter->user != NULL){ + filterPresent = 1; + if (!strncmp(filter->user, user, strlen(filter->user))) + found = 1; + } + filter = filter->next; + } + if (!found && filterPresent) + skip = 1; + + //Chek for the state + filter = filters; + found = 0; + filterPresent = 0; + while ((filter != NULL) && (!skip) && (!found)){ + if (filter->state != NULL){ + filterPresent = 1; + if (!strcmp(filter->state, "Pending")) + if (!strcmp(state, "Q")) + found = 1; + if (!strcmp(filter->state, "Running")) + if(!strcmp(state, "R")) + found = 1; + } + filter = filter->next; + } + if(!found && filterPresent) + skip = 1; + + //Check for the ID interval + filter = filters; + found = 0; + filterPresent = 0; + while((filter!=NULL)&&(!skip)&&(!found)){ + if((filter->startRange>0)&&(filter->endRange>0)){ + filterPresent=1; + if((jobid>=filter->startRange) &&(jobid<=filter->endRange)) + found=1; + } + filter=filter->next; + } + if(!found&&filterPresent) + skip=1; + + //Check for the time interval + filter=filters; + found=0; + filterPresent=0; + while((filter!=NULL)&&(skip==0)&&(!found)){ + if((filter->endTime!=NULL)&&(filter->startTime!=NULL)){ + char date[64]; + filterPresent=1; + sprintf(date,"%4d%2d%2d%T%2d:%2d:%2d",year,monthToInt(month),day,hour,minute,second); + if((strcmp(date,filter->endTime)<0)&&(strcmp(date,filter->startTime)>0)) + found=1; + } + filter=filter->next; + } + if(!found&&filterPresent) + skip=1; + + if(!skip){ + struct rm_job* newJob=(struct rm_job *)soap_malloc(s, + sizeof(struct rm_job)); + char jobidStr[sizeof(int)*8+1]; + if (!newJob) + return BESE_MEM_ALLOC; + memset(newJob, 0, sizeof(struct rm_job)); + sprintf(jobidStr,"%d",jobid); + newJob->jobid = soap_strdup(s, jobidStr); + newJob->next = jobList; + jobList = newJob; + numJobs++; + } + + scan=fscanf(in,"Job Id: %d.%s\n",&jobid,ignore); + } + fclose(in); + unlink(filename); + + *joblist = jobList; + *numjobs = numJobs; + + return BESE_OK; +} + +char * readLineFromFile(struct soap* s, FILE* fd) +{ + char line[256]; + int rc = fscanf(fd,"%s\n",line); + if (rc == 0) + { + fclose(fd); + return NULL; + } + return soap_strdup(s, line); +} + +int +rm_getResourceList(struct soap *soap, struct rm_filter *filter, + struct rm_resource **resourcelist, int *num_resources) +{ + int rc; + FILE* fd; + char outputFile[255]; + char resource[255]; + //Get the information about the current nodes + strcpy(outputFile, "/tmp/nodeInfo.XXXXXX"); + + rc = executeScriptSameUser(SCRIPT_SGE, SCRIPT_SGE_EXEC, "factory", + "", outputFile); + strcpy(resource, outputFile); + strcat(resource, "RS"); + if (rc) + { + //There was an error + unlink(resource); + return rc; + } + else + { + int scriptReturn; + fd = fopen(outputFile,"r"); + fscanf(fd, "%d",&scriptReturn); + fclose(fd); + unlink(outputFile); + if(scriptReturn) + { + unlink(resource); + return BESE_OTHER; + } + } + + rc = loadResourceFile(soap, resourcelist, resource, num_resources); + unlink(resource); + + return rc; +} + + +/** + * Gets the factory attributes. + * + * This function uses @see loadResourceFile + * and also queries the SGE queue. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @return a struct of type clusterInfo with the information needed for the + * factory attributes document + */ +int rm_getClusterInfo(struct soap* s, struct rm_clusterInfo** clusterInf + /*,int compactResources*/) +{ + struct rm_clusterInfo* clusterInfo; + struct rm_resource* resourcesInfo; + char outputFile[256]; + char resourceFile[256]; + FILE* fd; + int rc; + long int jobId; + int num_resources; + + if (!clusterInf) { + return BESE_BAD_ARG; + } + clusterInfo = (struct rm_clusterInfo*) soap_malloc(s, + sizeof(struct rm_clusterInfo)); + if (clusterInfo == NULL) + return BESE_MEM_ALLOC; + memset(clusterInfo, 0, sizeof(struct rm_clusterInfo)); + + memset(resourceFile,0, sizeof(resourceFile)); + memset(outputFile,0, sizeof(outputFile)); + strcpy(outputFile, "/tmp/besserver.XXXXXX"); + strcat(resourceFile, outputFile); + strcat(resourceFile, "R"); + + /*if (!compact_resources) + rc = executeScriptSameUser(script_sge, script_sge_exec, "factory", + resourceFile, outputFile); + else*/ + rc = executeScriptSameUser(script_sge, script_sge_exec, "factory", + resourceFile, outputFile); + if (rc) + { + //There was an error + unlink(outputFile); + return BESE_BACKEND; + } + else + { + int scriptReturn; + fd = fopen(outputFile,"r"); + fscanf(fd, "%d",&scriptReturn); + fclose(fd); + unlink(outputFile); + if (scriptReturn != 0) + return BESE_BACKEND; + } + + rc = loadResourceFile(s, &resourcesInfo, resourceFile, &num_resources); + unlink(resourceFile); + + if(rc) + return BESE_BACKEND; + + //Load the file with the SGE queue properties + fd = fopen(outputFile, "r"); + + if(!strcmp(readLineFromFile(s, fd), "0")) + clusterInfo->IsAcceptingNewActivities = false_; + else + clusterInfo->IsAcceptingNewActivities = true_; + + clusterInfo->CommonName = readLineFromFile(s, fd); + clusterInfo->LongDescription = readLineFromFile(s, fd); + clusterInfo->LocalResourceManagerType = readLineFromFile(s, fd); + fclose(fd); + unlink(outputFile); + + *clusterInf = clusterInfo; + + return BESE_OK; +} + +/** + * Submits a job to the queuing system. + * + * It generates a script file and sends + * it to the queue. + * @param jc stores all the information about the job + * @param soap is used to allocate memory that can be freed by the gsoap + * library + * @param message is the description of the error ocurred (if any) + * @return job PID if correct, negative integer if error + */ +int rm_submitJob( struct soap* soap, struct jobcard *jc, + char* user, char** return_jobid) +{ + static char fname[] = "submitJob"; + char scriptname[64]; + int fd, i, rc, jobid = 0, rr = 0; + FILE *script; + FILE *result; + + fprintf(stderr, "In submitJob...\n"); + + if (!jc || !jc->executable || !jc->username) { + fprintf(stderr, "Need to have the executable name and username\n"); + return BESE_BAD_ARG; + } + + //TO-DO: implement candidate hosts + if(jc->num_hostnames>0){ + fprintf(stderr, "Candidate Hosts unsupported by SGE\n"); + return BESE_BAD_ARG; + } + + /*if(jc->osname){ + int osNotFound=1; + OSListNode* os=clusterInfo->osList; + while(os->OperatingSystem!=NULL){ + if(!strcmp(os->OperatingSystem,jc->osname)){ + osNotFound=0; + break; + } + os=os->next; + } + if(osNotFound){ + *message="OS not present in the cluster"; + return BESE_BAD_ARG; + } + } + + if(jc->cpuarch){ + int archNotFound=1; + ArchListNode* arch=clusterInfo->archList; + while(arch->CPUArchitecture!=NULL){ + if(!strcmp(arch->CPUArchitecture,jc->cpuarch)){ + archNotFound=0; + break; + } + arch=arch->next; + } + if(archNotFound){ + *message="Architecture not present in the cluster"; + return BESE_BAD_ARG; + } + }*/ + + strcpy(scriptname, "/tmp/besserver.XXXXXX"); + //Compose the script + fd = mkstemp(scriptname); + if (fd == -1) { + perror("submitJob: mkstemp"); + fprintf(stderr, "Can not write SGE script file to disk\n"); + return BESE_SYS_ERR; + } + script = fdopen(fd, "w"); + if (script == NULL) { + perror("submitJob: fdopen"); + fprintf(stderr, "Can not write SGE script file to disk\n"); + return BESE_SYS_ERR; + } + + fprintf(script, "#!/bin/sh\n"); + + if(jc->jobname!=NULL) + fprintf(script,"#$ -N %s\n", jc->jobname); + //List of nodes for the job + fprintf(script,"#$ -pe * "); + /*switch(jc->tcpuType) + { + case EXACT: fprintf(script,"%u",jc->tcpu.exact);break; + case LOWERBOUND: fprintf(script, "%u", + jc->tcpu.lowerBound.exclusive?jc->tcpu.lowerBound.bound+1: + jc->tcpu.lowerBound.bound);break; + case UPPERBOUND: fprintf(script, "1-%u", + jc->tcpu.upperBound.exclusive?jc->tcpu.upperBound.bound: + jc->tcpu.upperBound.bound+1);break; + case RANGE: fprintf(script, "%u-%u", + jc->tcpu.range.exclusiveLower?jc->tcpu.range.lowerBound+1: + jc->tcpu.range.lowerBound, + jc->tcpu.range.exclusiveUpper?jc->tcpu.range.upperBound+1: + jc->tcpu.range.upperBound);break; + default:fprintf(script,"1"); + }*/ + fprintf(script,"%u",jc->icpu); + + fprintf(script, "\n"); + //List of resources for the job + if(jc->ipmem!=0) + fprintf(script,"#$ -l s_vmem=%u\n",jc->ipmem); + if(jc->ivmem!=0) + fprintf(script,"#$ -l h_vmem=%u\n",jc->ivmem); + //End of list of resources + if(jc->wd==NULL) + jc->wd="~"; + fprintf(script,"#$ -j y\n"); + if(jc->jobproject!=NULL) + fprintf(script,"#$ -%s %s\n","A",jc->jobproject); + + //Store the submitting info in environment variables for later use + char list[MAXVAR_BUFFER]; + if(jc->wd!=NULL) + sprintf(list,"SGE_O_HOME=/home/%s,SGE_O_LOGNAME=%s,SGE_O_SHELL=/bin/bash,SGE_O_WORKDIR=%s",jc->username,jc->username,jc->wd); + else + sprintf(list,"SGE_O_HOME=/home/%s,SGE_O_LOGNAME=%s,SGE_O_SHELL=/bin/bash,SGE_O_WORKDIR=/home/%s",jc->username,jc->username,jc->username); + addRequestInfo(soap, list, jc); + + struct envvar* variableList = jc->environment; + int envVariablesSize = 0; + for(;variableList != NULL; variableList = variableList->next) + { + char *variable; + envVariablesSize+= strlen(variableList->name) + + strlen(variableList->val) + 5; + if (envVariablesSize > MAXVAR_BUFFER) + break; + variable = (char*) soap_malloc(soap, strlen(variableList->name) + + strlen(variableList->val) + 5); + sprintf(variable, ",%s=%s", variableList->name, variableList->val); + strcat(list, variable); + free(variable); + } + fprintf(script, "#$ -v %s\n", list); + + fprintf(script, "cd %s\n", jc->wd); + + //Obtain myproxy credentials ans start proxy + /*struct cred* credentials = jc->credentials; + while(credentials != NULL) + { + if(!strncmp(credentials->endpoint, "myproxy://", 10)) + { + fprintf(script, "%s %s %s %s\n", CREDSCRIPT, credentials->endpoint, + credentials->username, credentials->password); + } + credentials = credentials->next; + } + + //Stage in files + struct fileStage* currentFile=jc->files; + while(currentFile != NULL) + { + if(currentFile->source != NULL) + { + if(currentFile->userSource == NULL) + fprintf(script,"%s in %s %s\n", STAGESCRIPT, currentFile->source, + currentFile->filename, currentFile->userSource, + currentFile->passwordSource); + else if(currentFile->passwordSource==NULL) + fprintf(script, "%s in %s %s %s\n", STAGESCRIPT, + currentFile->source, currentFile->filename, + currentFile->userSource); + else + fprintf(script, "%s in %s %s %s %s\n", STAGESCRIPT, + currentFile->source, currentFile->filename, + currentFile->userSource, + currentFile->passwordSource); + } + currentFile = currentFile->next; + }*/ + + //The executable + if (jc->executable) + fprintf(script, "%s", jc->executable); + for (i = 0; i < jc->num_args; i++) + fprintf(script, " %s", jc->args[i]); + if(jc->input!=NULL) + fprintf(script," < %s ",jc->input); + if(jc->output!=NULL) + fprintf(script," > %s ",jc->output); + if(jc->error!=NULL) + fprintf(script," 2> %s ",jc->error); + fprintf(script, "\n"); + + //Stage out files + /*currentFile = jc->files; + while(currentFile!=NULL) + { + if(currentFile->target != NULL) + { + if(currentFile->userTarget == NULL) + fprintf(script, "%s out %s %s\n", STAGESCRIPT, currentFile->target, + currentFile->filename, currentFile->userTarget, + currentFile->passwordTarget); + else if(currentFile->passwordTarget==NULL) + fprintf(script, "%s out %s %s %s\n", STAGESCRIPT, + currentFile->target, currentFile->filename, + currentFile->userTarget, currentFile->passwordTarget); + else + fprintf(script, "%s out %s %s %s %s\n", STAGESCRIPT, + currentFile->target, currentFile->filename, + currentFile->userTarget, currentFile->passwordTarget); + } + currentFile = currentFile->next; + } + + //Remove files which DeleteOnTermination equals true + currentFile=jc->files; + while(currentFile!=NULL) + { + if(currentFile->deleteFile){ + fprintf(script,"rm %s\n",currentFile->filename); + } + currentFile=currentFile->next; + }*/ + + fclose(script); + + if (chmod(scriptname, S_IRWXU)) { + perror("submitJob: chmod"); + fprintf(stderr, "Can not write SGE script file to disk\n"); + return BESE_SYS_ERR; + } + + + char outputFile[256]; + strcpy(outputFile, "/tmp/besserver.XXXXXX"); + + int submission = executeScriptSameUser( script_sge, script_sge_exec, + "submit", scriptname, outputFile); + //Delete the temporal script file + unlink(scriptname); + + if(submission!=0){ + fprintf(stderr, "SGE error code"); + unlink(outputFile); + return BESE_SYS_ERR; + } + + result = fopen(outputFile, "r"); + int pid=0; + fscanf(result,"%d",&pid); + fclose(result); + unlink(outputFile); + + if(pid<=0){ + fprintf(stderr, "SGE error code"); + return BESE_SYS_ERR; + } + + *return_jobid = (char*)soap_malloc(soap, sizeof(int)*8+1); + sprintf(*return_jobid,"%d", jobid); + + return BESE_OK; +} + Property changes on: trunk/besserver/rm_sge.c ___________________________________________________________________ Added: svn:executable + * Modified: trunk/besserver/rm_util.c =================================================================== --- trunk/besserver/rm_util.c 2009-03-06 19:38:26 UTC (rev 70) +++ trunk/besserver/rm_util.c 2009-09-02 16:35:14 UTC (rev 71) @@ -43,7 +43,6 @@ char *OPERATING_SYSTEM_NAME[] = {"LINUX"}; char *OPERATING_SYSTEM_VERSION[] = {"2.6.9"}; char *CPU_ARCHITECTURE[] = {"x86", "x86_64"}; -#define DESCRIPTION_CLUSTER "This is a cluster managed by the UVA CS Grid group" /** @@ -194,7 +193,6 @@ void getRequestInfo(struct soap* soap, char* list, struct jobcard* jobInfo) { char *variable; - //fprintf(stderr, "%s\n", list); jobInfo->args = (char**) soap_malloc(soap, sizeof(char**)*50); for ( variable = strtok(list,","); variable != NULL; variable = strtok(NULL, ",") ) @@ -209,14 +207,10 @@ if(!strcmp(name, "HPCP_JOB_NAME")) { - //jobInfo->jobname = (char*) soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->jobname, varValue); jobInfo->jobname = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_JOB_PROJECT")) { - //jobInfo->jobproject = (char*) soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->jobproject, varValue); jobInfo->jobproject = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_EXCLUSIVE")) @@ -225,63 +219,43 @@ } else if(!strcmp(name, "HPCP_OSNAME")) { - //jobInfo->osname = (char*) soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->osname, varValue); jobInfo->osname = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_CPU_ARCH")) { - //jobInfo->cpuarch = (char*) soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->cpuarch, varValue); jobInfo->cpuarch = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_TOTAL_CPU_COUNT")) { jobInfo->icpu = atoi(varValue); - //jobInfo->tcpuType = EXACT; } else if(!strcmp(name, "HPCP_APP_EXECUTABLE")) { - //jobInfo->executable = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->executable, varValue); jobInfo->executable = soap_strdup(soap, varValue); } else if(!strncmp(name, "HPCP_APP_ARG",12)) { - //jobInfo->args[jobInfo->num_args] = (char*) soap_malloc(soap, - // strlen(varValue)); - //strcpy(jobInfo->args[jobInfo->num_args], varValue); jobInfo->args[jobInfo->num_args] = soap_strdup(soap, varValue); jobInfo->num_args += 1; } else if(!strcmp(name, "HPCP_APP_INPUT")) { - //jobInfo->input = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->input, varValue); jobInfo->input = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_APP_OUTPUT")) { - //jobInfo->output = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->output, varValue); jobInfo->output = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_APP_ERROR")) { - //jobInfo->error = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->error, varValue); jobInfo->error = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_APP_WD")) { - //jobInfo->wd = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->wd,varValue); jobInfo->wd = soap_strdup(soap, varValue); } else if(!strcmp(name, "HPCP_APP_USERNAME")) { - //jobInfo->username = (char*)soap_malloc(soap, strlen(varValue)); - //strcpy(jobInfo->username, varValue); jobInfo->username = soap_strdup(soap, varValue); } else @@ -298,95 +272,6 @@ } /** - * Loads the cluster resource information file into a clsuterInfo variable. - * - * The cluster resource information files are defined in RESOURCE_FILE, - * bescluster.h - * RESOURCE_FILE is a text file. - * @param clusterInfo is a pointer to a valid an zeroed clusterInfo struct - * @return 0 is correct, 1 otherwise - */ -/*int loadClusterInfo(struct soap * soap, - struct rm_resource** resources, - char* resourceFilename) -{ - unsigned int TotalCPUCount = 0; - unsigned int TotalAvailableCPUCount = 0; - unsigned int TotalNumberNodes = 0; - unsigned long TotalPhysicalMemory = 0; - unsigned int NumberNodes; - OSListNode *currentOSList,*headOSList; - ArchListNode *currentArchList,*headArchList; - - ResourceListNode *currentRS, *headRSList; -TotalCPUCount = 0; - TotalNumberNodes = 0; - headOSList = NULL; - headArchList = NULL; - headRSList = NULL; - currentOSList = headOSList; - currentArchList = headArchList; - currentRS = headRSList; - - do{ - TotalCPUCount += CPUCount; - if (!strcmp(state, "free")) - TotalAvailableCPUCount += CPUCount; - TotalPhysicalMemory += PhysicalMemory; - TotalNumberNodes ++; - if (currentRS == NULL){ - currentRS = (ResourceListNode*) soap_malloc(soap, - sizeof(ResourceListNode)); - if (headRSList == NULL) - headRSList = currentRS; - }else{ - currentRS->next = (ResourceListNode*) soap_malloc(soap, - sizeof(ResourceListNode)); - currentRS = currentRS->next; - } - memset(currentRS, 0, sizeof(ResourceListNode)); - currentRS->ResourceName = soap_strdup(soap, resourceName); - currentRS->State = soap_strdup(soap, state); - currentRS->CPUCount = CPUCount; - currentRS->PhysicalMemory = PhysicalMemory; - }while(); - - for(count = 0; count < N_OS; count ++) - { - currentOSList = (OSListNode*) soap_malloc(soap, - sizeof(OSListNode)); - memset(currentOSList, 0, sizeof(OSListNode)); - if (headOSList == NULL) - headOSList = currentOSList; - - currentOSList->OperatingSystem = (char*) soap_strdup(soap, - OPERATING_SYSTEM_NAME[count]); - currentOSList->OperatingSystemVersion = (char*) soap_strdup(soap, - OPERATING_SYSTEM_VERSION[count]); - currentOSList = currentOSList->next; - } - - for(count = 0; count < N_ARCH; count ++) - { - currentArchList = (ArchListNode*) soap_malloc(soap, - sizeof(ArchListNode)); - memset(currentArchList, 0, sizeof(ArchListNode)); - if (headArchList == NULL) - headArchList = currentArchList; - - currentArchList->CPUArchitecture = (char*) soap_strdup(soap, - CPU_ARCHITECTURE[count]); - currentArchList = currentArchList->next; - } - - clusterInfo->osList = headOSList; - clusterInfo->archList = headArchList; - clusterInfo->resourceList = headRSList; - clusterInfo->LongDescription = DESCRIPTION_CLUSTER; - - return BESE_OK; -}*/ -/** * Loads the cluster resource information file into the module variable * clusterInfo. * @@ -624,3 +509,38 @@ return output; } + +/** + * Gets a month string and returns the month number + * @param month is a 3 letter string with the name of the month + * @return integer number of month +*/ +int monthToInt(char*month) +{ + if(!strcmp(month,"Jan")) + return 1; + if(!strcmp(month,"Feb")) + return 2; + if(!strcmp(month,"Mar")) + return 3; + if(!strcmp(month,"Apr")) + return 4; + if(!strcmp(month,"May")) + return 5; + if(!strcmp(month,"Jun")) + return 6; + if(!strcmp(month,"Jul")) + return 7; + if(!strcmp(month,"Aug")) + return 8; + if(!strcmp(month,"Sep")) + return 9; + if(!strcmp(month,"Oct")) + return 10; + if(!strcmp(month,"Nov")) + return 11; + if(!strcmp(month,"Dec")) + return 12; + return 0; +} + Modified: trunk/besserver/rm_util.h =================================================================== --- trunk/besserver/rm_util.h 2009-03-06 19:38:26 UTC (rev 70) +++ trunk/besserver/rm_util.h 2009-09-02 16:35:14 UTC (rev 71) @@ -8,17 +8,6 @@ #include <sys/utsname.h> #include <time.h> - -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - -//Location of the scripts to call for file staging, credentials, etc. -#define STAGE_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/stageFile.py" -#define SU_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/su.py" -#define CRED_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/cred.py" -#define PBS_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/pbs.py" -#define PBS_SCRIPT_EXEC "pbs.py" - struct jobForward { struct soap *s; struct bes__CreateActivityType* req; @@ -73,5 +62,6 @@ void fillJobStatusDefaults(struct jobcard*); char* trim(struct soap*,char*); +int monthToInt(char*); #endif /* _BESCLUSTER_H */ Added: trunk/besserver/scripts/cred.py =================================================================== --- trunk/besserver/scripts/cred.py (rev 0) +++ trunk/besserver/scripts/cred.py 2009-09-02 16:35:14 UTC (rev 71) @@ -0,0 +1,32 @@ +#!/usr/bin/python + +#Usage $./cred.py server username password + +import pexpect +import sys +import re +import time + +server=sys.argv[1] +username=sys.argv[2] +password=sys.argv[3] + +if server[:10]=="myproxy://": + server=server[10:] + +if server.find(':')==-1: + port=0 +else: + port=server[server.find(':')+1:] + server=server[:server.find(':')] + +if port==0: + myproxy=pexpect.spawn('myproxy-get-delegation -s%s -l%s\n'%(server,username)); +else: + myproxy=pexpect.spawn('myproxy-get-delegation -s%s -p%s -l%s\n'%(server,port,username)); +myproxy.expect('pass phrase:'); +myproxy.sendline(password); +myproxy.expect(pexpect.EOF) + +print "Credential obtained from " + server + Property changes on: trunk/besserver/scripts/cred.py ___________________________________________________________________ Added: svn:executable + * Added: trunk/besserver/scripts/pbs.py =================================================================== --- trunk/besserver/scripts/pbs.py (rev 0) +++ trunk/besserver/scripts/pbs.py 2009-09-02 16:35:14 UTC (rev 71) @@ -0,0 +1,159 @@ +#!/usr/bin/python + +#Usage $./pbs.py action parameter file.out + +import pexpect +import sys +import re +import os +import stat + +pbs_bin_location = "/usr/pbs/bin" + +def submitJob(scriptFile): + """Submits the scriptFile using qsub and returns + the jobid""" + submit = pexpect.spawn('qsub %s'%(scriptFile)); + output = submit.read(); + submit.close() + pattern = re.compile('Your job \d* .* has been submitted.\r\n'); + jobid = re.compile(' \d* '); + if not pattern.match(output): + return "0"; + return jobid.search(output).group().strip(); + +def statusJob(jobid): + """Gets the status of the job given and returns + a character""" + qstat = pexpect.spawn('/bin/bash -c "qstat | grep %s"'%(jobid)) + output = qstat.read() + qstat.close() + if output == '': + return 'u' + listAttributes = output.rsplit(); + #State is the fifth element + if len(listAttributes) >= 5: + return listAttributes[4] + return 'u' + +def deleteJob(jobid): + """Deletes the job -jobid- from the queue. + return 0 if ok or 1 if not.""" + qdel = pexpect.spawn('qdel %s'%(jobid)); + output = qdel.read(); + qdel.close() + if output == '': + #job is already registered for deletion + return "0" + pattern = re.compile('has registered the job \d* for deletion') + if pattern.search(output) != None: + return "0" + pattern = re.compile('has deleted job \d*') + if pattern.search(output) != None: + return "0" + #Jobid is not known + return "1" + +def activityDocument(jobid): + """Returns a list of environment variables for the job with jobid. + If the job does not exist returns "list=NULL" """ + qstat = pexpect.spawn('qstat -j %s'%(jobid)); + output = qstat.read(); + qstat.close() + if output == '': + #job is already registered for deletion + return "list=NULL" + pattern = re.compile('Following jobs do not exist:') + if pattern.search(output) != None: + return "list=NULL" + pattern = re.compile('env_list:\s*\S*') + list = pattern.search(output) + if list != None: + return list.group().rsplit()[1] + else: + return "list=NULL" + +def factoryDocument(queue, fileOut): + """Writes in fileOut the document with the factory attributes. + Returns '0' if exited correctly.""" + #Compose the file with the information about resources + pbsnodes = pexpect.spawn(pbs_bin_location+"/pbsnodes -a") + nodesInformation = pbsnodes.read() + pbsnodes.close() + output = open(fileOut + "RS", 'w') + hostRE = re.compile("Mom = "+ queue +"\S*") + memRE = re.compile("resources_available.mem = \S*") + cpuRE = re.compile("resources_available.ncpus = \S*") + stateRE = re.compile("state = \S*") + start = True + hostInfo = "" + + for line in nodesInformation.splitlines(): + hostname = hostRE.search(line) + if hostname != None: + if start: + hostInfo = hostInfo + hostname.group().split()[2] + " " + start = False + else: + hostInfo = hostInfo + "\n" + hostname.group().split()[2] + " " + else: + mem = memRE.search(line) + if (mem != None): + hostInfo = hostInfo + str(float(mem.group().split()[2][:-2]) / 1024) + " " + else: + cpu = cpuRE.search(line) + if (cpu != None): + hostInfo = hostInfo + cpu.group().split()[2] + else: + state = stateRE.search(line) + if state != None: + if state.group().split()[2] == "free": + hostInfo = hostInfo + "free " + elif state.group().split()[2] == "job-busy": + hostInfo = hostInfo + "job-busy " + else: + hostInfo = hostInfo + "unavailable" + + for line in hostInfo.splitlines(): + available = re.compile("unavailable") + hostAvailable = available.search(line) + if hostAvailable == None: + attributes = line.split() + output.write(attributes[0] + "\n" + attributes[2] + "\n" + attributes[3] + "\n" + attributes[1] + "\n") + output.close() + + return "0" + +def writeOutput(output, filename): + fileO = open(filename,'w') + fileO.write(output) + fileO.close() + os.chmod(filename,stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR) + return + +if len(sys.argv) >3: + action = sys.argv[1]; + parameter = sys.argv[2]; + fileOut = sys.argv[3]; + + if action == "delete": + output = deleteJob(parameter) + elif action == "status": + output = statusJob(parameter) + elif action == "submit": + output = submitJob(parameter) + elif action == "activity": + output = activityDocument(parameter) + elif action == "factory": + output = factoryDocument(parameter, fileOut) + else: + output = "Incorrect action" + + writeOutput(output,fileOut); + +else: + print "Incorrect number of parameters." + print "$./pbs.py action parameter output_file" + print " action: delete, submit, status or activity" + print " parameter: jobid or scriptFile" + Property changes on: trunk/besserver/scripts/pbs.py ___________________________________________________________________ Added: svn:executable + * Added: trunk/besserver/scripts/sge.py =================================================================== --- trunk/besserver/scripts/sge.py (rev 0) +++ trunk/besserver/scripts/sge.py 2009-09-02 16:35:14 UTC (rev 71) @@ -0,0 +1,160 @@ +#!/usr/bin/python + +#Usage $./sge.py action parameter file.out + +import pexpect +import sys +import re +import os +import stat + +def submitJob(scriptFile): + """Submits the scriptFile using qsub and returns + the jobid""" + submit = pexpect.spawn('qsub %s'%(scriptFile)); + output = submit.read(); + submit.close() + pattern = re.compile('Your job \d* .* has been submitted.\r\n'); + jobid = re.compile(' \d* '); + if not pattern.match(output): + return "0"; + return jobid.search(output).group().strip(); + +def statusJob(jobid): + """Gets the status of the job given and returns + a character""" + qstat = pexpect.spawn("qstat") + output = qstat.read() + qstat.close() + jobRE = re.compile(jobid) + for line in output.splitlines(): + job = jobRE.search(line) + if job!= None: + break + if job != None: + return 'u' + listAttributes = job.group().split() + #State is the fifth element + if len(listAttributes) >= 5: + return listAttributes[4] + return 'u' + +def deleteJob(jobid): + """Deletes the job -jobid- from the queue. + return 0 if ok or 1 if not.""" + qdel = pexpect.spawn('qdel %s'%(jobid)); + output = qdel.read(); + qdel.close() + if output == '': + #job is already registered for deletion + return "0" + pattern = re.compile('has registered the job \d* for deletion') + if pattern.search(output) != None: + return "0" + pattern = re.compile('has deleted job \d*') + if pattern.search(output) != None: + return "0" + #Jobid is not known + return "1" + +def activityDocument(jobid): + """Returns a list of environment variables for the job with jobid. + If the job does not exist returns "list=NULL" """ + qstat = pexpect.spawn('qstat -j %s'%(jobid)); + output = qstat.read(); + qstat.close() + if output == '': + #job is already registered for deletion + return "list=NULL" + pattern = re.compile('Following jobs do not exist:') + if pattern.search(output) != None: + return "list=NULL" + pattern = re.compile('env_list:\s*\S*') + list = pattern.search(output) + if list != None: + return list.group().rsplit()[1] + else: + return "list=NULL" + +def factoryCompactDocument(fileOut): + """Writes in fileOut the document with the factory attributes. + Returns '0' if exited correctly.""" + resource = open(fileOut, 'w') + + node_info = pexpect.run("qstat -f") + hostRE = re.compile(" \d+/\d+ ") + + total_used = 0 + total_available = 0 + for line in node_info.splitlines()[3:]: + cpus = hostRE.search(line) + if cpus != None: + cpu_str = cpus.group() + used = int(cpu_str[:cpu_str.rfind('/')]) + available = int(cpu_str[cpu_str.rfind('/')+1:]) - used + total_used += used + total_available += available + resource.write("clusterA 0 " + str(total_available) + " free\n") + resource.write("clusterU 0 " + str(total_used) + " job-busy\n") + + resource.close() + return "0" + + +def factoryDocument(fileOut): + """Writes in fileOut the document with the factory attributes. + Returns '0' if exited correctly.""" + resource = open(fileOut, 'w') + + node_info = pexpect.run("qhost") + + for line in node_info.splitlines()[3:]: + host = line.split() + if host[5] != "-": + state = "busy" + else: + state = "free" + mem = float(host[4][:-1]) * 1024 *1024 + mem = int(mem) + resourceInfo = host[0] + " " + str(mem)+ " " + host[2] + " " + state + "\n" + resource.write(resourceInfo) + + resource.close() + + return "0" + +def writeOutput(output, filename): + fileO = open(filename,'w') + fileO.write(output) + fileO.close() + os.chmod(filename,stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR) + return + +if len(sys.argv) >3: + action = sys.argv[1]; + parameter = sys.argv[2]; + fileOut = sys.argv[3]; + + if action == "delete": + output = deleteJob(parameter) + elif action == "status": + output = statusJob(parameter) + elif action == "submit": + output = submitJob(parameter) + elif action == "activity": + output = activityDocument(parameter) + elif action == "factory": + output = factoryDocument(parameter) + elif action == "compact": + output = factoryCompactDocument(parameter) + else: + output = "Incorrect action" + + writeOutput(output,fileOut); + +else: + print "Incorrect number of parameters." + print "$./sge.py action parameter output_file" + print " action: delete, submit, status or activity" + print " parameter: jobid or scriptFile" + Property changes on: trunk/besserver/scripts/sge.py ___________________________________________________________________ Added: svn:executable + * Added: trunk/besserver/scripts/stageFile.py =================================================================== --- trunk/besserver/scripts/stageFile.py (rev 0) +++ trunk/besserver/scripts/stageFile.py 2009-09-02 16:35:14 UTC (rev 71) @@ -0,0 +1,106 @@ +#!/usr/bin/python + +#Usage $./stageFile.py mode uri file username password +#mode: in or out + +import pexpect +import sys +import re + +def getHTTP(file,url): + #print 'wget --quiet --output-document=%s %s\n'%(file,url) + http=pexpect.spawn('wget --quiet --output-document=%s %s\n'%(file,url)) + http.expect(pexpect.EOF) + +def getGRIDFTP(file,url): + print 'globus-url-copy %s file://%s'%(url,file) + gftp=pexpect.spawn('globus-url-copy %s file://%s'%(url,file)) + gftp.expect(pexpect.EOF) + +def getFTP(file,server,remoteFile,username,password): + port='' + servername = server + if server.find(':')>0: + port = server[server.find(':')+1:] + servername = server[:server.find(':')] + #print 'ftp %s %s'%(servername,port) + ftp=pexpect.spawn('ftp %s %s'%(servername,port)) + ftp.expect('Name .*: ') + ftp.sendline(username) + ftp.expect('assword:') + ftp.sendline(password) + ftp.expect('ftp> ') + ftp.sendline('get %s %s'%(remoteFile,file)) + ftp.expect('ftp> ') + ftp.sendline('bye') + ftp.expect(pexpect.EOF) + +def getSCP(file,server,remoteFile,username,password): + scp=pexpect.spawn('scp %s@%s:%s %s'%(username,server,remoteFile,file)) + scp.expect('assword:') + scp.sendline(password) + scp.expect(pexpect.EOF) + +def putFTP(file,server,remoteFile,username,password): + port='' + servername = server + if server.find(':')>0: + port = server[server.find(':')+1:] + servername = server[:server.find(':')] + ftp=pexpect.spawn('ftp %s %s'%(servername,port)) + ftp.expect('Name .*: ') + ftp.sendline(username) + ftp.expect('assword:') + ftp.sendline(password) + ftp.expect('ftp> ') + ftp.sendline('put %s %s'%(file,remoteFile)) + ftp.expect('ftp> ') + ftp.sendline('bye') + ftp.expect(pexpect.EOF) + +def putSCP(file,server,remoteFile,username,password): + scp=pexpect.spawn('scp %s %s@%s:%s'%(file,username,server,remoteFile)) + scp.expect('assword:') + scp.sendline(password) + scp.expect(pexpect.EOF) + +def putGRIDFTP(file,url): + gftp=pexpect.spawn('globus-url-copy file://%s %s'%(file,url)) + gftp.expect(pexpect.EOF) + +if len(sys.argv)>5: + password=sys.argv[5] +else: + password="" +if len(sys.argv)>4: + username=sys.argv[4] +else: + username="" + +file=sys.argv[3] +url=sys.argv[2] +protocol=sys.argv[2][:sys.argv[2].find(':')] +server=sys.argv[2][len(protocol)+3:sys.argv[2].find('/',len(protocol)+4)] +remoteFile=sys.argv[2][len(protocol)+len(server)+3:] +mode=sys.argv[1] + +if mode == 'in': + if protocol== 'http': + getHTTP(file,url) + elif protocol== 'ftp': + getFTP(file,server,remoteFile,username,password) + elif protocol== 'scp': + getSCP(file,server,remoteFile,username,password) + elif protocol=='gsiftp': + getGRIDFTP(file,url); + print "File "+file+" staged in from " +url +elif mode=='out': + if protocol== 'ftp': + putFTP(file,server,remoteFile,username,password) + elif protocol== 'scp': + putSCP(file,server,remoteFile,username,password) + elif protocol=='gsiftp': + putGRIDFTP(file,url); + print "File "+file+" staged out to " +url + + Property changes on: trunk/besserver/scripts/stageFile.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-03-06 19:38:48
|
Revision: 70 http://bespp.svn.sourceforge.net/bespp/?rev=70&view=rev Author: arkaitzr Date: 2009-03-06 19:38:26 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Makefile is fixed so rm_util.c is not compiled for an LSF build Modified Paths: -------------- trunk/besserver/Makefile Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2009-03-06 19:25:50 UTC (rev 69) +++ trunk/besserver/Makefile 2009-03-06 19:38:26 UTC (rev 70) @@ -18,7 +18,11 @@ BES_WSDL = bes-factory.wsdl BES_HEADER = bes-factory.h BES_H_FILES = job.h namespaces.h faults.h auth.h rm.h -BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o rm_util.o +ifneq ($(RM),rm_lsf) + BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o rm_util.o +else + BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o +endif SOAP_NS = BESFactoryBinding.nsmap SOAP_H_FILES = soapH.h soapStub.h @@ -42,7 +46,9 @@ soapServer.o: soapServer.c soapClient.o: soapClient.c soapC.o: soapC.c -rm_util.o: rm_util.c +ifneq ($(RM),rm_lsf) + rm_util.o: rm_util.c +endif stdsoap2.o: $(GSOAP_TOP)/stdsoap2.c $(CC) $(CFLAGS) -c $(GSOAP_TOP)/stdsoap2.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-03-06 19:26:01
|
Revision: 69 http://bespp.svn.sourceforge.net/bespp/?rev=69&view=rev Author: arkaitzr Date: 2009-03-06 19:25:50 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Arkaitz's addition to the repository: -rm_util are functions common to PBS and SGE -rm_pbs.c with the PBS code -Makefile includes new file selected for compitalion, rm_util.c Modified Paths: -------------- trunk/besserver/Makefile Added Paths: ----------- trunk/besserver/rm_pbs.c trunk/besserver/rm_util.c trunk/besserver/rm_util.h Modified: trunk/besserver/Makefile =================================================================== --- trunk/besserver/Makefile 2009-03-06 19:23:22 UTC (rev 68) +++ trunk/besserver/Makefile 2009-03-06 19:25:50 UTC (rev 69) @@ -18,7 +18,7 @@ BES_WSDL = bes-factory.wsdl BES_HEADER = bes-factory.h BES_H_FILES = job.h namespaces.h faults.h auth.h rm.h -BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o +BES_OBJ = besserver.o job.o faults.o auth.o $(RM).o rm_util.o SOAP_NS = BESFactoryBinding.nsmap SOAP_H_FILES = soapH.h soapStub.h @@ -37,11 +37,12 @@ job.o: job.c $(BES_H_FILES) $(SOAP_NS) faults.o: faults.c $(BES_H_FILES) $(SOAP_NS) auth.o: auth.c $(BES_H_FILES) $(SOAP_NS) -$(RM).o: $(RM).c $(BES_H_FILES) $(SOAP_NS) +$(RM).o: $(RM).c rm_util.o $(BES_H_FILES) $(SOAP_NS) soapServer.o: soapServer.c soapClient.o: soapClient.c soapC.o: soapC.c +rm_util.o: rm_util.c stdsoap2.o: $(GSOAP_TOP)/stdsoap2.c $(CC) $(CFLAGS) -c $(GSOAP_TOP)/stdsoap2.c Added: trunk/besserver/rm_pbs.c =================================================================== --- trunk/besserver/rm_pbs.c (rev 0) +++ trunk/besserver/rm_pbs.c 2009-03-06 19:25:50 UTC (rev 69) @@ -0,0 +1,908 @@ +/* ---------------------------------------------------------------- + * bespbs.c + * + * PBS server implementation of the OGSA Basic Execution Services + * + * Copyright (C) Arkaitz Ruiz Alvarez. + * ar...@cs... + * Platform Computing Corporation. + * All Rights Reserved. + * + * This file is part of Besserver. + * + * Besserver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +//Includes +#include "rm.h" +#include "rm_util.h" +#include "faults.h" +#include "job.h" +#include <pbs_error.h> +#include <pbs_ifl.h> + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> + + +#define PBSLOCATION "/usr/pbs/bin" + +#define QDEL "/usr/pbs/bin/qdel" +#define QDELEXEC "qdel" +#define QSUB "/usr/pbs/bin/qsub" +#define QSUBEXEC "qsub" +#define PBS "PBS Resource Manager" + +//GLOBAL VARIABLES + +//! error code of the last error ocurred +int errorno = 0; +//! server to connect to +char* server; +//! stores information about the cluster +struct rm_clusterInfo* clusterInfo; +//! stores the resources of the cluster +struct rm_resource* resourceList; +//! number of resources in @resourceList +int * nresources; +//!Compatibility with previous versions of PBS +size_t cred_len = 0; +//!Compatibility with previous versions of PBS +char* cred_buf; +//!Compatibility with previous versions of PBS +int cred_type; + +/** + * Updates the error code. + * + * It takes the PBS error variable (pbs_errno) and + * fills the errono variable of this module. + */ +void updateErrorNo() +{ + switch(pbs_errno){ + case PBSE_NONE: errorno = BESE_OK; break; + case PBSE_UNKJOBID: errorno = BESE_NO_ACTIVITY; break; + case PBSE_PERM: errorno = BESE_PERMISSION; break; + default:fprintf(stderr, "Unkwon PBS error number %u", pbs_errno); break; + } +} + +/** + * Converts a PBS job status struct to a jobcard struct + * + * @param jobInfo struct with the information about the job + * @param soap is used to allocate memory deallocatable by the gSOAP library +*/ +void convertJobInfo(struct soap* soap, + struct jobcard* jobInfo, + struct batch_status* status) +{ + struct attrl* attrList = status->attribs; + //default value + jobInfo->tcpu= 1; + + while (attrList != NULL) + { + if(!strcmp(attrList->name, ATTR_v)) + getRequestInfo(soap, attrList->value, jobInfo); + attrList = attrList->next; + } +} + +/** + * Connects to the PBS queue server and loads cluster info. + * @param soap is used to allocate memory + * @param serverName is a string with the hostname in which the queue is running + * @return 0 if connection established, 1 if error + */ +int rm_initialize(struct soap* soap, char* serverName){ + int connectionIdentifier; + int error_code = BESE_OK; + + if (!serverName) + return BESE_BAD_ARG; + server = (char*) malloc(strlen(serverName) + 1); + nresources = (int*) malloc(sizeof(int)); + strcpy(server,serverName); + connectionIdentifier = pbs_connect(serverName); + if (connectionIdentifier <= 0 ) + return BESE_BACKEND; + pbs_disconnect(connectionIdentifier); + error_code = rm_getClusterInfo(soap, &clusterInfo); + if (error_code != BESE_OK) + return error_code; + else { + printf("Looking for resources now"); + error_code = rm_getResourceList(soap, NULL, &resourceList, nresources); + return error_code; + } +} +/** + * Prints in stderr the error message of the last error. + * + * It gets the error + * description of the last error that happened in the PBS queue server. + * @param userMessage message to append to the output. It may contain + * additional information from the main program + */ +void printError(char* userMessage) +{ + char *errorMessage; + int connectionIdentifier=pbs_connect(server); + errorMessage=pbs_geterrmsg(connectionIdentifier); + pbs_disconnect(connectionIdentifier); + fprintf(stderr,"%s\n%s\n",userMessage,errorMessage); +} + + +/** + * Terminates a job. + * @param jobid is the PID assigned by the queue + * @return 0 if correct, non-zero if error + */ +int rm_terminateJob(struct soap* s, char* jobid, char* user) +{ + int connectionIdentifier = pbs_connect(server); + if (connectionIdentifier < 1 ) + return BESE_BACKEND; + int rc = pbs_deljob(connectionIdentifier, jobid, NULL); + updateErrorNo(); + pbs_disconnect(connectionIdentifier); + return BESE_OK; +} + +/** + * Gets the information about a job. + * + * It stores the info in a module variable. + * In order to retrieve it, use @see readJobInfo. + * @param jobid is the PID assigned by the queue + * @return 0 if correct, non-zero if error + */ +int rm_getJobInfo(struct soap* soap, char* jobid, char* user, + struct jobcard** jobInfo ) +{ + //! stores the status of a job + struct batch_status* status; + int connectionIdentifier; + struct jobcard* job; + + connectionIdentifier = pbs_connect(server); + if(!connectionIdentifier) + return BESE_BACKEND; + status = pbs_statjob(connectionIdentifier, jobid, NULL, NULL); + pbs_disconnect(connectionIdentifier); + if(status == NULL) + return BESE_NO_ACTIVITY; + job = (struct jobcard*)soap_malloc(soap, sizeof(struct jobcard)); + if (!job) + return BESE_MEM_ALLOC; + memset(job, 0, sizeof(struct jobcard)); + + fillJobStatusDefaults(job); + convertJobInfo(soap, job, status); + *jobInfo = job; + pbs_statfree(status); + return BESE_OK; +} + +/** + * Gets the status of the job. + * + * It maps the different states of PBS jobs to + * pending and running. It does not make a difference between finished, + * cancelled, terminated and unknown jobs since PBS does not store this info. + * @param jobid is the PID assigned by the queue + * @return 0 if correct, non-zero if error + */ +int rm_getJobStatus(struct soap* s, char* jobid, char* user, struct bes__ActivityStatusType** jobStatus) +{ + struct bes__ActivityStatusType *activityStatus; + int connectionIdentifier; + //! stores the status of a job + struct batch_status* status; + + if (!jobid || !jobStatus) { + return BESE_BAD_ARG; + } + connectionIdentifier = pbs_connect(server); + if (!connectionIdentifier) + return BESE_BACKEND; + status = pbs_statjob(connectionIdentifier,jobid,NULL,NULL); + pbs_disconnect(connectionIdentifier); + if(status == NULL) + { + return BESE_NO_ACTIVITY; + } + activityStatus = (struct bes__ActivityStatusType*)soap_malloc(s, sizeof(struct bes__ActivityStatusType)); + if (activityStatus == NULL) { + return BESE_MEM_ALLOC; + } + memset(activityStatus, 0, sizeof(struct bes__ActivityStatusType)); + struct attrl* attrList = status->attribs; + while (attrList != NULL) + { + if(!strcmp(attrList->name, ATTR_state)) + { + if(strcmp(attrList->value, "T")) { + activityStatus->state = Pending; + } + else if(strcmp(attrList->value, "Q")) { + activityStatus->state = Pending; + } + else if(strcmp(attrList->value,"H")) { + activityStatus->state = Pending; + } + else if(strcmp(attrList->value,"W")){ + activityStatus->state = Pending; + } + else if(strcmp(attrList->value,"R")){ + activityStatus->state = Running; + } + else if(strcmp(attrList->value,"E")) { + activityStatus->state = Finished; + } + pbs_statfree(status); + *jobStatus = activityStatus; + return BESE_OK; + } + attrList = attrList->next; + } + pbs_statfree(status); + return BESE_NO_ACTIVITY; +} + +/** + * Gets a month string and returns the month number + * @param month is a 3 letter string with the name of the month + * @return integer number of month +*/ +int monthToInt(char*month) +{ + if(!strcmp(month,"Jan")) + return 1; + if(!strcmp(month,"Feb")) + return 2; + if(!strcmp(month,"Mar")) + return 3; + if(!strcmp(month,"Apr")) + return 4; + if(!strcmp(month,"May")) + return 5; + if(!strcmp(month,"Jun")) + return 6; + if(!strcmp(month,"Jul")) + return 7; + if(!strcmp(month,"Aug")) + return 8; + if(!strcmp(month,"Sep")) + return 9; + if(!strcmp(month,"Oct")) + return 10; + if(!strcmp(month,"Nov")) + return 11; + if(!strcmp(month,"Dec")) + return 12; + return 0; +} + +/** + * Gets a fitlered list of jobs in the queue. + * + * This function issues a qstat and then parses the output file to add to + * the list the jobs that pass the filters. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @param filters are the filters that are going to be applied. See + * HPCBP Advanced Filter Extension. + * @return a list of job ids + */ +int rm_getJobList(struct soap*soap, struct rm_filter* filters, + struct rm_job** joblist, int* numjobs) +{ + char filename[128]; + char command[256]; + char ignore[128]; + struct rm_filter* filter; + struct rm_job* jobList; + int numJobs, fd, jobid, scan; + FILE * in; + + strcpy(filename, "/tmp/queueStatus.XXXXXX"); + fd = mkstemp(filename); + if (fd == -1) { + return BESE_SYS_ERR; + } + close(fd); + + sprintf(command,"qstat -f | grep '\\(Job Id\\)\\|\\(Job_Owner\\)\\|\\(qtime\\)\\|\\(job_state\\)' > %s ",filename); + //printf(command); + + system(command); + + in = fopen(filename, "r"); + if (in == NULL) + return BESE_SYS_ERR; + + numJobs = 0; + scan = fscanf(in, "Job Id: %d.%s\n", &jobid, ignore); + filter = filters; + while(scan!=EOF){ + char state[64]; + char user[32]; + char week[16],month[16]; + int day, hour, minute, second, year; + int skip = 0, found = 0, filterPresent = 0; + fscanf(in,"\tJob_Owner = %s\n",user); + fscanf(in,"job_state = %s\n",state); + fscanf(in,"qtime = %s %s %d %d:%d:%d %d\n",week,month,&day,&hour,&minute,&second,&year); + + //Chek for the users if we have to + filter=filters; + found=0; + filterPresent=0; + while((filter != NULL)&&(!found)){ + if(filter->user != NULL){ + filterPresent = 1; + if(!strncmp(filter->user, user, strlen(filter->user))) + found=1; + } + filter = filter->next; + } + if(!found && filterPresent) + skip = 1; + + //Chek for the state + filter = filters; + found = 0; + filterPresent = 0; + while((filter != NULL) && (!skip) && (!found)){ + if(filter->state != NULL){ + filterPresent = 1; + if(!strcmp(filter->state, "Pending")) + if(!strcmp(state,"Q")) + found = 1; + if(!strcmp(filter->state, "Running")) + if(!strcmp(state,"R")) + found = 1; + } + filter = filter->next; + } + if(!found && filterPresent) + skip = 1; + + //Check for the ID interval + filter = filters; + found = 0; + filterPresent = 0; + while((filter != NULL) && (!skip) && (!found)){ + if((filter->startRange>0)&&(filter->endRange>0)){ + filterPresent=1; + if((jobid>=filter->startRange) &&(jobid<=filter->endRange)) + found=1; + } + filter = filter->next; + } + if(!found && filterPresent) + skip = 1; + + //Check for the time interval + filter = filters; + found = 0; + filterPresent = 0; + while((filter != NULL)&&(skip == 0)&&(!found)){ + if((filter->endTime!=NULL)&&(filter->startTime!=NULL)){ + char date[64]; + filterPresent=1; + sprintf(date,"%4d%2d%2d%T%2d:%2d:%2d",year,monthToInt(month),day,hour,minute,second); + if((strcmp(date,filter->endTime)<0)&&(strcmp(date,filter->startTime)>0)) + found=1; + } + filter=filter->next; + } + if(!found&&filterPresent) + skip=1; + + if(!skip){ + struct rm_job* newJob=(struct rm_job *)soap_malloc(soap, + sizeof(struct rm_job)); + char jobidStr[sizeof(int)*8+1]; + if (!newJob) + return BESE_MEM_ALLOC; + memset(newJob, 0, sizeof(struct rm_job)); + sprintf(jobidStr,"%d",jobid); + newJob->jobid = soap_strdup(soap, jobidStr); + newJob->next = jobList; + jobList = newJob; + numJobs++; + } + + scan = fscanf(in,"Job Id: %d.%s\n",&jobid,ignore); + } + fclose(in); + unlink(filename); + *joblist = jobList; + *numjobs = numJobs; + + return BESE_OK; +} + + +/** + * Gets the factory attributes. + * + * This function uses @see loadResourceFile + * and also queries the PBS queue. + * @param soap is needed to allocate memory that can be deallocated by the + * gsoap library after. + * @return a struct of type clusterInfo with the information needed for the + * factory attributes document + */ +int rm_getClusterInfo(struct soap*soap, struct rm_clusterInfo** clusterInf + /*,int compactResources*/) +{ + char outputFile[256]; + FILE* fd; + int rc; + char resource[128]; + int connectionIdentifier = pbs_connect(server); + struct rm_clusterInfo* clusterInfo; + struct rm_resource* resourcesInfo; + struct batch_status* status; + + + if (!clusterInf) { + return BESE_BAD_ARG; + } + clusterInfo = (struct rm_clusterInfo*) soap_malloc(soap, + sizeof(struct rm_clusterInfo)); + if (clusterInfo == NULL) + return BESE_MEM_ALLOC; + memset(clusterInfo, 0, sizeof(struct rm_clusterInfo)); + + //First, contact the PBS queue + status = pbs_statserver(connectionIdentifier,NULL,NULL); + if(status != NULL) + { + //Loop over the list of attributes returned + struct attrl* attributeList = status->attribs; + while(attributeList != NULL) + { + //Server_host fot the CommonName element + if(!strcmp(attributeList->name, "server_host")) + { + clusterInfo->CommonName = soap_strdup(soap, + attributeList->value); + } + //Server_state for the IsAcceptingNewActivities element + else if(!strcmp(attributeList->name, "server_state")) + { + if(!strcmp(attributeList->value, "Active")) + clusterInfo->IsAcceptingNewActivities = true_; + else + clusterInfo->IsAcceptingNewActivities = false_; + }//total_jobs for the TotalNumberOfActivities element + else if(!strcmp(attributeList->name, "total_jobs")) + { + //clusterInfo->TotalNumberOfActivities = + // atoi(attributeList->value); + }//pbs_version for the LocalResourceManagerType element + else if(!strcmp(attributeList->name, "pbs_version")) + { + char* pbsStr = (char*) soap_malloc(soap, strlen(PBS) + + strlen(attributeList->value) + 10); + sprintf(pbsStr, "%s %s %s", PBS, "Version", attributeList->value); + clusterInfo->LocalResourceManagerType = pbsStr; + } + //fprintf(stderr,"Attribute: %s - Value: %s\n",attributeList->name,attributeList->value); + attributeList = attributeList->next; + } + } + + pbs_statfree(status); + pbs_disconnect(connectionIdentifier); + *clusterInf = clusterInfo; + + return BESE_OK; +} + +/** + * Submits a job to the queuing system. + * + * It generates a script file and sends + * it to the queue. + * @param jc stores all the information about the job + * @param soap is used to allocate memory that can be freed by the gsoap + * library + * @param message is the description of the error ocurred (if any) + * @return job PID if correct, negative integer if error + */ +int rm_submitJob(struct soap* soap, struct jobcard *jc, + char* user, char ** return_jobid) +{ + static char fname[] = "submitJob"; + char scriptname[64]; + int fd, i, rc, jobid = 0, rr = 0; + FILE *script; + + fprintf(stderr, "In submitJob...\n"); + + if (!jc || !jc->executable||!jc->username) { + fprintf(stderr, "Need to have the executable name and username\n"); + return BESE_BAD_ARG; + } + + if(jc->num_hostnames>0){ + fprintf(stderr,"Candidate Hosts unsupported by PBS"); + return BESE_BAD_ARG; + } + + /* FIXME need to retrive a rm_resource structure instead of the old + * clusterInfo on initialization and getfactoryattribtuesdocument + * if(jc->osname){ + int osNotFound=1; + OSListNode* os=clusterInfo->osList; + while(os->OperatingSystem!=NULL){ + if(!strcmp(os->OperatingSystem,jc->osname)){ + osNotFound=0; + break; + } + os=os->next; + } + if(osNotFound){ + *message="OS not present in the cluster"; + return BESE_BAD_ARG; + } + } + + if(jc->cpuarch){ + int archNotFound=1; + ArchListNode* arch=clusterInfo->archList; + while(arch->CPUArchitecture!=NULL){ + if(!strcmp(arch->CPUArchitecture,jc->cpuarch)){ + archNotFound=0; + break; + } + arch=arch->next; + } + if(archNotFound){ + *message="Architecture not present in the cluster"; + return BESE_BAD_ARG; + } + }*/ + + strcpy(scriptname, "/tmp/besserver.XXXXXX"); + //Compose the script + fd = mkstemp(scriptname); + if (fd == -1) { + perror("submitJob: mkstemp"); + fprintf(stderr, "Can not write PBS script file to disk\n"); + return BESE_SYS_ERR; + } + script = fdopen(fd, "w"); + if (script == NULL) { + perror("submitJob: fdopen"); + fprintf(stderr, "Can not write PBS script file to disk\n"); + return BESE_SYS_ERR; + } + + fprintf(script, "#!/bin/sh\n"); + + if(jc->jobname!=NULL) + fprintf(script,"#PBS -%s %s\n","N",jc->jobname); + //List of resources for the job + if (jc->icpu || jc->ipmem || jc->ivmem) + fprintf(script,"#PBS -l "); + /* FIXME add suport for range type to the new rm code + * switch(jc->tcpuType) + { + case EXACT:fprintf(script,"nodes=%u",jc->tcpu.exact);break; + case LOWERBOUND:fprintf(script,"nodes=%u",jc->tcpu.lowerBound.exclusive? + jc->tcpu.lowerBound.bound+1:jc->tcpu.lowerBound.bound); + break; + case UPPERBOUND:fprintf(script,"nodes=%u",jc->tcpu.upperBound.exclusive? + jc->tcpu.upperBound.bound:jc->tcpu.upperBound.bound+1);break; + case RANGE:fprintf(script,"nodes=%u",jc->tcpu.range.exclusiveLower? + jc->tcpu.range.lowerBound+1:jc->tcpu.range.lowerBound);break; + default:fprintf(script,"nodes=1"); + }*/ + if (jc->icpu > 0 ) + fprintf(script,"nodes=%d", jc->icpu); + + if(jc->ipmem!=0) + fprintf(script,",pmem=%u",jc->ipmem); + if(jc->ivmem!=0) + fprintf(script,",pvmem=%u",jc->ivmem); + fprintf(script,"\n"); + //End of list of resources + if(jc->wd==NULL) + jc->wd="~"; + if(jc->username!=NULL) + fprintf(script,"#PBS -%s %s\n","u",jc->username); + fprintf(script,"#PBS -j eo\n"); + if(jc->jobproject!=NULL) + fprintf(script,"#PBS -%s %s\n","A",jc->jobproject); + //Store the submitting info in environment variables for later use + char list[3000]; + if(jc->wd!=NULL) + sprintf(list,"PBS_O_HOME=/home/%s,PBS_O_LOGNAME=%s,PBS_O_SHELL=/bin/bash,PBS_O_WORKDIR=%s",jc->username,jc->username,jc->wd); + else + sprintf(list,"PBS_O_HOME=/home/%s,PBS_O_LOGNAME=%s,PBS_O_SHELL=/bin/bash,PBS_O_WORKDIR=/home/%s",jc->username,jc->username,jc->username); + addRequestInfo(soap, list, jc); + + struct envvar* variableList = jc->environment; + for(; variableList != NULL; variableList = variableList->next) + { + strcat(list, ","); + strcat(list, trim(soap, variableList->name)); + strcat(list, "="); + strcat(list, trim(soap, variableList->val)); + } + fprintf(script,"#PBS -v %s\n", trim(soap, list)); + + fprintf(script,"cd %s\n", jc->wd); + + //Stage in files + struct fileStage* currentFile=jc->files; + while(currentFile!=NULL) + { + if(currentFile->source != NULL){ + //Obtain myproxy credentials and start proxy + if((currentFile->credential != NULL) && + (!strncmp(currentFile->source,"myproxy://",10))){ + fprintf(script,"%s %s %s %s\n", CRED_SCRIPT, + currentFile->source, + currentFile->credential->username, + currentFile->credential->password); + } + if((currentFile->credential != NULL) && + (!strncmp(currentFile->target,"myproxy://",10))){ + fprintf(script,"%s %s %s %s\n", CRED_SCRIPT, + currentFile->target, + currentFile->credential->username, + currentFile->credential->password); + } + /* FIXME + * if(currentFile->userSource == NULL) + fprintf(script,"%s in %s %s\n", STAGESCRIPT, currentFile->source, + currentFile->filename, + currentFile->userSource, + currentFile->passwordSource); + else if(currentFile->passwordSource == NULL) + fprintf(script,"%s in %s %s %s\n",STAGESCRIPT,currentFile->source, + currentFile->filename,currentFile->userSource); + else + fprintf(script,"%s in %s %s %s %s\n",STAGESCRIPT,currentFile->source, + currentFile->filename,currentFile->userSource,currentFile->passwordSource);*/ + } + currentFile=currentFile->next; + } + + //The executable + if (jc->executable) + fprintf(script, "%s", jc->executable); + for (i = 0; i < jc->num_args; i++) + fprintf(script, " %s", trim(soap, jc->args[i])); + if(jc->input!=NULL) + fprintf(script," < %s ", trim(soap, jc->input)); + if(jc->output!=NULL) + fprintf(script," > %s ", trim(soap, jc->output)); + if(jc->error!=NULL) + fprintf(script," 2> %s ", trim(soap, jc->error)); + fprintf(script, "\n"); + + /*//Obtain myproxy credentials and start proxy + credentials=jc->credentials; + while(credentials!=NULL) + { + if(!strncmp(credentials->endpoint,"myproxy://",10)) + { + fprintf(script,"%s %s %s %s\n",CRED_SCRIPT,credentials->endpoint, + credentials->username,credentials->password); + } + credentials=credentials->next; + } + //Stage out files + currentFile = jc->files; + while(currentFile!=NULL) + { + if(currentFile->target!=NULL) + { + if(currentFile->userTarget==NULL) + fprintf(script,"%s out %s %s\n",STAGE_SCRIPT,currentFile->target, + currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); + else if(currentFile->passwordTarget==NULL) + fprintf(script,"%s out %s %s %s\n",STAGE_SCRIPT,currentFile->target, + currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); + else + fprintf(script,"%s out %s %s %s %s\n",STAGE_SCRIPT,currentFile->target, + currentFile->filename,currentFile->userTarget,currentFile->passwordTarget); + } + currentFile=currentFile->next; + }*/ + + //Remove files which DeleteOnTermination equals true + currentFile = jc->files; + while(currentFile != NULL){ + if(currentFile->delete){ + fprintf(script, "rm %s\n", currentFile->filename); + } + currentFile=currentFile->next; + } + + fclose(script); + close(fd); + + if (chmod(scriptname, S_IRWXU)) { + perror("submitJob: chmod"); + return BESE_BACKEND; + } + + jobid = runQsubScriptAsUser(scriptname,list,jc->username); + + //Delete the temporal script file + unlink(scriptname); + + if(jobid <= 0){ + fprintf(stderr, "PBS error code"); + return BESE_BACKEND; + } + + *return_jobid = (char*)soap_malloc(soap, sizeof(int)*8+1); + sprintf(*return_jobid,"%d", jobid); + + return BESE_OK; +} + +int +rm_getResourceList(struct soap *soap, struct rm_filter *filter, + struct rm_resource **resourcelist, int *num_resources) +{ + int rc; + FILE* fd; + char outputFile[255]; + char resource[255]; + //Get the information about the current nodes + strcpy(outputFile, "/tmp/nodeInfo.XXXXXX"); + + rc = executeScriptSameUser(PBS_SCRIPT, PBS_SCRIPT_EXEC, "factory", + "", outputFile); + strcpy(resource, outputFile); + strcat(resource, "RS"); + if (rc) + { + //There was an error + unlink(resource); + return rc; + } + else + { + int scriptReturn; + fd = fopen(outputFile,"r"); + fscanf(fd, "%d",&scriptReturn); + fclose(fd); + unlink(outputFile); + if(scriptReturn) + { + unlink(resource); + return BESE_OTHER; + } + } + + rc = loadResourceFile(soap, resourcelist, resource, num_resources); + unlink(resource); + + return rc; +} + +int runQsubScriptAsUser(char *scriptname, char*variables,char *user) +{ + static char fname[] = "runBsubScriptAsUser"; + FILE *fp; + pid_t pid; + int pfd[2], jobid = 0; + struct passwd *pw; + char *arg0, buf[512]; + + if (!scriptname || !user) { + return -1; + } +#ifdef ROOTACCESS + if ((pw = getpwnam(user)) == NULL) { + fprintf(stderr, "%s: couldn't get user %s from passwd\n", fname, user); + return -1; + } +#endif + + if (pipe(pfd) < 0) { + perror("runBsubScriptAsUser: pipe"); + return -1; + } + + if ((pid = fork()) < 0) { + perror("runBsubScriptAsUser: fork"); + return -1; + } + + if (pid == 0) { + /* child process */ + close(pfd[0]); + if (pfd[1] != STDOUT_FILENO) { + if (dup2(pfd[1], STDOUT_FILENO) != STDOUT_FILENO) { + perror("runBsubScriptAsUser (child): dup2"); + _exit(1); + } + close(pfd[1]); + } +#ifdef ROOTACCESS + if (seteuid(0)) { + perror("runBsubScriptAsUser (child): setuid 0"); + _exit(1); + } + if (setgid(pw->pw_gid)) { + perror("runBsubScriptAsUser (child): setgid"); + _exit(1); + } + if (setuid(pw->pw_uid)) { + perror("runBsubScriptAsUser (child): setuid"); + _exit(1); + } +#endif + execl(QSUB,QSUBEXEC,scriptname,"-v",variables,(char*)NULL); + perror("runBsubScriptAsUser (child): execl"); + close(pfd[0]); + _exit(1); + } + + /* In the parent */ + close(pfd[1]); + fp = fdopen(pfd[0], "r"); + if (fp == NULL) { + perror("runBsubScriptAsUser: fdopen"); + } + while (fgets(buf, 512, fp)) { + jobid=atoi(buf);//sscanf(buf, "%d@%s\n", &jobid,server); + } + fclose(fp); + close(pfd[0]); + + if (waitpid(pid, NULL, 0) < 0) { + perror("runBsubScriptAsUser: waitpid"); + return -1; + } + + return jobid; +} + +/** + * Gets the error number code of the last error. + * + * It provides access to local module variable errorno. See errors.h for a list + * of error codes. + * @return the error number code +*/ +int getErrNo(){ + return errorno; +} + Added: trunk/besserver/rm_util.c =================================================================== --- trunk/besserver/rm_util.c (rev 0) +++ trunk/besserver/rm_util.c 2009-03-06 19:25:50 UTC (rev 69) @@ -0,0 +1,626 @@ +/* ---------------------------------------------------------------- + * bescluster.c + * + * BES++ server implementation of the OGSA Basic Execution Services + * Common functions for all types of clusters + * + * Copyright (C) Arkaitz Ruiz Alvarez. + * ar...@cs... + * Platform Computing Corporation. + * All Rights Reserved. + * + * This file is part of Besserver. + * + * Besserver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +//Includes +#include "rm_util.h" +#include "rm.h" +#include "faults.h" +#include "job.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define N_OS 1 +#define N_ARCH 2 +char *OPERATING_SYSTEM_NAME[] = {"LINUX"}; +char *OPERATING_SYSTEM_VERSION[] = {"2.6.9"}; +char *CPU_ARCHITECTURE[] = {"x86", "x86_64"}; +#define DESCRIPTION_CLUSTER "This is a cluster managed by the UVA CS Grid group" + + +/** + * Executes the python script by forking and calling execl. The python + * script sge.py calls the commands qsub, qstat, qdel, etc. and writes + * the result to a text file that is later readed by this C program. + * Before this call the process changes its UID to the UID of the + * account specified. + * @param user String with the user account to execute the script under + * @param script Absolute route to the script + * @param scriptExec name of the executable (arg[0]) + * @param action First parameter for sge.py, see sge.py for details + * @param parameter Second parameter for sge.py, see sge.py for details + * @param outputFile Third parameter for sge.py, this is a temporal file + * created to pass the information between the python script and this + * C program + * @return 0 if everything is OK, NOTAUTHORIZEDFAULT otherwise + */ +int executeScript(char * user, char * script, char * scriptExec, + char * action, char * parameter, char * outputFile) +{ + int fd; + pid_t pid; + struct passwd *pw; + char *arg0, buf[512]; + + //Make a temporal file for the script output + fd = mkstemp(outputFile); + if (fd == -1) { + perror("executeScript: mkstemp"); + return BESE_SYS_ERR; + } +#ifdef ROOTACCESS + if (!user) { + return BESE_SYS_ERR; + } + + if ((pw = getpwnam(user)) == NULL) { + fprintf(stderr, "executeScript: couldn't get user %s from passwd\n", user); + return BESE_SYS_ERR; + } +#endif + + if ((pid = fork()) < 0) { + fprintf(stderr,"executeScript: fork"); + return BESE_SYS_ERR; + } + + if (pid == 0) { +#ifdef ROOTACCESS + // child process + if (seteuid(0)) { + perror("executeScript (child): setuid 0"); + _exit(1); + } + if (setgid(pw->pw_gid)) { + perror("executeScript (child): setgid"); + _exit(1); + } + if (setuid(pw->pw_uid)) { + perror("executeScript (child): setuid"); + _exit(1); + } +#endif + execlp(script, scriptExec, action, parameter, outputFile, (char*) NULL); + perror("executeScript (child): execl"); + _exit(1); + } + else{ + /* parent process */ + if (waitpid(pid, NULL, 0) < 0) { + perror("executeScript: waitpid"); + return BESE_SYS_ERR; + } + } + + close(fd); + return BESE_OK; +} + +/** + * Executes the python script by forking and calling execl. The python + * script sge.py calls the commands qsub, qstat, qdel, etc. and writes + * the result to a text file that is later readed by this C program. It + * does not change the UID, so this function should be used ONLY for + * obtaining information that is widely available (QSTAT) + * + * @param script Absolute route to the script + * @param scriptExec name of the executable (arg[0]) + * @param action First parameter for sge.py, see sge.py for details + * @param parameter Second parameter for sge.py, see sge.py for details + * @param outputFile Third parameter for sge.py, this is a temporal file + * created to pass the information between the python script and this + * C program + * @return 0 if everything is OK, NOTAUTHORIZEDFAULT otherwise + */ +int executeScriptSameUser(char * script, char * scriptExec, char * action, + char * parameter, char * outputFile) +{ + int fd; + pid_t pid; + struct passwd *pw; + char *arg0, buf[512]; + + //Make a temporal file for the script output + fd = mkstemp(outputFile); + if (fd == -1) { + perror("executeScript: mkstemp"); + return BESE_SYS_ERR; + } + + + if ((pid = fork()) < 0) { + fprintf(stderr,"executeScript: fork"); + return BESE_SYS_ERR; + } + + if (pid == 0) { + /* child process */ + execl(script, scriptExec, action, parameter, outputFile, (char*) NULL); + perror("executeScript (child): execl"); + _exit(1); + } + else{ + /* parent process */ + if (waitpid(pid, NULL, 0) < 0) { + perror("executeScript: waitpid"); + return -1; + } + } + + close(fd); + + return 0; +} + +/** + * Assigns an environment variable to a field in the jobcard struct. + * + * The queue stores the original job parameters of the request in + * environment variables like HPCP_XXXXX. This function gets a list of + * environment variables and fills the struct jobcard. + * @param list is a list of environment variables "VAR1="var1",VAR2="var2"" + * @param jobInfo is the struct which is filled with the information + * @param soap is used to allocate memory deallocatable by the gSOAP library + * about the job + */ +void getRequestInfo(struct soap* soap, char* list, struct jobcard* jobInfo) +{ + char *variable; + //fprintf(stderr, "%s\n", list); + jobInfo->args = (char**) soap_malloc(soap, sizeof(char**)*50); + for ( variable = strtok(list,","); variable != NULL; + variable = strtok(NULL, ",") ) + { + char name[200]; + char *equal = strchr(variable, '='); + char varValue[200]; + memset(name, 0, 200); + memset(varValue, 0, 200); + strncpy(name, variable, equal-variable); + strcpy(varValue, equal + 1); + + if(!strcmp(name, "HPCP_JOB_NAME")) + { + //jobInfo->jobname = (char*) soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->jobname, varValue); + jobInfo->jobname = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_JOB_PROJECT")) + { + //jobInfo->jobproject = (char*) soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->jobproject, varValue); + jobInfo->jobproject = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_EXCLUSIVE")) + { + jobInfo->exclusive = atoi(varValue); + } + else if(!strcmp(name, "HPCP_OSNAME")) + { + //jobInfo->osname = (char*) soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->osname, varValue); + jobInfo->osname = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_CPU_ARCH")) + { + //jobInfo->cpuarch = (char*) soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->cpuarch, varValue); + jobInfo->cpuarch = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_TOTAL_CPU_COUNT")) + { + jobInfo->icpu = atoi(varValue); + //jobInfo->tcpuType = EXACT; + } + else if(!strcmp(name, "HPCP_APP_EXECUTABLE")) + { + //jobInfo->executable = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->executable, varValue); + jobInfo->executable = soap_strdup(soap, varValue); + } + else if(!strncmp(name, "HPCP_APP_ARG",12)) + { + //jobInfo->args[jobInfo->num_args] = (char*) soap_malloc(soap, + // strlen(varValue)); + //strcpy(jobInfo->args[jobInfo->num_args], varValue); + jobInfo->args[jobInfo->num_args] = soap_strdup(soap, varValue); + jobInfo->num_args += 1; + } + else if(!strcmp(name, "HPCP_APP_INPUT")) + { + //jobInfo->input = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->input, varValue); + jobInfo->input = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_APP_OUTPUT")) + { + //jobInfo->output = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->output, varValue); + jobInfo->output = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_APP_ERROR")) + { + //jobInfo->error = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->error, varValue); + jobInfo->error = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_APP_WD")) + { + //jobInfo->wd = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->wd,varValue); + jobInfo->wd = soap_strdup(soap, varValue); + } + else if(!strcmp(name, "HPCP_APP_USERNAME")) + { + //jobInfo->username = (char*)soap_malloc(soap, strlen(varValue)); + //strcpy(jobInfo->username, varValue); + jobInfo->username = soap_strdup(soap, varValue); + } + else + { + struct envvar* newEnvVar=(struct envvar*) soap_malloc(soap, + sizeof(struct envvar)); + memset(newEnvVar, 0, sizeof(struct envvar)); + newEnvVar->name = soap_strdup(soap,name); + newEnvVar->val = soap_strdup(soap,varValue); + newEnvVar->next = jobInfo->environment; + jobInfo->environment = newEnvVar; + } + } +} + +/** + * Loads the cluster resource information file into a clsuterInfo variable. + * + * The cluster resource information files are defined in RESOURCE_FILE, + * bescluster.h + * RESOURCE_FILE is a text file. + * @param clusterInfo is a pointer to a valid an zeroed clusterInfo struct + * @return 0 is correct, 1 otherwise + */ +/*int loadClusterInfo(struct soap * soap, + struct rm_resource** resources, + char* resourceFilename) +{ + unsigned int TotalCPUCount = 0; + unsigned int TotalAvailableCPUCount = 0; + unsigned int TotalNumberNodes = 0; + unsigned long TotalPhysicalMemory = 0; + unsigned int NumberNodes; + OSListNode *currentOSList,*headOSList; + ArchListNode *currentArchList,*headArchList; + + ResourceListNode *currentRS, *headRSList; +TotalCPUCount = 0; + TotalNumberNodes = 0; + headOSList = NULL; + headArchList = NULL; + headRSList = NULL; + currentOSList = headOSList; + currentArchList = headArchList; + currentRS = headRSList; + + do{ + TotalCPUCount += CPUCount; + if (!strcmp(state, "free")) + TotalAvailableCPUCount += CPUCount; + TotalPhysicalMemory += PhysicalMemory; + TotalNumberNodes ++; + if (currentRS == NULL){ + currentRS = (ResourceListNode*) soap_malloc(soap, + sizeof(ResourceListNode)); + if (headRSList == NULL) + headRSList = currentRS; + }else{ + currentRS->next = (ResourceListNode*) soap_malloc(soap, + sizeof(ResourceListNode)); + currentRS = currentRS->next; + } + memset(currentRS, 0, sizeof(ResourceListNode)); + currentRS->ResourceName = soap_strdup(soap, resourceName); + currentRS->State = soap_strdup(soap, state); + currentRS->CPUCount = CPUCount; + currentRS->PhysicalMemory = PhysicalMemory; + }while(); + + for(count = 0; count < N_OS; count ++) + { + currentOSList = (OSListNode*) soap_malloc(soap, + sizeof(OSListNode)); + memset(currentOSList, 0, sizeof(OSListNode)); + if (headOSList == NULL) + headOSList = currentOSList; + + currentOSList->OperatingSystem = (char*) soap_strdup(soap, + OPERATING_SYSTEM_NAME[count]); + currentOSList->OperatingSystemVersion = (char*) soap_strdup(soap, + OPERATING_SYSTEM_VERSION[count]); + currentOSList = currentOSList->next; + } + + for(count = 0; count < N_ARCH; count ++) + { + currentArchList = (ArchListNode*) soap_malloc(soap, + sizeof(ArchListNode)); + memset(currentArchList, 0, sizeof(ArchListNode)); + if (headArchList == NULL) + headArchList = currentArchList; + + currentArchList->CPUArchitecture = (char*) soap_strdup(soap, + CPU_ARCHITECTURE[count]); + currentArchList = currentArchList->next; + } + + clusterInfo->osList = headOSList; + clusterInfo->archList = headArchList; + clusterInfo->resourceList = headRSList; + clusterInfo->LongDescription = DESCRIPTION_CLUSTER; + + return BESE_OK; +}*/ +/** + * Loads the cluster resource information file into the module variable + * clusterInfo. + * + * + * @return 0 is correct, 1 otherwise + */ +int loadResourceFile(struct soap * soap, + struct rm_resource** resources, + char* resourceFilename, + int* num_resources) +{ + char resourceName[128]; + char state[128]; + unsigned int CPUCount; + unsigned long CPUSpeed; + unsigned long PhysicalMemory; + unsigned long VirtualMemory; + int eof; + int count; + struct rm_resource* rm_resource; + struct rm_resource* new_resource; + FILE* resourceFile; + + rm_resource = new_resource = NULL; + count = 0; + resourceFile = fopen(resourceFilename, "r"); + + if (resourceFile == NULL){ + fprintf(stderr,"Error with cluster info file:%s\n", resourceFilename); + return BESE_OTHER; + } + + do{ + eof = fscanf(resourceFile, "%s %lu %lu %s", resourceName, + &PhysicalMemory, &CPUCount, state); + if (eof != EOF) + { + new_resource = (struct rm_resource*) soap_malloc(soap, + sizeof (struct rm_resource)); + if (new_resource == NULL) + return BESE_MEM_ALLOC; + memset(new_resource, 0, sizeof(rm_resource)); + + new_resource->CPUCount = (double*) soap_malloc(soap, + sizeof(double)); + new_resource->CPUSpeed = (double*) soap_malloc(soap, + sizeof(double)); + new_resource->PhysicalMemory = (double*) soap_malloc(soap, + sizeof(double)); + new_resource->VirtualMemory = (double*) soap_malloc(soap, + sizeof(double)); + new_resource->ResourceName = (char*) soap_malloc(soap, + strlen(resourceName) + 1); + if (!new_resource->CPUCount || !new_resource->PhysicalMemory || + !new_resource->ResourceName) + return BESE_MEM_ALLOC; + *(new_resource->CPUCount) = CPUCount; + *(new_resource->CPUSpeed) = 0; + *(new_resource->VirtualMemory) = PhysicalMemory; + *(new_resource->PhysicalMemory) = PhysicalMemory; + new_resource->ResourceName = soap_strdup(soap, resourceName); + new_resource->next = rm_resource; + rm_resource = new_resource; + count ++; + } + }while (eof != EOF); + fclose(resourceFile); + + *resources = rm_resource; + *num_resources = count; + + return BESE_OK; +} + +/** + * Fills a jobcard struct with 0s, 1s and empty strings. + * + * This function is used to avoid segmentation faults if we access a field in + * the struct that has not been filled by @see getRequestInfo. + * @param jobInfo is the -allocated- struct to fill + */ +void fillJobStatusDefaults(struct jobcard*jobInfo) +{ + jobInfo->jobname=""; + jobInfo->jobproject=""; + jobInfo->num_hostnames=0; + jobInfo->hostnames=NULL; + jobInfo->exclusive=0; + jobInfo->osname=""; + jobInfo->osver=""; + jobInfo->cpuarch=""; + jobInfo->executable=""; + jobInfo->num_args=0; + jobInfo->args=NULL; + jobInfo->input=""; + jobInfo->output=""; + jobInfo->error=""; + jobInfo->wd="$HOME"; + jobInfo->environment=NULL; + + jobInfo->username=""; + +} + +/** + * Adds an environment variable for every field in the struct jobcard. + * + * The queue stores the original job parameters of the request in + * environment variables like HPCP_XXXXX. This function gets every property + * used in the request and adds the corresponding environment variable to + * the job submission request. + * @param list is the environment variable list generated, separated by commas + * @param jobInfo is the struct with the request info + * @param soap is used to allocate memory deallocatable by the gsoap library + */ +void addRequestInfo(struct soap* soap, char* list, struct jobcard* jobInfo) +{ + char variable[200]; + int i; + + if(jobInfo->jobname!=NULL) + { + sprintf(variable,",HPCP_JOB_NAME=%s",jobInfo->jobname); + strcat(list,variable); + } + if(jobInfo->jobproject!=NULL) + { + sprintf(variable,",HPCP_JOB_PROJECT=%s",jobInfo->jobproject) ; + strcat(list,variable); + } + for (i=0;i<jobInfo->num_hostnames;i++) + { + sprintf(variable,",HPCP_HOSTNAME%u=%s",i,jobInfo->hostnames[i]) ; + strcat(list,variable); + } + if(jobInfo->exclusive) + { + sprintf(variable,",HPCP_EXCLUSIVE=%u",jobInfo->exclusive) ; + strcat(list,variable); + } + if(jobInfo->osname!=NULL) + { + sprintf(variable,",HPCP_OSNAME=%s",jobInfo->osname) ; + strcat(list,variable); + } + if(jobInfo->cpuarch!=NULL) + { + sprintf(variable,",HPCP_CPU_ARCH=%s",jobInfo->cpuarch) ; + strcat(list,variable); + } + if(jobInfo->icpu > 0) + { + sprintf(variable,",HPCP_TOTAL_CPU_COUNT=%u",jobInfo->icpu) ; + strcat(list,variable); + } + /*if(jobInfo->tcpuType==LOWERBOUND) + { + if(jobInfo->tcpu.lowerBound.exclusive) + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_LB=%u",jobInfo->tcpu.lowerBound.bound+1); + else + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_LB=%u",jobInfo->tcpu.lowerBound.bound); + strcat(list,variable); + } + if(jobInfo->tcpuType==UPPERBOUND) + { + if(jobInfo->tcpu.upperBound.exclusive) + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_UB=%u",jobInfo->tcpu.upperBound.bound); + else + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_UB=%u",jobInfo->tcpu.upperBound.bound+1); + strcat(list,variable); + } + if(jobInfo->tcpuType==RANGE) + { + if(jobInfo->tcpu.range.exclusiveUpper) + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_UB=%u",jobInfo->tcpu.range.upperBound); + else + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_UB=%u",jobInfo->tcpu.range.upperBound+1); + if(jobInfo->tcpu.range.exclusiveLower) + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_LB=%u",jobInfo->tcpu.range.lowerBound+1); + else + sprintf(variable,",HPCP_TOTAL_CPU_COUNT_LB=%u",jobInfo->tcpu.range.lowerBound); + + strcat(list,variable); + }*/ + + if(jobInfo->executable!=NULL) + { + sprintf(variable,",HPCP_APP_EXECUTABLE=%s",jobInfo->executable) ; + strcat(list,variable); + } + for (i=0;i<jobInfo->num_args;i++) + { + sprintf(variable,",HPCP_APP_ARG%u=%s",i,jobInfo->args[i]) ; + strcat(list,variable); + } + if(jobInfo->input!=NULL) + { + sprintf(variable,",HPCP_APP_INPUT=%s",jobInfo->input) ; + strcat(list,variable); + } + if(jobInfo->output!=NULL) + { + sprintf(variable,",HPCP_APP_OUTPUT=%s",jobInfo->output) ; + strcat(list,variable); + } + if(jobInfo->error!=NULL) + { + sprintf(variable,",HPCP_APP_ERROR=%s",jobInfo->error) ; + strcat(list,variable); + } + if(jobInfo->wd!=NULL) + { + sprintf(variable,",HPCP_APP_WD=%s",jobInfo->wd) ; + strcat(list,variable); + } + if(jobInfo->username!=NULL) + { + sprintf(variable,",HPCP_APP_USERNAME=%s",jobInfo->username) ; + strcat(list,variable); + } +} + +char* trim(struct soap* soap, char* string) +{ + char * output = (char*) soap_malloc(soap, sizeof(char) * strlen(string) + 1); + memset(output, 0, sizeof(char) * strlen(string) + 1); + int j = 0, i; + for(i = 0; i < strlen(string); i++){ + if ((string[i]!= ' ') && (string[i] != '\n')){ + output[j] = string[i]; + j++; + } + } + output[j] = '\0'; + return output; +} + Property changes on: trunk/besserver/rm_util.c ___________________________________________________________________ Added: svn:executable + * Added: trunk/besserver/rm_util.h =================================================================== --- trunk/besserver/rm_util.h (rev 0) +++ trunk/besserver/rm_util.h 2009-03-06 19:25:50 UTC (rev 69) @@ -0,0 +1,77 @@ +//bescluster.h +#ifndef _BESCLUSTER_H +#define _BESCLUSTER_H + +#include "faults.h" +#include "job.h" +#include "rm.h" +#include <sys/utsname.h> +#include <time.h> + + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +//Location of the scripts to call for file staging, credentials, etc. +#define STAGE_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/stageFile.py" +#define SU_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/su.py" +#define CRED_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/cred.py" +#define PBS_SCRIPT "/home/ar5je/centurion/sf.net/bespp/besserver/scripts/pbs.py" +#define PBS_SCRIPT_EXEC "pbs.py" + +struct jobForward { + struct soap *s; + struct bes__CreateActivityType* req; + struct bes__CreateActivityResponseType *resp; + int returnValue; +}jobForward; + +typedef struct OSListNode{ + char*OperatingSystem; + char*OperatingSystemVersion; + struct OSListNode* next; +}OSListNode; + +typedef struct ArchListNode{ + char*CPUArchitecture; + struct ArchListNode* next; +}ArchListNode; + +typedef struct ResourceListNode{ + char* ResourceName; + char* State; + long int PhysicalMemory; + int CPUCount; + struct ResourceListNode* next; +}ResourceListNode; + +typedef struct JobList{ + long jobid; + struct JobList* next; +}JobList; + + +struct nodeResources{ + //OperatingSystem" type="jsdl:OperatingSystem_Type" + char * OperatingSystemName; + char * OperatingSystemVersion; + //<xsd:element name="CPUArchitecture" type="jsdl:CPUArchitecture_Type" + char* CPUArchitecture; + unsigned int CPUCount; + unsigned long CPUSpeed; + unsigned long PhysicalMemory; + unsigned long VirtualMemory; + + unsigned int NumberNodes; + struct nodeResources* next; +}; + +//Common functions for all clusters +void getRequestInfo(struct soap*, char*, struct jobcard*); +void addRequestInfo(struct soap*, char*, struct jobcard*); +int loadResourceFile(struct soap *, struct rm_resource**, char*, int*); +void fillJobStatusDefaults(struct jobcard*); + +char* trim(struct soap*,char*); + +#endif /* _BESCLUSTER_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ark...@us...> - 2009-03-06 19:23:50
|
Revision: 68 http://bespp.svn.sourceforge.net/bespp/?rev=68&view=rev Author: arkaitzr Date: 2009-03-06 19:23:22 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Arkaitz's changes to common files: - Added -r option to besserver executable - Removed LSF imports from job.h - Added field 'next' to the filters struct in rm.h Modified Paths: -------------- trunk/besserver/besserver.c trunk/besserver/job.h trunk/besserver/rm.h Modified: trunk/besserver/besserver.c =================================================================== --- trunk/besserver/besserver.c 2009-02-04 22:52:05 UTC (rev 67) +++ trunk/besserver/besserver.c 2009-03-06 19:23:22 UTC (rev 68) @@ -82,6 +82,7 @@ fprintf(stderr, " [-s server.pem] [-c capath]"); fprintf(stderr, " [-e service_endpoint]"); fprintf(stderr, " [-g generic user]"); + fprintf(stderr, " [-r resource manager]"); fprintf(stderr, "\n"); exit(1); } @@ -91,7 +92,7 @@ { struct soap soap, *psoap; int m, s, i, ch, port; - char *host, *portstr, *capath, *certfile, *service_user; + char *host, *portstr, *capath, *certfile, *service_user, *resource_manager; struct passwd *pwent; time_t now; @@ -101,8 +102,9 @@ certfile = "server.pem"; capath = "certs"; service_user = NULL; + resource_manager = NULL; - while ((ch = getopt(argc, argv, "Vh:p:s:c:u:e:g:")) != -1) { + while ((ch = getopt(argc, argv, "Vh:p:s:c:u:e:g:r:")) != -1) { switch (ch) { case 'h': host = optarg; @@ -126,6 +128,9 @@ case 'g': generic_user = optarg; break; + case 'r': + resource_manager = optarg; + break; case 'V': printf("besserver, %s\n%s\n", VERSION_STRING, COPYRIGHT); exit(0); @@ -192,7 +197,7 @@ sprintf(service_endpoint, "https://%s%s%s", host, strlen(portstr)?":":"", portstr); } - if (rm_initialize(&soap, NULL)) { + if (rm_initialize(&soap, resource_manager)) { fprintf(stderr, "Couldn't initialize the resource manager\n"); exit(1); } @@ -285,7 +290,7 @@ rc = rm_submitJob(s, jc, username, &jobid); if (rc != BESE_OK) { if (rc == BESE_PERMISSION) { - fault = bes_NotAuthorizedFault(s, lsb_sysmsg()); + fault = bes_NotAuthorizedFault(s, ""/*FIXME: lsf dependent code lsb_sysmsg()*/); return bes_send_fault(s, fault); } else { return soap_receiver_fault(s, BACKEND_ERROR, NULL); Modified: trunk/besserver/job.h =================================================================== --- trunk/besserver/job.h 2009-02-04 22:52:05 UTC (rev 67) +++ trunk/besserver/job.h 2009-03-06 19:23:22 UTC (rev 68) @@ -24,8 +24,6 @@ #ifndef _JOB_H #define _JOB_H -#include <lsf/lsf.h> -#include <lsf/lsbatch.h> #include "soapH.h" #include "namespaces.h" Modified: trunk/besserver/rm.h =================================================================== --- trunk/besserver/rm.h 2009-02-04 22:52:05 UTC (rev 67) +++ trunk/besserver/rm.h 2009-03-06 19:23:22 UTC (rev 68) @@ -47,6 +47,7 @@ char *startTime; char *endTime; char *CompactResources; + struct rm_filter *next; }; struct rm_job { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |