~ubuntu-branches/ubuntu/precise/slurm-llnl/precise

« back to all changes in this revision

Viewing changes to src/plugins/select/bluegene/plugin/jobinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2011-04-08 11:21:17 UTC
  • mfrom: (3.3.16 sid)
  • Revision ID: james.westby@ubuntu.com-20110408112117-nfnyq9dtm55hqoaw
Tags: 2.2.4-1
* New upstream releases 
* Cleaning spare file and directories, not belonging to the sources
  generated by the building process and not removed by distclean.
  Added debian/clean with spare files and rm -rf inside debian/rules
  for directories.
* Added new packages libslurm-perl, libslurmdb-perl, slurm-llnl-torque
  (Closes: #575822) thanks to Julien Blache

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
\*****************************************************************************/
38
38
 
39
39
#include "src/common/slurm_xlator.h"
 
40
#include "bluegene.h"
40
41
#include "jobinfo.h"
41
42
#include "src/common/xmalloc.h"
42
43
#include "src/common/xstring.h"
68
69
        jobinfo->rotate = (uint16_t) NO_VAL;
69
70
        jobinfo->magic = JOBINFO_MAGIC;
70
71
        jobinfo->node_cnt = NO_VAL;
71
 
        jobinfo->max_cpus =  NO_VAL;
72
72
        /* Remainder of structure is already NULL fulled */
73
73
 
74
74
        return jobinfo;
90
90
                xfree(jobinfo->bg_block_id);
91
91
                xfree(jobinfo->nodes);
92
92
                xfree(jobinfo->ionodes);
93
 
#ifdef HAVE_BGL
94
93
                xfree(jobinfo->blrtsimage);
95
 
#endif
96
94
                xfree(jobinfo->linuximage);
97
95
                xfree(jobinfo->mloaderimage);
98
96
                xfree(jobinfo->ramdiskimage);
113
111
        uint16_t *uint16 = (uint16_t *) data;
114
112
        uint32_t *uint32 = (uint32_t *) data;
115
113
        char *tmp_char = (char *) data;
 
114
        uint32_t new_size;
116
115
 
117
116
        if (jobinfo == NULL) {
118
 
                error("select_g_set_jobinfo: jobinfo not set");
 
117
                error("set_select_jobinfo: jobinfo not set");
119
118
                return SLURM_ERROR;
120
119
        }
 
120
 
121
121
        if (jobinfo->magic != JOBINFO_MAGIC) {
122
 
                error("set_jobinfo: jobinfo magic bad");
 
122
                error("set_select_jobinfo: jobinfo magic bad");
123
123
                return SLURM_ERROR;
124
124
        }
125
125
 
126
126
        switch (data_type) {
127
127
        case SELECT_JOBDATA_GEOMETRY:
128
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++)
 
128
                new_size = 1;
 
129
                for (i=0; i<SYSTEM_DIMENSIONS; i++) {
129
130
                        jobinfo->geometry[i] = uint16[i];
 
131
                        new_size *= uint16[i];
 
132
                }
 
133
 
 
134
                /* Make sure the conn type is correct with the new count */
 
135
                if ((new_size > 1) && (jobinfo->conn_type == SELECT_SMALL))
 
136
                        jobinfo->conn_type = SELECT_TORUS;
130
137
                break;
131
138
        case SELECT_JOBDATA_REBOOT:
132
139
                jobinfo->reboot = *uint16;
152
159
                break;
153
160
        case SELECT_JOBDATA_NODE_CNT:
154
161
                jobinfo->node_cnt = *uint32;
 
162
#ifdef HAVE_BG_L_P
 
163
                /* Make sure the conn type is correct with the new count */
 
164
                if ((bg_conf->bp_node_cnt == bg_conf->nodecard_node_cnt)
 
165
                    || (jobinfo->node_cnt < bg_conf->bp_node_cnt)) {
 
166
                        if (jobinfo->conn_type < SELECT_SMALL)
 
167
                                jobinfo->conn_type = SELECT_SMALL;
 
168
                } else if (jobinfo->conn_type >= SELECT_SMALL)
 
169
                        jobinfo->conn_type = SELECT_TORUS;
 
170
#endif
155
171
                break;
156
172
        case SELECT_JOBDATA_ALTERED:
157
173
                jobinfo->altered = *uint16;
158
174
                break;
159
 
        case SELECT_JOBDATA_MAX_CPUS:
160
 
                jobinfo->max_cpus = *uint32;
161
 
                break;
162
175
        case SELECT_JOBDATA_BLRTS_IMAGE:
163
176
                /* we xfree() any preset value to avoid a memory leak */
164
 
#ifdef HAVE_BGL
165
177
                xfree(jobinfo->blrtsimage);
166
178
                jobinfo->blrtsimage = xstrdup(tmp_char);
167
 
#endif
168
179
                break;
169
180
        case SELECT_JOBDATA_LINUX_IMAGE:
170
181
                /* we xfree() any preset value to avoid a memory leak */
182
193
                jobinfo->ramdiskimage = xstrdup(tmp_char);
183
194
                break;
184
195
        default:
185
 
                debug("set_jobinfo data_type %d invalid",
 
196
                debug("set_select_jobinfo: data_type %d invalid",
186
197
                      data_type);
187
198
        }
188
199
 
193
204
 * IN jobinfo  - updated select job credential
194
205
 * IN data_type - type of data to enter into job credential
195
206
 * OUT data - the data to get from job credential, caller must xfree
196
 
 *      data for data_tyep == SELECT_JOBDATA_BLOCK_ID
 
207
 *      data for data_type == SELECT_JOBDATA_BLOCK_ID
197
208
 */
198
209
extern int get_select_jobinfo(select_jobinfo_t *jobinfo,
199
 
                enum select_jobdata_type data_type, void *data)
 
210
                              enum select_jobdata_type data_type, void *data)
200
211
{
201
212
        int i, rc = SLURM_SUCCESS;
202
213
        uint16_t *uint16 = (uint16_t *) data;
254
265
        case SELECT_JOBDATA_ALTERED:
255
266
                *uint16 = jobinfo->altered;
256
267
                break;
257
 
        case SELECT_JOBDATA_MAX_CPUS:
258
 
                *uint32 = jobinfo->max_cpus;
259
 
                break;
260
268
        case SELECT_JOBDATA_BLRTS_IMAGE:
261
 
#ifdef HAVE_BGL
262
269
                if ((jobinfo->blrtsimage == NULL)
263
270
                    ||  (jobinfo->blrtsimage[0] == '\0'))
264
271
                        *tmp_char = NULL;
265
272
                else
266
273
                        *tmp_char = xstrdup(jobinfo->blrtsimage);
267
 
#endif
268
274
                break;
269
275
        case SELECT_JOBDATA_LINUX_IMAGE:
270
276
                if ((jobinfo->linuximage == NULL)
323
329
                rc->ionodes = xstrdup(jobinfo->ionodes);
324
330
                rc->node_cnt = jobinfo->node_cnt;
325
331
                rc->altered = jobinfo->altered;
326
 
                rc->max_cpus = jobinfo->max_cpus;
327
 
#ifdef HAVE_BGL
328
332
                rc->blrtsimage = xstrdup(jobinfo->blrtsimage);
329
 
#endif
330
333
                rc->linuximage = xstrdup(jobinfo->linuximage);
331
334
                rc->mloaderimage = xstrdup(jobinfo->mloaderimage);
332
335
                rc->ramdiskimage = xstrdup(jobinfo->ramdiskimage);
338
341
/* pack a select job credential into a buffer in machine independent form
339
342
 * IN jobinfo  - the select job credential to be saved
340
343
 * OUT buffer  - buffer with select credential appended
 
344
 * IN protocol_version - slurm protocol version of client
341
345
 * RET         - slurm error code
342
346
 */
343
 
extern int  pack_select_jobinfo(select_jobinfo_t *jobinfo, Buf buffer)
 
347
extern int  pack_select_jobinfo(select_jobinfo_t *jobinfo, Buf buffer,
 
348
                                uint16_t protocol_version)
344
349
{
345
350
        int i;
346
 
 
347
 
        if (jobinfo) {
348
 
                /* NOTE: If new elements are added here, make sure to
349
 
                 * add equivalant pack of zeros below for NULL pointer */
350
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++) {
351
 
                        pack16(jobinfo->geometry[i], buffer);
 
351
        uint32_t cluster_flags = slurmdb_setup_cluster_flags();
 
352
        int dims = slurmdb_setup_cluster_dims();
 
353
 
 
354
        if (protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
 
355
                if (jobinfo) {
 
356
                        /* NOTE: If new elements are added here, make sure to
 
357
                         * add equivalant pack of zeros below for NULL
 
358
                         * pointer */
 
359
                        for (i=0; i<dims; i++) {
 
360
                                pack16(jobinfo->geometry[i], buffer);
 
361
                        }
 
362
                        pack16(jobinfo->conn_type, buffer);
 
363
                        pack16(jobinfo->reboot, buffer);
 
364
                        pack16(jobinfo->rotate, buffer);
 
365
 
 
366
                        pack32(jobinfo->node_cnt, buffer);
 
367
 
 
368
                        packstr(jobinfo->bg_block_id, buffer);
 
369
                        packstr(jobinfo->nodes, buffer);
 
370
                        packstr(jobinfo->ionodes, buffer);
 
371
 
 
372
                        packstr(jobinfo->blrtsimage, buffer);
 
373
                        packstr(jobinfo->linuximage, buffer);
 
374
                        packstr(jobinfo->mloaderimage, buffer);
 
375
                        packstr(jobinfo->ramdiskimage, buffer);
 
376
                } else {
 
377
                        /* pack space for 3 positions for geo
 
378
                         * then 1 for conn_type, reboot, and rotate
 
379
                         */
 
380
                        for (i=0; i<(dims+3); i++)
 
381
                                pack16((uint16_t) 0, buffer);
 
382
 
 
383
                        pack32((uint32_t) 0, buffer); //node_cnt
 
384
 
 
385
                        packnull(buffer); //bg_block_id
 
386
                        packnull(buffer); //nodes
 
387
                        packnull(buffer); //ionodes
 
388
 
 
389
                        packnull(buffer); //blrts
 
390
                        packnull(buffer); //linux
 
391
                        packnull(buffer); //mloader
 
392
                        packnull(buffer); //ramdisk
352
393
                }
353
 
                pack16(jobinfo->conn_type, buffer);
354
 
                pack16(jobinfo->reboot, buffer);
355
 
                pack16(jobinfo->rotate, buffer);
356
 
 
357
 
                pack32(jobinfo->node_cnt, buffer);
358
 
                pack32(jobinfo->max_cpus, buffer);
359
 
 
360
 
                packstr(jobinfo->bg_block_id, buffer);
361
 
                packstr(jobinfo->nodes, buffer);
362
 
                packstr(jobinfo->ionodes, buffer);
363
 
#ifdef HAVE_BGL
364
 
                packstr(jobinfo->blrtsimage, buffer);
365
 
#endif
366
 
                packstr(jobinfo->linuximage, buffer);
367
 
                packstr(jobinfo->mloaderimage, buffer);
368
 
                packstr(jobinfo->ramdiskimage, buffer);
369
394
        } else {
370
 
                /* pack space for 3 positions for geo
371
 
                 * then 1 for conn_type, reboot, and rotate
372
 
                 */
373
 
                for (i=0; i<(SYSTEM_DIMENSIONS+3); i++)
374
 
                        pack16((uint16_t) 0, buffer);
375
 
 
376
 
                pack32((uint32_t) 0, buffer); //node_cnt
377
 
                pack32((uint32_t) 0, buffer); //max_cpus
378
 
 
379
 
                packnull(buffer); //bg_block_id
380
 
                packnull(buffer); //nodes
381
 
                packnull(buffer); //ionodes
382
 
#ifdef HAVE_BGL
383
 
                packnull(buffer); //blrts
384
 
#endif
385
 
                packnull(buffer); //linux
386
 
                packnull(buffer); //mloader
387
 
                packnull(buffer); //ramdisk
 
395
                if (jobinfo) {
 
396
                        /* NOTE: If new elements are added here, make sure to
 
397
                         * add equivalant pack of zeros below for NULL
 
398
                         * pointer */
 
399
                        for (i=0; i<SYSTEM_DIMENSIONS; i++) {
 
400
                                pack16(jobinfo->geometry[i], buffer);
 
401
                        }
 
402
                        pack16(jobinfo->conn_type, buffer);
 
403
                        pack16(jobinfo->reboot, buffer);
 
404
                        pack16(jobinfo->rotate, buffer);
 
405
 
 
406
                        pack32(jobinfo->node_cnt, buffer);
 
407
                        pack32(0, buffer);
 
408
 
 
409
                        packstr(jobinfo->bg_block_id, buffer);
 
410
                        packstr(jobinfo->nodes, buffer);
 
411
                        packstr(jobinfo->ionodes, buffer);
 
412
 
 
413
                        if (cluster_flags & CLUSTER_FLAG_BGL)
 
414
                                packstr(jobinfo->blrtsimage, buffer);
 
415
 
 
416
                        packstr(jobinfo->linuximage, buffer);
 
417
                        packstr(jobinfo->mloaderimage, buffer);
 
418
                        packstr(jobinfo->ramdiskimage, buffer);
 
419
                } else {
 
420
                        /* pack space for 3 positions for geo
 
421
                         * then 1 for conn_type, reboot, and rotate
 
422
                         */
 
423
                        for (i=0; i<(SYSTEM_DIMENSIONS+3); i++)
 
424
                                pack16((uint16_t) 0, buffer);
 
425
 
 
426
                        pack32((uint32_t) 0, buffer); //node_cnt
 
427
                        pack32((uint32_t) 0, buffer); //max_cpus
 
428
 
 
429
                        packnull(buffer); //bg_block_id
 
430
                        packnull(buffer); //nodes
 
431
                        packnull(buffer); //ionodes
 
432
 
 
433
                        if (cluster_flags & CLUSTER_FLAG_BGL)
 
434
                                packnull(buffer); //blrts
 
435
 
 
436
                        packnull(buffer); //linux
 
437
                        packnull(buffer); //mloader
 
438
                        packnull(buffer); //ramdisk
 
439
                }
388
440
        }
389
 
 
390
441
        return SLURM_SUCCESS;
391
442
}
392
443
 
393
444
/* unpack a select job credential from a buffer
394
445
 * OUT jobinfo - the select job credential read
395
446
 * IN  buffer  - buffer with select credential read from current pointer loc
 
447
 * IN protocol_version - slurm protocol version of client
396
448
 * RET         - slurm error code
397
449
 * NOTE: returned value must be freed using free_jobinfo
398
450
 */
399
 
extern int unpack_select_jobinfo(select_jobinfo_t **jobinfo_pptr, Buf buffer)
 
451
extern int unpack_select_jobinfo(select_jobinfo_t **jobinfo_pptr, Buf buffer,
 
452
                                 uint16_t protocol_version)
400
453
{
401
454
        int i;
402
455
        uint32_t uint32_tmp;
 
456
        uint32_t cluster_flags = slurmdb_setup_cluster_flags();
 
457
        int dims = slurmdb_setup_cluster_dims();
403
458
        select_jobinfo_t *jobinfo = xmalloc(sizeof(struct select_jobinfo));
404
459
        *jobinfo_pptr = jobinfo;
405
460
 
406
461
        jobinfo->magic = JOBINFO_MAGIC;
407
 
        for (i=0; i<SYSTEM_DIMENSIONS; i++) {
408
 
                safe_unpack16(&(jobinfo->geometry[i]), buffer);
 
462
        if (protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
 
463
                for (i=0; i<dims; i++) {
 
464
                        safe_unpack16(&(jobinfo->geometry[i]), buffer);
 
465
                }
 
466
 
 
467
                safe_unpack16(&(jobinfo->conn_type), buffer);
 
468
                safe_unpack16(&(jobinfo->reboot), buffer);
 
469
                safe_unpack16(&(jobinfo->rotate), buffer);
 
470
 
 
471
                safe_unpack32(&(jobinfo->node_cnt), buffer);
 
472
 
 
473
                safe_unpackstr_xmalloc(&(jobinfo->bg_block_id), &uint32_tmp,
 
474
                                       buffer);
 
475
                safe_unpackstr_xmalloc(&(jobinfo->nodes), &uint32_tmp, buffer);
 
476
                safe_unpackstr_xmalloc(&(jobinfo->ionodes), &uint32_tmp,
 
477
                                       buffer);
 
478
 
 
479
                safe_unpackstr_xmalloc(&(jobinfo->blrtsimage),
 
480
                                       &uint32_tmp, buffer);
 
481
                safe_unpackstr_xmalloc(&(jobinfo->linuximage), &uint32_tmp,
 
482
                                       buffer);
 
483
                safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp,
 
484
                                       buffer);
 
485
                safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp,
 
486
                                       buffer);
 
487
        } else {
 
488
                for (i=0; i<dims; i++) {
 
489
                        safe_unpack16(&(jobinfo->geometry[i]), buffer);
 
490
                }
 
491
                safe_unpack16(&(jobinfo->conn_type), buffer);
 
492
                safe_unpack16(&(jobinfo->reboot), buffer);
 
493
                safe_unpack16(&(jobinfo->rotate), buffer);
 
494
 
 
495
                safe_unpack32(&(jobinfo->node_cnt), buffer);
 
496
                safe_unpack32(&uint32_tmp, buffer);
 
497
 
 
498
                safe_unpackstr_xmalloc(&(jobinfo->bg_block_id), &uint32_tmp,
 
499
                                       buffer);
 
500
                safe_unpackstr_xmalloc(&(jobinfo->nodes), &uint32_tmp, buffer);
 
501
                safe_unpackstr_xmalloc(&(jobinfo->ionodes), &uint32_tmp,
 
502
                                       buffer);
 
503
 
 
504
                if (cluster_flags & CLUSTER_FLAG_BGL)
 
505
                        safe_unpackstr_xmalloc(&(jobinfo->blrtsimage),
 
506
                                               &uint32_tmp, buffer);
 
507
                safe_unpackstr_xmalloc(&(jobinfo->linuximage), &uint32_tmp,
 
508
                                       buffer);
 
509
                safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp,
 
510
                                       buffer);
 
511
                safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp,
 
512
                                       buffer);
409
513
        }
410
 
        safe_unpack16(&(jobinfo->conn_type), buffer);
411
 
        safe_unpack16(&(jobinfo->reboot), buffer);
412
 
        safe_unpack16(&(jobinfo->rotate), buffer);
413
 
 
414
 
        safe_unpack32(&(jobinfo->node_cnt), buffer);
415
 
        safe_unpack32(&(jobinfo->max_cpus), buffer);
416
 
 
417
 
        safe_unpackstr_xmalloc(&(jobinfo->bg_block_id),  &uint32_tmp, buffer);
418
 
        safe_unpackstr_xmalloc(&(jobinfo->nodes),        &uint32_tmp, buffer);
419
 
        safe_unpackstr_xmalloc(&(jobinfo->ionodes),      &uint32_tmp, buffer);
420
 
#ifdef HAVE_BGL
421
 
        safe_unpackstr_xmalloc(&(jobinfo->blrtsimage),   &uint32_tmp, buffer);
422
 
#endif
423
 
        safe_unpackstr_xmalloc(&(jobinfo->linuximage),   &uint32_tmp, buffer);
424
 
        safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp, buffer);
425
 
        safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp, buffer);
426
 
 
427
514
        return SLURM_SUCCESS;
428
515
 
429
516
unpack_error:
442
529
extern char *sprint_select_jobinfo(select_jobinfo_t *jobinfo,
443
530
                                   char *buf, size_t size, int mode)
444
531
{
445
 
        uint16_t geometry[SYSTEM_DIMENSIONS];
 
532
        char *geo = NULL;
446
533
        int i;
447
 
        char max_cpus_char[8];
448
534
        char *tmp_image = "default";
 
535
        char *header = "CONNECT REBOOT ROTATE GEOMETRY BLOCK_ID";
449
536
 
450
537
        if (buf == NULL) {
451
538
                error("sprint_jobinfo: buf is null");
453
540
        }
454
541
 
455
542
        if ((mode != SELECT_PRINT_DATA)
456
 
        && jobinfo && (jobinfo->magic != JOBINFO_MAGIC)) {
 
543
            && jobinfo && (jobinfo->magic != JOBINFO_MAGIC)) {
457
544
                error("sprint_jobinfo: jobinfo magic bad");
458
545
                return NULL;
459
546
        }
463
550
                        error("sprint_jobinfo: jobinfo bad");
464
551
                        return NULL;
465
552
                }
466
 
        } else if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
467
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++)
468
 
                        geometry[i] = 0;
469
 
        } else {
470
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++)
471
 
                        geometry[i] = jobinfo->geometry[i];
 
553
 
 
554
                snprintf(buf, size, "%s", header);
 
555
                return buf;
472
556
        }
473
557
 
 
558
        if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
 
559
                for (i=0; i<SYSTEM_DIMENSIONS; i++) {
 
560
                        if (geo)
 
561
                                xstrcat(geo, "x0");
 
562
                        else
 
563
                                xstrcat(geo, "0");
 
564
                }
 
565
        } else
 
566
                geo = give_geo(jobinfo->geometry);
 
567
 
474
568
        switch (mode) {
475
569
        case SELECT_PRINT_HEAD:
476
 
                snprintf(buf, size,
477
 
                         "CONNECT REBOOT ROTATE MAX_CPUS GEOMETRY BLOCK_ID");
 
570
                snprintf(buf, size, "%s", header);
478
571
                break;
479
572
        case SELECT_PRINT_DATA:
480
 
                if (jobinfo->max_cpus == NO_VAL)
481
 
                        sprintf(max_cpus_char, "None");
482
 
                else
483
 
                        convert_num_unit((float)jobinfo->max_cpus,
484
 
                                         max_cpus_char, sizeof(max_cpus_char),
485
 
                                         UNIT_NONE);
486
573
                snprintf(buf, size,
487
 
                         "%7.7s %6.6s %6.6s %8s    %cx%cx%c %-16s",
 
574
                         "%7.7s %6.6s %6.6s    %s %-16s",
488
575
                         conn_type_string(jobinfo->conn_type),
489
576
                         _yes_no_string(jobinfo->reboot),
490
577
                         _yes_no_string(jobinfo->rotate),
491
 
                         max_cpus_char,
492
 
                         alpha_num[geometry[0]],
493
 
                         alpha_num[geometry[1]],
494
 
                         alpha_num[geometry[2]],
 
578
                         geo,
495
579
                         jobinfo->bg_block_id);
496
580
                break;
497
581
        case SELECT_PRINT_MIXED_SHORT:
498
582
                snprintf(buf, size,
499
583
                         "Connection=%s Reboot=%s Rotate=%s "
500
 
                         "Geometry=%cx%cx%c",
 
584
                         "Geometry=%s",
501
585
                         conn_type_string(jobinfo->conn_type),
502
586
                         _yes_no_string(jobinfo->reboot),
503
587
                         _yes_no_string(jobinfo->rotate),
504
 
                         alpha_num[geometry[0]],
505
 
                         alpha_num[geometry[1]],
506
 
                         alpha_num[geometry[2]]);
 
588
                         geo);
507
589
                break;
508
590
        case SELECT_PRINT_MIXED:
509
591
                snprintf(buf, size,
510
592
                         "Connection=%s Reboot=%s Rotate=%s "
511
 
                         "Geometry=%cx%cx%c Block_ID=%s",
 
593
                         "Geometry=%s Block_ID=%s",
512
594
                         conn_type_string(jobinfo->conn_type),
513
595
                         _yes_no_string(jobinfo->reboot),
514
596
                         _yes_no_string(jobinfo->rotate),
515
 
                         alpha_num[geometry[0]],
516
 
                         alpha_num[geometry[1]],
517
 
                         alpha_num[geometry[2]],
 
597
                         geo,
518
598
                         jobinfo->bg_block_id);
519
599
                break;
520
600
        case SELECT_PRINT_BG_ID:
521
601
                snprintf(buf, size, "%s", jobinfo->bg_block_id);
522
602
                break;
523
603
        case SELECT_PRINT_NODES:
524
 
                if(jobinfo->ionodes && jobinfo->ionodes[0])
 
604
                if (jobinfo->ionodes && jobinfo->ionodes[0])
525
605
                        snprintf(buf, size, "%s[%s]",
526
606
                                 jobinfo->nodes, jobinfo->ionodes);
527
607
                else
540
620
                         _yes_no_string(jobinfo->rotate));
541
621
                break;
542
622
        case SELECT_PRINT_GEOMETRY:
543
 
                snprintf(buf, size, "%cx%cx%c",
544
 
                         alpha_num[geometry[0]],
545
 
                         alpha_num[geometry[1]],
546
 
                         alpha_num[geometry[2]]);
547
 
                break;
548
 
        case SELECT_PRINT_MAX_CPUS:
549
 
                if (jobinfo->max_cpus == NO_VAL)
550
 
                        sprintf(max_cpus_char, "None");
551
 
                else
552
 
                        convert_num_unit((float)jobinfo->max_cpus,
553
 
                                         max_cpus_char, sizeof(max_cpus_char),
554
 
                                         UNIT_NONE);
555
 
 
556
 
                snprintf(buf, size, "%s", max_cpus_char);
 
623
                snprintf(buf, size, "%s", geo);
557
624
                break;
558
625
        case SELECT_PRINT_BLRTS_IMAGE:
559
 
#ifdef HAVE_BGL
560
 
                if(jobinfo->blrtsimage)
 
626
                if (jobinfo->blrtsimage)
561
627
                        tmp_image = jobinfo->blrtsimage;
562
628
                snprintf(buf, size, "%s", tmp_image);
563
 
#endif
564
629
                break;
565
630
        case SELECT_PRINT_LINUX_IMAGE:
566
 
                if(jobinfo->linuximage)
 
631
                if (jobinfo->linuximage)
567
632
                        tmp_image = jobinfo->linuximage;
568
633
                snprintf(buf, size, "%s", tmp_image);
569
634
                break;
570
635
        case SELECT_PRINT_MLOADER_IMAGE:
571
 
                if(jobinfo->mloaderimage)
 
636
                if (jobinfo->mloaderimage)
572
637
                        tmp_image = jobinfo->mloaderimage;
573
638
                snprintf(buf, size, "%s", tmp_image);
574
639
                break;
575
640
        case SELECT_PRINT_RAMDISK_IMAGE:
576
 
                if(jobinfo->ramdiskimage)
 
641
                if (jobinfo->ramdiskimage)
577
642
                        tmp_image = jobinfo->ramdiskimage;
578
643
                snprintf(buf, size, "%s", tmp_image);
579
644
                break;
582
647
                if (size > 0)
583
648
                        buf[0] = '\0';
584
649
        }
585
 
 
 
650
        xfree(geo);
586
651
        return buf;
587
652
}
588
653
 
593
658
 */
594
659
extern char *xstrdup_select_jobinfo(select_jobinfo_t *jobinfo, int mode)
595
660
{
596
 
        uint16_t geometry[SYSTEM_DIMENSIONS];
 
661
        char *geo = NULL;
597
662
        int i;
598
 
        char max_cpus_char[8];
599
663
        char *tmp_image = "default";
600
664
        char *buf = NULL;
 
665
        char *header = "CONNECT REBOOT ROTATE GEOMETRY BLOCK_ID";
601
666
 
602
667
        if ((mode != SELECT_PRINT_DATA)
603
668
            && jobinfo && (jobinfo->magic != JOBINFO_MAGIC)) {
610
675
                        error("xstrdup_jobinfo: jobinfo bad");
611
676
                        return NULL;
612
677
                }
613
 
        } else if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
614
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++)
615
 
                        geometry[i] = 0;
616
 
        } else {
617
 
                for (i=0; i<SYSTEM_DIMENSIONS; i++)
618
 
                        geometry[i] = jobinfo->geometry[i];
 
678
                xstrcat(buf, header);
 
679
                return buf;
619
680
        }
620
681
 
 
682
        if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
 
683
                for (i=0; i<SYSTEM_DIMENSIONS; i++) {
 
684
                        if (geo)
 
685
                                xstrcat(geo, "x0");
 
686
                        else
 
687
                                xstrcat(geo, "0");
 
688
                }
 
689
        } else
 
690
                geo = give_geo(jobinfo->geometry);
 
691
 
621
692
        switch (mode) {
622
693
        case SELECT_PRINT_HEAD:
623
 
                xstrcat(buf,
624
 
                        "CONNECT REBOOT ROTATE MAX_CPUS GEOMETRY BLOCK_ID");
 
694
                xstrcat(buf, header);
625
695
                break;
626
696
        case SELECT_PRINT_DATA:
627
 
                if (jobinfo->max_cpus == NO_VAL)
628
 
                        sprintf(max_cpus_char, "None");
629
 
                else
630
 
                        convert_num_unit((float)jobinfo->max_cpus,
631
 
                                         max_cpus_char, sizeof(max_cpus_char),
632
 
                                         UNIT_NONE);
633
697
                xstrfmtcat(buf,
634
 
                           "%7.7s %6.6s %6.6s %8s    %cx%cx%c %-16s",
 
698
                           "%7.7s %6.6s %6.6s    %s %-16s",
635
699
                           conn_type_string(jobinfo->conn_type),
636
700
                           _yes_no_string(jobinfo->reboot),
637
701
                           _yes_no_string(jobinfo->rotate),
638
 
                           max_cpus_char,
639
 
                           alpha_num[geometry[0]],
640
 
                           alpha_num[geometry[1]],
641
 
                           alpha_num[geometry[2]],
 
702
                           geo,
642
703
                           jobinfo->bg_block_id);
643
704
                break;
644
705
        case SELECT_PRINT_MIXED:
645
706
                xstrfmtcat(buf,
646
 
                         "Connection=%s Reboot=%s Rotate=%s "
647
 
                         "Geometry=%cx%cx%c Block_ID=%s",
648
 
                         conn_type_string(jobinfo->conn_type),
649
 
                         _yes_no_string(jobinfo->reboot),
650
 
                         _yes_no_string(jobinfo->rotate),
651
 
                         alpha_num[geometry[0]],
652
 
                         alpha_num[geometry[1]],
653
 
                         alpha_num[geometry[2]],
654
 
                         jobinfo->bg_block_id);
 
707
                           "Connection=%s Reboot=%s Rotate=%s "
 
708
                           "Geometry=%s Block_ID=%s",
 
709
                           conn_type_string(jobinfo->conn_type),
 
710
                           _yes_no_string(jobinfo->reboot),
 
711
                           _yes_no_string(jobinfo->rotate),
 
712
                           geo,
 
713
                           jobinfo->bg_block_id);
655
714
                break;
656
715
        case SELECT_PRINT_BG_ID:
657
716
                xstrfmtcat(buf, "%s", jobinfo->bg_block_id);
658
717
                break;
659
718
        case SELECT_PRINT_NODES:
660
 
                if(jobinfo->ionodes && jobinfo->ionodes[0])
 
719
                if (jobinfo->ionodes && jobinfo->ionodes[0])
661
720
                        xstrfmtcat(buf, "%s[%s]",
662
 
                                 jobinfo->nodes, jobinfo->ionodes);
 
721
                                   jobinfo->nodes, jobinfo->ionodes);
663
722
                else
664
723
                        xstrfmtcat(buf, "%s", jobinfo->nodes);
665
724
                break;
676
735
                           _yes_no_string(jobinfo->rotate));
677
736
                break;
678
737
        case SELECT_PRINT_GEOMETRY:
679
 
                xstrfmtcat(buf, "%cx%cx%c",
680
 
                           alpha_num[geometry[0]],
681
 
                           alpha_num[geometry[1]],
682
 
                           alpha_num[geometry[2]]);
683
 
                break;
684
 
        case SELECT_PRINT_MAX_CPUS:
685
 
                if (jobinfo->max_cpus == NO_VAL)
686
 
                        sprintf(max_cpus_char, "None");
687
 
                else
688
 
                        convert_num_unit((float)jobinfo->max_cpus,
689
 
                                         max_cpus_char, sizeof(max_cpus_char),
690
 
                                         UNIT_NONE);
691
 
 
692
 
                xstrfmtcat(buf, "%s", max_cpus_char);
 
738
                xstrfmtcat(buf, "%s", geo);
693
739
                break;
694
740
        case SELECT_PRINT_BLRTS_IMAGE:
695
 
#ifdef HAVE_BGL
696
 
                if(jobinfo->blrtsimage)
 
741
                if (jobinfo->blrtsimage)
697
742
                        tmp_image = jobinfo->blrtsimage;
698
743
                xstrfmtcat(buf, "%s", tmp_image);
699
 
#endif
700
744
                break;
701
745
        case SELECT_PRINT_LINUX_IMAGE:
702
 
                if(jobinfo->linuximage)
 
746
                if (jobinfo->linuximage)
703
747
                        tmp_image = jobinfo->linuximage;
704
748
                xstrfmtcat(buf, "%s", tmp_image);
705
749
                break;
706
750
        case SELECT_PRINT_MLOADER_IMAGE:
707
 
                if(jobinfo->mloaderimage)
 
751
                if (jobinfo->mloaderimage)
708
752
                        tmp_image = jobinfo->mloaderimage;
709
753
                xstrfmtcat(buf, "%s", tmp_image);
710
754
                break;
711
755
        case SELECT_PRINT_RAMDISK_IMAGE:
712
 
                if(jobinfo->ramdiskimage)
 
756
                if (jobinfo->ramdiskimage)
713
757
                        tmp_image = jobinfo->ramdiskimage;
714
758
                xstrfmtcat(buf, "%s", tmp_image);
715
759
                break;
716
760
        default:
717
761
                error("xstrdup_jobinfo: bad mode %d", mode);
718
762
        }
719
 
 
 
763
        xfree(geo);
720
764
        return buf;
721
765
}