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
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)
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();
354
if (protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
356
/* NOTE: If new elements are added here, make sure to
357
* add equivalant pack of zeros below for NULL
359
for (i=0; i<dims; i++) {
360
pack16(jobinfo->geometry[i], buffer);
362
pack16(jobinfo->conn_type, buffer);
363
pack16(jobinfo->reboot, buffer);
364
pack16(jobinfo->rotate, buffer);
366
pack32(jobinfo->node_cnt, buffer);
368
packstr(jobinfo->bg_block_id, buffer);
369
packstr(jobinfo->nodes, buffer);
370
packstr(jobinfo->ionodes, buffer);
372
packstr(jobinfo->blrtsimage, buffer);
373
packstr(jobinfo->linuximage, buffer);
374
packstr(jobinfo->mloaderimage, buffer);
375
packstr(jobinfo->ramdiskimage, buffer);
377
/* pack space for 3 positions for geo
378
* then 1 for conn_type, reboot, and rotate
380
for (i=0; i<(dims+3); i++)
381
pack16((uint16_t) 0, buffer);
383
pack32((uint32_t) 0, buffer); //node_cnt
385
packnull(buffer); //bg_block_id
386
packnull(buffer); //nodes
387
packnull(buffer); //ionodes
389
packnull(buffer); //blrts
390
packnull(buffer); //linux
391
packnull(buffer); //mloader
392
packnull(buffer); //ramdisk
353
pack16(jobinfo->conn_type, buffer);
354
pack16(jobinfo->reboot, buffer);
355
pack16(jobinfo->rotate, buffer);
357
pack32(jobinfo->node_cnt, buffer);
358
pack32(jobinfo->max_cpus, buffer);
360
packstr(jobinfo->bg_block_id, buffer);
361
packstr(jobinfo->nodes, buffer);
362
packstr(jobinfo->ionodes, buffer);
364
packstr(jobinfo->blrtsimage, buffer);
366
packstr(jobinfo->linuximage, buffer);
367
packstr(jobinfo->mloaderimage, buffer);
368
packstr(jobinfo->ramdiskimage, buffer);
370
/* pack space for 3 positions for geo
371
* then 1 for conn_type, reboot, and rotate
373
for (i=0; i<(SYSTEM_DIMENSIONS+3); i++)
374
pack16((uint16_t) 0, buffer);
376
pack32((uint32_t) 0, buffer); //node_cnt
377
pack32((uint32_t) 0, buffer); //max_cpus
379
packnull(buffer); //bg_block_id
380
packnull(buffer); //nodes
381
packnull(buffer); //ionodes
383
packnull(buffer); //blrts
385
packnull(buffer); //linux
386
packnull(buffer); //mloader
387
packnull(buffer); //ramdisk
396
/* NOTE: If new elements are added here, make sure to
397
* add equivalant pack of zeros below for NULL
399
for (i=0; i<SYSTEM_DIMENSIONS; i++) {
400
pack16(jobinfo->geometry[i], buffer);
402
pack16(jobinfo->conn_type, buffer);
403
pack16(jobinfo->reboot, buffer);
404
pack16(jobinfo->rotate, buffer);
406
pack32(jobinfo->node_cnt, buffer);
409
packstr(jobinfo->bg_block_id, buffer);
410
packstr(jobinfo->nodes, buffer);
411
packstr(jobinfo->ionodes, buffer);
413
if (cluster_flags & CLUSTER_FLAG_BGL)
414
packstr(jobinfo->blrtsimage, buffer);
416
packstr(jobinfo->linuximage, buffer);
417
packstr(jobinfo->mloaderimage, buffer);
418
packstr(jobinfo->ramdiskimage, buffer);
420
/* pack space for 3 positions for geo
421
* then 1 for conn_type, reboot, and rotate
423
for (i=0; i<(SYSTEM_DIMENSIONS+3); i++)
424
pack16((uint16_t) 0, buffer);
426
pack32((uint32_t) 0, buffer); //node_cnt
427
pack32((uint32_t) 0, buffer); //max_cpus
429
packnull(buffer); //bg_block_id
430
packnull(buffer); //nodes
431
packnull(buffer); //ionodes
433
if (cluster_flags & CLUSTER_FLAG_BGL)
434
packnull(buffer); //blrts
436
packnull(buffer); //linux
437
packnull(buffer); //mloader
438
packnull(buffer); //ramdisk
390
441
return SLURM_SUCCESS;
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
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)
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;
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);
467
safe_unpack16(&(jobinfo->conn_type), buffer);
468
safe_unpack16(&(jobinfo->reboot), buffer);
469
safe_unpack16(&(jobinfo->rotate), buffer);
471
safe_unpack32(&(jobinfo->node_cnt), buffer);
473
safe_unpackstr_xmalloc(&(jobinfo->bg_block_id), &uint32_tmp,
475
safe_unpackstr_xmalloc(&(jobinfo->nodes), &uint32_tmp, buffer);
476
safe_unpackstr_xmalloc(&(jobinfo->ionodes), &uint32_tmp,
479
safe_unpackstr_xmalloc(&(jobinfo->blrtsimage),
480
&uint32_tmp, buffer);
481
safe_unpackstr_xmalloc(&(jobinfo->linuximage), &uint32_tmp,
483
safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp,
485
safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp,
488
for (i=0; i<dims; i++) {
489
safe_unpack16(&(jobinfo->geometry[i]), buffer);
491
safe_unpack16(&(jobinfo->conn_type), buffer);
492
safe_unpack16(&(jobinfo->reboot), buffer);
493
safe_unpack16(&(jobinfo->rotate), buffer);
495
safe_unpack32(&(jobinfo->node_cnt), buffer);
496
safe_unpack32(&uint32_tmp, buffer);
498
safe_unpackstr_xmalloc(&(jobinfo->bg_block_id), &uint32_tmp,
500
safe_unpackstr_xmalloc(&(jobinfo->nodes), &uint32_tmp, buffer);
501
safe_unpackstr_xmalloc(&(jobinfo->ionodes), &uint32_tmp,
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,
509
safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp,
511
safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp,
410
safe_unpack16(&(jobinfo->conn_type), buffer);
411
safe_unpack16(&(jobinfo->reboot), buffer);
412
safe_unpack16(&(jobinfo->rotate), buffer);
414
safe_unpack32(&(jobinfo->node_cnt), buffer);
415
safe_unpack32(&(jobinfo->max_cpus), buffer);
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);
421
safe_unpackstr_xmalloc(&(jobinfo->blrtsimage), &uint32_tmp, buffer);
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);
427
514
return SLURM_SUCCESS;
463
550
error("sprint_jobinfo: jobinfo bad");
466
} else if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
467
for (i=0; i<SYSTEM_DIMENSIONS; i++)
470
for (i=0; i<SYSTEM_DIMENSIONS; i++)
471
geometry[i] = jobinfo->geometry[i];
554
snprintf(buf, size, "%s", header);
558
if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
559
for (i=0; i<SYSTEM_DIMENSIONS; i++) {
566
geo = give_geo(jobinfo->geometry);
475
569
case SELECT_PRINT_HEAD:
477
"CONNECT REBOOT ROTATE MAX_CPUS GEOMETRY BLOCK_ID");
570
snprintf(buf, size, "%s", header);
479
572
case SELECT_PRINT_DATA:
480
if (jobinfo->max_cpus == NO_VAL)
481
sprintf(max_cpus_char, "None");
483
convert_num_unit((float)jobinfo->max_cpus,
484
max_cpus_char, sizeof(max_cpus_char),
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),
492
alpha_num[geometry[0]],
493
alpha_num[geometry[1]],
494
alpha_num[geometry[2]],
495
579
jobinfo->bg_block_id);
497
581
case SELECT_PRINT_MIXED_SHORT:
498
582
snprintf(buf, size,
499
583
"Connection=%s Reboot=%s Rotate=%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]]);
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]],
518
598
jobinfo->bg_block_id);
520
600
case SELECT_PRINT_BG_ID:
521
601
snprintf(buf, size, "%s", jobinfo->bg_block_id);
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);
610
675
error("xstrdup_jobinfo: jobinfo bad");
613
} else if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
614
for (i=0; i<SYSTEM_DIMENSIONS; i++)
617
for (i=0; i<SYSTEM_DIMENSIONS; i++)
618
geometry[i] = jobinfo->geometry[i];
678
xstrcat(buf, header);
682
if (jobinfo->geometry[0] == (uint16_t) NO_VAL) {
683
for (i=0; i<SYSTEM_DIMENSIONS; i++) {
690
geo = give_geo(jobinfo->geometry);
622
693
case SELECT_PRINT_HEAD:
624
"CONNECT REBOOT ROTATE MAX_CPUS GEOMETRY BLOCK_ID");
694
xstrcat(buf, header);
626
696
case SELECT_PRINT_DATA:
627
if (jobinfo->max_cpus == NO_VAL)
628
sprintf(max_cpus_char, "None");
630
convert_num_unit((float)jobinfo->max_cpus,
631
max_cpus_char, sizeof(max_cpus_char),
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),
639
alpha_num[geometry[0]],
640
alpha_num[geometry[1]],
641
alpha_num[geometry[2]],
642
703
jobinfo->bg_block_id);
644
705
case SELECT_PRINT_MIXED:
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),
713
jobinfo->bg_block_id);
656
715
case SELECT_PRINT_BG_ID:
657
716
xstrfmtcat(buf, "%s", jobinfo->bg_block_id);
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);
664
723
xstrfmtcat(buf, "%s", jobinfo->nodes);