source: trunk/ll_drmaa/util.c @ 1

Revision 1, 16.0 KB checked in by mariusz, 14 years ago (diff)

drmaa ll initial commit

Line 
1/* $Id: util.c 224 2010-05-25 08:48:28Z mamonski $ */
2/*
3 * PSNC DRMAA for LL
4 * Copyright (C) 2010 Poznan Supercomputing and Networking Center
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *    http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include <drmaa_utils/common.h>
20#include <drmaa_utils/exception.h>
21#include <ll_drmaa/util.h>
22#include <string.h>
23
24#ifndef lint
25static char rcsid[]
26#       ifdef __GNUC__
27                __attribute__ ((unused))
28#       endif
29        = "$Id: util.c 224 2010-05-25 08:48:28Z mamonski $";
30#endif
31
32
33const char *
34lldrmaa_err_ckpt(int _llerrno)
35{
36        switch(_llerrno)
37        {
38                case API_OK:
39                        return "Checkpoint completed successfully.";
40                case LL_CKPT_UNCLEAR:
41                        return "Checkpoint event did not receive status and the success or failure of the checkpoint is unclear.";
42                case LL_CKPT_ERROR:
43                        return "Error occurred attempting to checkpoint.";
44                case LL_CKPT_JOB_ID_ERR:
45                        return "Format not valid for job step, not in the form host.jobid.stepid.";
46                case LL_CKPT_MALLOC_ERR:
47                        return "Cannot allocate memory.";
48                case LL_CKPT_SOCKET_ERR:
49                        return "API cannot create listen socket.";
50                case LL_CKPT_CONF_ERR:
51                        return "Configuration file errors.";
52                default:
53                        fsd_assert(false);
54                        return "Invalid error code";
55        }
56}
57
58int
59lldrmaa_map_ckpt(int _llerrno)
60{
61        switch(_llerrno)
62        {
63                case API_OK:
64                        return FSD_ERRNO_SUCCESS;
65                case LL_CKPT_UNCLEAR:
66                        return FSD_ERRNO_INTERNAL_ERROR;
67                case LL_CKPT_ERROR:
68                        return FSD_DRMAA_ERRNO_SUSPEND_INCONSISTENT_STATE;
69                case LL_CKPT_JOB_ID_ERR:
70                        return FSD_ERRNO_INTERNAL_ERROR;
71                case LL_CKPT_MALLOC_ERR:
72                        return FSD_ERRNO_NO_MEMORY;
73                case LL_CKPT_SOCKET_ERR:
74                        return FSD_ERRNO_INTERNAL_ERROR;
75                case LL_CKPT_CONF_ERR:
76                        return FSD_ERRNO_DENIED_BY_DRM;
77                default:
78                        fsd_assert(false);
79                        return FSD_ERRNO_INTERNAL_ERROR;
80        }
81}
82
83const char *
84lldrmaa_err_control(int _llerrno)
85{
86        switch(_llerrno)
87        {
88                case LL_CONTROL_OK:
89                        return "The specified command has been sent to the appropriate LoadLeveler daemon.";
90                case LL_CONTROL_CM_ERR:
91                        return "The specified command cannot be sent to the central manager.";
92                case LL_CONTROL_MASTER_ERR:
93                        return "The specified command cannot be sent to one of the LoadL_master daemons.";
94                case LL_CONTROL_CONFIG_ERR:
95                        return "ll_control encountered an error while processing the administration or configuration file.";
96                case LL_CONTROL_XMIT_ERR:
97                        return "A data transmission failure has occurred.";
98                case LL_CONTROL_AUTH_ERR :
99                        return "The calling program does not have LoadLeveler administrator authority.";
100                case LL_CONTROL_VERSION_ERR:
101                        return "An incorrect ll_control version has been specified.";
102                case LL_CONTROL_SYSTEM_ERR:
103                        return "A system error has occurred.";
104                case LL_CONTROL_MALLOC_ERR:
105                        return "The system cannot allocate memory.";
106                case LL_CONTROL_INVALID_OP_ERR:
107                        return "A control_op operation that is not valid has been specified.";
108                case LL_CONTROL_JOB_LIST_ERR:
109                        return "The job_list argument contains one or more errors.";
110                case LL_CONTROL_HOST_LIST_ERR:
111                        return "The host_list argument contains one or more errors.";
112                case LL_CONTROL_USER_LIST_ERR:
113                        return "The user_list argument contains one or more errors.";
114                case LL_CONTROL_HOLD_ERR:
115                        return "Incompatible arguments have been specified for HOLD operation.";
116                case LL_CONTROL_PRIO_ERR:
117                        return "Incompatible arguments have been specified for PRIORITY operation.";
118                case LL_CONTROL_FAVORJOB_ERR:
119                        return "Incompatible arguments have been specified for FAVORJOB operation.";
120                case LL_CONTROL_FAVORUSER_ERR:
121                        return "Incompatible arguments have been specified for FAVORUSER operation.";
122                case LL_CONTROL_SYS_ERR:
123                        return "An error occurred while ll_control tried to start a child process.";
124                case LL_CONTROL_START_ERR:
125                        return "An error occurred while ll_control tried to start the LoadL_master daemon.";
126                case LL_CONTROL_UNUSED_1_ERR:
127                        return "Unused";
128                case LL_CONTROL_CLASS_ERR:
129                        return "The class_list argument contains incompatible information.";
130                case LL_CONTROL_TMP_ERR:
131                        return "ll_control cannot create a file in the /tmp directory.";
132                case LL_CONTROL_ERR:
133                        return "LoadLeveler has encountered miscellaneous incompatible input specifications.";
134                case LL_CONTROL_NO_DCE_ID:
135                        return "DCE identity can not be determined.";
136                case LL_CONTROL_NO_DCE_CRED:
137                        return "No DCE credentials.";
138                case LL_CONTROL_INSUFFICIENT_DCE_CRED:
139                        return "DCE credentials within 300 secs of expiration.";
140                case LL_CONTROL_64BIT_DCE_ERR:
141                        return "64-bit API not supported when DCE is enabled";
142                case LL_CONTROL_NO_DCE_SUPPORT_ERR:
143                        return "This version of LL does not support DCE security.";
144                case LL_CONTROL_NO_CTSEC_SUPPORT_ERR:
145                        return "This version of LL does not support CTSEC security.";
146                case LL_CONTROL_NO_GANG_SUPPORT_ERR:
147                        return "This version of LL does not support GANG scheduling.";
148                case LL_CONTROL_NO_PVM_SUPPORT_ERR:
149                        return "This version of LL does not support PVM.";
150                case LL_CONTROL_NO_NQS_SUPPORT_ERR:
151                        return "This version of LL does not support NQS.";
152                default:
153                        fsd_assert(false);
154                        return "Invalid error code";
155        }
156}
157
158int
159lldrmaa_map_control(int _llerrno)
160{
161        switch( _llerrno )
162         {
163                case LL_CONTROL_OK:                      /* Command successfully sent to appropriate LL daemon. */
164                        return FSD_ERRNO_SUCCESS;
165                case LL_CONTROL_CM_ERR:                                  /* Cannot send command to central manager. */
166                case LL_CONTROL_MASTER_ERR:                              /* Cannot send command to one of LoadL_master daemons. */
167                        return FSD_ERRNO_INTERNAL_ERROR;
168                case LL_CONTROL_CONFIG_ERR:                      /* Errors encountered while processing the LL admin/config files. */
169                        return FSD_ERRNO_DENIED_BY_DRM;
170                case LL_CONTROL_XMIT_ERR:                                /* A data transmission failure occurred. */
171                        return FSD_ERRNO_INTERNAL_ERROR;
172                case LL_CONTROL_AUTH_ERR:                        /* Calling program does not have LL administrator authority. */
173                        return FSD_ERRNO_AUTHZ_FAILURE;
174                case LL_CONTROL_VERSION_ERR:                     /* An incorrect ll_control version has been specified. */
175                case LL_CONTROL_SYSTEM_ERR:                      /* A system error occurred. */
176                        return FSD_ERRNO_INTERNAL_ERROR;
177                case LL_CONTROL_MALLOC_ERR:                      /* Unable to allocate memory. */
178                        return FSD_ERRNO_NO_MEMORY;
179                case LL_CONTROL_INVALID_OP_ERR:                  /* An invalid control_op operation has been specified. */
180                case LL_CONTROL_JOB_LIST_ERR:                    /* job_list argument contains one or more errors. */
181                case LL_CONTROL_HOST_LIST_ERR:                   /* host_list argument contains one or more errors. */
182                case LL_CONTROL_USER_LIST_ERR:                   /* user_list argument contains one or more errors. */
183                case LL_CONTROL_HOLD_ERR:                                /* Incompatible arguments specified for HOLD operation. */
184                case LL_CONTROL_PRIO_ERR:                                /* Incompatible arguments specified for PRIORITY operation. */
185                case LL_CONTROL_FAVORJOB_ERR:                    /* Incompatible arguments specified for FAVORJOB operation. */
186                case LL_CONTROL_FAVORUSER_ERR:                   /* Incompatible arguments specified for FAVORUSER operation. */
187                case LL_CONTROL_SYS_ERR:                                 /* An error occurred while trying to start a child process. */
188                case LL_CONTROL_START_ERR:                               /* An error occurred while trying to start the LoadL_master daemon. */
189                case LL_CONTROL_UNUSED_1_ERR:
190                case LL_CONTROL_CLASS_ERR:                       /* class_list argument contains incompatible information. */
191                case LL_CONTROL_TMP_ERR:                                 /* Unable to create a file in /tmp directory. */
192                case LL_CONTROL_ERR:                                     /* Miscellaneous incompatible input specifications. */
193                case LL_CONTROL_NO_DCE_ID:                       /* DCE identity can not be determined. */
194                case LL_CONTROL_NO_DCE_CRED:                     /* No DCE credentials. */
195                case LL_CONTROL_INSUFFICIENT_DCE_CRED:    /* DCE credentials within 300 secs of expiration. */
196                case LL_CONTROL_64BIT_DCE_ERR:                           /* 64-bit API not supported when DCE is enabled */
197                case LL_CONTROL_NO_DCE_SUPPORT_ERR:       /* This version of LL does not support DCE security. */
198                case LL_CONTROL_NO_CTSEC_SUPPORT_ERR:    /* This version of LL does not support CTSEC security. */
199                case LL_CONTROL_NO_GANG_SUPPORT_ERR:     /* This version of LL does not support GANG scheduling. */
200                case LL_CONTROL_NO_PVM_SUPPORT_ERR:      /* This version of LL does not support PVM. */
201                case LL_CONTROL_NO_NQS_SUPPORT_ERR:      /* This version of LL does not support NQS. */
202                        return FSD_ERRNO_INTERNAL_ERROR;
203                default:
204                        fsd_assert(false);
205                        return FSD_ERRNO_INTERNAL_ERROR;
206        }
207}
208
209
210const char *
211lldrmaa_err_get_data(int _llerrno)
212{
213        switch(_llerrno)
214        {
215                case API_OK :
216                        return "Operation successful";
217                case API_INVALID_INPUT:
218                        return "You specified an object that is not valid.";
219                case LL_GET_DATA_NOT_VALID_LLAPI_SPECIFICATION_ERR:
220                        return "You specified an LLAPI_Specification that is not valid.";
221                default:
222                        fsd_assert(false);
223                        return "Invalid error code";
224        }
225}
226
227int
228lldrmaa_map_get_data(int _llerrno)
229{
230        switch(_llerrno)
231        {
232                case API_OK :                /* API call runs to complete */
233                        return FSD_ERRNO_SUCCESS;
234                case API_INVALID_INPUT:      /* Invalid input */
235                case LL_GET_DATA_NOT_VALID_LLAPI_SPECIFICATION_ERR:    /* input not valid */
236                        return FSD_ERRNO_INTERNAL_ERROR;
237                default:
238                        fsd_assert(false);
239                        return FSD_ERRNO_INTERNAL_ERROR;
240        }
241}
242
243const char *
244lldrmaa_err_get_objs(int _llerrno)
245{
246        switch( _llerrno )
247        {
248                case API_OK:
249                        return "Operation successful";
250                case LL_GET_OBJS_QUERY_ELEMENT_NOT_VALID_ERR:
251                        return "query_element not valid.";
252                case LL_GET_OBJS_QUERY_DEAMON_NOT_VALID_ERR:
253                        return "query_daemon not valid.";
254                case LL_GET_OBJS_HOSTNAME_ERR:
255                        return "Cannot resolve hostname.";
256                case LL_GET_OBJS_INVALID_REQUEST_ERR:
257                        return "Request type for specified daemon not valid.";
258                case LL_GET_OBJS_SYS_ERR:
259                        return "System error.";
260                case LL_GET_OBJS_NO_OBJECTS_ERR:
261                        return "No valid objects meet the request.";
262                case LL_GET_OBJS_CONF_ERR:
263                        return "Configuration error.";
264                case LL_GET_OBJS_DEAMON_CONNECTION_ERR:
265                        return "Connection to daemon failed.";
266                case LL_GET_OBJS_HISTORY_F_PROCESS_ERR:
267                        return "Error processing history file (LL_HISTORY_FILE query only).";
268                case LL_GET_OBJS_NO_HISTORY_FILE:
269                        return "History file must be specified in the hostname argument (LL_HISTORY_FILE query only).";
270                case LL_GET_OBJS_HISTORY_F_NO_ACCES_ERR:
271                        return "Unable to access the history file (LL_HISTORY_FILE query only).";
272                default:
273                        fsd_assert(false);
274                        return "Invalid error code";
275        }
276}
277
278int
279lldrmaa_map_get_objs(int _llerrno)
280{
281        switch( _llerrno )
282        {
283                case API_OK:                                                            /* API call runs to complete */
284                        return FSD_ERRNO_SUCCESS;
285                case LL_GET_OBJS_QUERY_ELEMENT_NOT_VALID_ERR:                                           /* Invalid input */
286                case LL_GET_OBJS_QUERY_DEAMON_NOT_VALID_ERR:                                    /* input not valid */
287                case LL_GET_OBJS_HOSTNAME_ERR:
288                case LL_GET_OBJS_INVALID_REQUEST_ERR:
289                case LL_GET_OBJS_SYS_ERR:
290                case LL_GET_OBJS_NO_OBJECTS_ERR:
291                        return FSD_DRMAA_ERRNO_INVALID_JOB ; /* "No valid objects meet the request." */
292                case LL_GET_OBJS_CONF_ERR:
293                        return FSD_ERRNO_DENIED_BY_DRM;
294                case LL_GET_OBJS_DEAMON_CONNECTION_ERR:
295                        return FSD_ERRNO_DRM_COMMUNICATION_FAILURE;
296                case LL_GET_OBJS_HISTORY_F_PROCESS_ERR:
297                case LL_GET_OBJS_NO_HISTORY_FILE:
298                case LL_GET_OBJS_HISTORY_F_NO_ACCES_ERR:
299                        return FSD_ERRNO_INTERNAL_ERROR;
300                default:
301                        fsd_assert(false);
302                        return FSD_ERRNO_INTERNAL_ERROR;
303        }
304}
305
306const char *
307lldrmaa_err_set_request(int _llerrno)
308{
309        switch(_llerrno)
310        {
311                case API_OK:
312                        return "Operation successful";
313                case API_INVALID_INPUT:
314                        return "You specified a query_element that is not valid.";
315                case LL_SET_REQUEST_QUERY_FLAG_NOT_VALID_ERR:
316                        return "You specified a query_flag that is not valid.";
317                case LL_SET_REQUEST_OBJ_FILTER_NOT_VALID_ERR:
318                        return "You specified an object_filter that is not valid.";
319                case LL_SET_REQUEST_DATA_FILTER_NOT_VALID_ERR:
320                        return "You specified a data_filter that is not valid.";
321                case LL_SET_REQUEST_SYS_ERR:
322                        return "A system error occurred.";
323                default:
324                        fsd_assert(false);
325                        return "Invalid error code";
326        }
327}
328
329int
330lldrmaa_map_set_request(int _llerrno)
331{
332        switch(_llerrno)
333        {
334                case API_OK:                           /* API call runs to complete */
335                        return FSD_ERRNO_SUCCESS;
336                case API_INVALID_INPUT:                /* Invalid input */
337                case LL_SET_REQUEST_QUERY_FLAG_NOT_VALID_ERR:
338                case LL_SET_REQUEST_OBJ_FILTER_NOT_VALID_ERR:
339                case LL_SET_REQUEST_DATA_FILTER_NOT_VALID_ERR:
340                case LL_SET_REQUEST_SYS_ERR:
341                        return FSD_ERRNO_INTERNAL_ERROR;
342                default:
343                        fsd_assert(false);
344                        return FSD_ERRNO_INTERNAL_ERROR;
345        }
346}
347
348
349const char *
350lldrmaa_err_preempt_jobs(int _llerrno)
351{
352        switch(_llerrno)
353        {
354                case API_OK:
355                        return "Request successfully sent to the central manager.";
356                case API_INVALID_INPUT:
357                        return "An LL_preempt_op that is not valid was specified.";
358                case API_CANT_CONNECT:
359                        return "Cannot send request to central manager.";
360                case LL_PREEMPT_JOBS_VERSION_ERR:
361                        return "An incorrect version was specified.";
362                case API_CONFIG_ERR :
363                        return "Errors encountered while processing the LoadLeveler administration or configuration files.";
364                case LL_PREEMPT_JOBS_SYS_ERR:
365                        return "A system error occurred.";
366                case API_CANT_TRANSMIT:
367                        return "A data transmission failure occurred.";
368                case API_CANT_AUTH:
369                        return "The calling program does not have LoadLeveler administrator authority.";
370                default:
371                        fsd_assert(false);
372                        return "Invalid error code";
373        }
374}
375
376int
377lldrmaa_map_preempt_jobs(int _llerrno)
378{
379        switch(_llerrno)
380        {
381                case API_OK:                                            /* API call runs to complete */
382                        return FSD_ERRNO_SUCCESS;
383                case API_INVALID_INPUT:                         /* Invalid input */
384                        return FSD_ERRNO_INVALID_ARGUMENT;
385                case API_CANT_CONNECT:                          /* can't connect to daemon */
386                case LL_PREEMPT_JOBS_VERSION_ERR:
387                        return FSD_ERRNO_INTERNAL_ERROR;
388                case API_CONFIG_ERR:                            /* Error from init_params() */
389                        return FSD_ERRNO_DENIED_BY_DRM;
390                case LL_PREEMPT_JOBS_SYS_ERR:
391                case API_CANT_TRANSMIT:                         /* xdr error */
392                        return FSD_ERRNO_INTERNAL_ERROR;
393                case API_CANT_AUTH:                                     /* can't authorize */
394                        return FSD_ERRNO_AUTHZ_FAILURE;
395                default:
396                        fsd_assert(false);
397                        return FSD_ERRNO_INTERNAL_ERROR;
398        }
399}
400
401const char * lldrmaa_err_submit(int _llerrno)
402{
403        switch(_llerrno)
404        {
405                case API_OK:
406                        return "The job was submitted successfully.";
407                case LL_SUBMIT_ERROR:
408                        return "Error, error messages written to stderr.";
409                default:
410                        fsd_assert(false);
411                        return "Invalid error code";
412        }
413}
414
415int lldrmaa_map_submit(int _llerrno)
416{
417        switch(_llerrno)
418        {
419                case API_OK:                    /* API call runs to complete */
420                        return FSD_ERRNO_SUCCESS;
421                case LL_SUBMIT_ERROR:
422                        return FSD_ERRNO_INTERNAL_ERROR;
423                default:
424                        fsd_assert(false);
425                        return FSD_ERRNO_INTERNAL_ERROR;
426        }
427}
428
429const char *
430lldrmaa_err_terminate_job(int _llerrno)
431{
432        switch(_llerrno)
433        {
434                case API_OK:
435                        return "Operation successful";
436                case API_INVALID_INPUT:
437                        return "There is an error in the input parameter.";
438                case API_CONFIG_ERR:
439                        return "An error occurred reading parameters from the administration or the configuration file.";
440                case API_CANT_TRANSMIT:
441                        return "A data transmission failure occurred.";
442                case API_CANT_AUTH:
443                        return "The subroutine cannot authorize the action because you are not a LoadLeveler administrator or you are not the user who submitted the job.";
444                case API_WRNG_PROC_VERSION:
445                        return "The job object version number is incorrect.";
446                default:
447                        fsd_assert(false);
448                        return "Invalid error code";
449        }
450}
451
452int
453lldrmaa_map_terminate_job(int _llerrno)
454{
455        switch(_llerrno)
456        {
457                case API_OK:
458                        return FSD_ERRNO_SUCCESS;               /* API call runs to complete */
459                case API_INVALID_INPUT:
460                        return FSD_ERRNO_INTERNAL_ERROR;
461                case API_CONFIG_ERR: /* Error from init_params() */
462                        return FSD_ERRNO_DENIED_BY_DRM;
463                case API_CANT_TRANSMIT:                         /* xdr error */
464                        return FSD_ERRNO_INTERNAL_ERROR;
465                case API_CANT_AUTH:                                     /* can't authorize */
466                        return FSD_ERRNO_AUTHZ_FAILURE;
467                case API_WRNG_PROC_VERSION:                     /* Wrong proc version */
468                        return FSD_ERRNO_INTERNAL_ERROR;
469                default:
470                        fsd_assert(false);
471                        return FSD_ERRNO_INTERNAL_ERROR;
472        }
473}
474
475
Note: See TracBrowser for help on using the repository browser.