~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/sacctmgr/cluster_functions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *  Copyright (C) 2002-2007 The Regents of the University of California.
7
7
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8
8
 *  Written by Danny Auble <da@llnl.gov>
9
 
 *  LLNL-CODE-402394.
 
9
 *  CODE-OCEC-09-009. All rights reserved.
10
10
 *  
11
11
 *  This file is part of SLURM, a resource management program.
12
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
12
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
13
 *  Please also read the included file: DISCLAIMER.
13
14
 *  
14
15
 *  SLURM is free software; you can redistribute it and/or modify it under
15
16
 *  the terms of the GNU General Public License as published by the Free
42
43
 
43
44
static int _set_cond(int *start, int argc, char *argv[],
44
45
                     List cluster_list,
45
 
                     List format_list)
 
46
                     List format_list,
 
47
                     uint16_t *classification)
46
48
{
47
49
        int i;
48
50
        int set = 0;
71
73
                } else if(!end || !strncasecmp (argv[i], "Names",
72
74
                                                MAX(command_len, 1))
73
75
                          || !strncasecmp (argv[i], "Clusters",
74
 
                                           MAX(command_len, 1))) {
 
76
                                           MAX(command_len, 3))) {
75
77
                        if(cluster_list) {
76
78
                                if(slurm_addto_char_list(cluster_list,
77
79
                                                         argv[i]+end))
78
80
                                        set = 1;
79
81
                        }
 
82
                } else if (!strncasecmp (argv[i], "Classification", 
 
83
                                         MAX(command_len, 3))) {
 
84
                        if(classification) {
 
85
                                *classification = 
 
86
                                        str_2_classification(argv[i]+end);
 
87
                                if(*classification)
 
88
                                        set = 1;
 
89
                        }
80
90
                } else if (!strncasecmp (argv[i], "Format",
81
91
                                         MAX(command_len, 1))) {
82
92
                        if(format_list)
95
105
 
96
106
static int _set_rec(int *start, int argc, char *argv[],
97
107
                    List name_list,
98
 
                    acct_association_rec_t *assoc)
 
108
                    acct_association_rec_t *assoc,
 
109
                    uint16_t *classification)
99
110
{
100
111
        int i, mins;
101
112
        int set = 0;
126
137
                          || !strncasecmp (argv[i], "Names",
127
138
                                           MAX(command_len, 1)) 
128
139
                          || !strncasecmp (argv[i], "Clusters", 
129
 
                                           MAX(command_len, 1))) {
 
140
                                           MAX(command_len, 3))) {
130
141
                        if(name_list)
131
 
                                slurm_addto_char_list(name_list, argv[i]+end);
 
142
                                slurm_addto_char_list(name_list,
 
143
                                                      argv[i]+end);
 
144
                } else if (!strncasecmp (argv[i], "Classification", 
 
145
                                         MAX(command_len, 3))) {
 
146
                        if(classification) {
 
147
                                *classification = 
 
148
                                        str_2_classification(argv[i]+end);
 
149
                                if(*classification)
 
150
                                        set = 1;
 
151
                        }
132
152
                } else if (!strncasecmp (argv[i], "FairShare", 
133
153
                                         MAX(command_len, 1))
134
154
                           || !strncasecmp (argv[i], "Shares",
135
155
                                         MAX(command_len, 1))) {
136
 
                        if (get_uint(argv[i]+end, &assoc->fairshare, 
 
156
                        if (get_uint(argv[i]+end, &assoc->shares_raw, 
137
157
                            "FairShare") == SLURM_SUCCESS)
138
158
                                set = 1;
139
159
                } else if (!strncasecmp (argv[i], "GrpCPUMins",
140
160
                                         MAX(command_len, 7))) {
141
 
                        if (get_uint64(argv[i]+end, 
142
 
                                       &assoc->grp_cpu_mins, 
143
 
                                       "GrpCPUMins") == SLURM_SUCCESS)
144
 
                                set = 1;
 
161
                        exit_code=1;
 
162
                        fprintf(stderr, "GrpCPUMins is not a valid option "
 
163
                                "for the root association of a cluster.\n");
 
164
                        break;                  
145
165
                } else if (!strncasecmp (argv[i], "GrpCpus",
146
166
                                         MAX(command_len, 7))) {
147
167
                        if (get_uint(argv[i]+end, &assoc->grp_cpus,
164
184
                                set = 1;
165
185
                } else if (!strncasecmp (argv[i], "GrpWall",
166
186
                                         MAX(command_len, 4))) {
167
 
                        mins = time_str2mins(argv[i]+end);
168
 
                        if (mins != NO_VAL) {
169
 
                                assoc->grp_wall = (uint32_t) mins;
170
 
                                set = 1;
171
 
                        } else {
172
 
                                exit_code=1;
173
 
                                fprintf(stderr, 
174
 
                                        " Bad GrpWall time format: %s\n", 
175
 
                                        argv[i]);
176
 
                        }
 
187
                        exit_code=1;
 
188
                        fprintf(stderr, "GrpWall is not a valid option "
 
189
                                "for the root association of a cluster.\n");
177
190
                } else if (!strncasecmp (argv[i], "MaxCPUMinsPerJob",
178
191
                                         MAX(command_len, 7))) {
179
192
                        if (get_uint64(argv[i]+end, 
257
270
        int limit_set = 0;
258
271
        ListIterator itr = NULL, itr_c = NULL;
259
272
        char *name = NULL;
 
273
        uint16_t class = 0;
260
274
 
261
275
        init_acct_association_rec(&start_assoc);
262
276
 
263
 
        for (i=0; i<argc; i++) 
264
 
                limit_set = _set_rec(&i, argc, argv, name_list, &start_assoc);
265
 
 
 
277
        for (i=0; i<argc; i++) {
 
278
                int command_len = strlen(argv[i]);
 
279
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
 
280
                    || !strncasecmp (argv[i], "Set", MAX(command_len, 3))) 
 
281
                        i++;            
 
282
                limit_set += _set_rec(&i, argc, argv,
 
283
                                     name_list, &start_assoc, &class);
 
284
        }
266
285
        if(exit_code) {
267
286
                list_destroy(name_list);
268
287
                return SLURM_ERROR;
278
297
 
279
298
                memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
280
299
                cluster_cond.cluster_list = name_list;
 
300
                cluster_cond.classification = class;
281
301
 
282
302
                temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
283
303
                                                        &cluster_cond);
322
342
                
323
343
                list_append(cluster_list, cluster);
324
344
                cluster->name = xstrdup(name);
 
345
                cluster->classification = class;
325
346
                cluster->root_assoc = xmalloc(sizeof(acct_association_rec_t));
326
347
                init_acct_association_rec(cluster->root_assoc);
327
348
                printf("  Name          = %s\n", cluster->name);
 
349
                if(cluster->classification)
 
350
                        printf("  Classification= %s\n",
 
351
                               get_classification_str(cluster->classification));
328
352
 
329
 
                cluster->root_assoc->fairshare = start_assoc.fairshare;         
 
353
                cluster->root_assoc->shares_raw = start_assoc.shares_raw;
330
354
                
331
 
                cluster->root_assoc->grp_cpu_mins = start_assoc.grp_cpu_mins;
332
355
                cluster->root_assoc->grp_cpus = start_assoc.grp_cpus;
333
356
                cluster->root_assoc->grp_jobs = start_assoc.grp_jobs;
334
357
                cluster->root_assoc->grp_nodes = start_assoc.grp_nodes;
335
358
                cluster->root_assoc->grp_submit_jobs =
336
359
                        start_assoc.grp_submit_jobs;
337
 
                cluster->root_assoc->grp_wall = start_assoc.grp_wall;
338
360
 
339
361
                cluster->root_assoc->max_cpu_mins_pj = 
340
362
                        start_assoc.max_cpu_mins_pj;
407
429
                PRINT_CLUSTER,
408
430
                PRINT_CHOST,
409
431
                PRINT_CPORT,
 
432
                PRINT_CLASS,
 
433
                PRINT_CPUS,
410
434
                PRINT_FAIRSHARE,
411
435
                PRINT_GRPCM,
412
436
                PRINT_GRPC,
420
444
                PRINT_MAXN,
421
445
                PRINT_MAXS,
422
446
                PRINT_MAXW,
 
447
                PRINT_NODECNT,
 
448
                PRINT_NODES,
423
449
                PRINT_QOS,
424
450
                PRINT_QOS_RAW,
425
451
                PRINT_RPC_VERSION               
427
453
 
428
454
 
429
455
        cluster_cond->cluster_list = list_create(slurm_destroy_char);
430
 
        _set_cond(&i, argc, argv, cluster_cond->cluster_list, format_list);
 
456
        for (i=0; i<argc; i++) {
 
457
                int command_len = strlen(argv[i]);
 
458
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
 
459
                    || !strncasecmp (argv[i], "Set", MAX(command_len, 3))) 
 
460
                        i++;
 
461
                _set_cond(&i, argc, argv, cluster_cond->cluster_list, 
 
462
                          format_list,
 
463
                          &cluster_cond->classification);
 
464
        }
 
465
 
431
466
        if(exit_code) {
432
467
                destroy_acct_cluster_cond(cluster_cond);
433
468
                list_destroy(format_list);
465
500
                } else if(!strncasecmp("ControlHost", object,
466
501
                                       MAX(command_len, 8))) {
467
502
                        field->type = PRINT_CHOST;
468
 
                        field->name = xstrdup("Control Host");
 
503
                        field->name = xstrdup("ControlHost");
469
504
                        field->len = 15;
470
505
                        field->print_routine = print_fields_str;
471
506
                } else if(!strncasecmp("ControlPort", object,
472
507
                                       MAX(command_len, 8))) {
473
508
                        field->type = PRINT_CPORT;
474
 
                        field->name = xstrdup("Control Port");
 
509
                        field->name = xstrdup("ControlPort");
475
510
                        field->len = 12;
476
511
                        field->print_routine = print_fields_uint;
 
512
                } else if(!strncasecmp("Classification", object,
 
513
                                       MAX(command_len, 2))) {
 
514
                        field->type = PRINT_CPUS;
 
515
                        field->name = xstrdup("Class");
 
516
                        field->len = 9;
 
517
                        field->print_routine = print_fields_str;
 
518
                } else if(!strncasecmp("CPUCount", object,
 
519
                                       MAX(command_len, 2))) {
 
520
                        field->type = PRINT_CPUS;
 
521
                        field->name = xstrdup("CPUCount");
 
522
                        field->len = 9;
 
523
                        field->print_routine = print_fields_str;
477
524
                } else if(!strncasecmp("FairShare", object, 
478
525
                                       MAX(command_len, 1))) {
479
526
                        field->type = PRINT_FAIRSHARE;
480
527
                        field->name = xstrdup("FairShare");
481
528
                        field->len = 9;
482
529
                        field->print_routine = print_fields_uint;
483
 
                } else if(!strncasecmp("GrpCPUMins", object, 
484
 
                                       MAX(command_len, 8))) {
485
 
                        field->type = PRINT_GRPCM;
486
 
                        field->name = xstrdup("GrpCPUMins");
487
 
                        field->len = 11;
488
 
                        field->print_routine = print_fields_uint64;
489
530
                } else if(!strncasecmp("GrpCPUs", object, 
490
531
                                       MAX(command_len, 8))) {
491
532
                        field->type = PRINT_GRPC;
510
551
                        field->name = xstrdup("GrpSubmit");
511
552
                        field->len = 9;
512
553
                        field->print_routine = print_fields_uint;
513
 
                } else if(!strncasecmp("GrpWall", object,
514
 
                                       MAX(command_len, 4))) {
515
 
                        field->type = PRINT_GRPW;
516
 
                        field->name = xstrdup("GrpWall");
517
 
                        field->len = 11;
518
 
                        field->print_routine = print_fields_time;
519
554
                } else if(!strncasecmp("MaxCPUMinsPerJob", object,
520
555
                                       MAX(command_len, 7))) {
521
556
                        field->type = PRINT_MAXCM;
552
587
                        field->name = xstrdup("MaxWall");
553
588
                        field->len = 11;
554
589
                        field->print_routine = print_fields_time;
 
590
                } else if(!strncasecmp("NodeCount", object,
 
591
                                       MAX(command_len, 5))) {
 
592
                        field->type = PRINT_NODECNT;
 
593
                        field->name = xstrdup("NodeCount");
 
594
                        field->len = 9;
 
595
                        field->print_routine = print_fields_uint;
 
596
                } else if(!strncasecmp("NodeNames", object,
 
597
                                       MAX(command_len, 5))) {
 
598
                        field->type = PRINT_NODES;
 
599
                        field->name = xstrdup("NodeNames");
 
600
                        field->len = 20;
 
601
                        field->print_routine = print_fields_str;
555
602
                } else if(!strncasecmp("QOSRAWLevel", object, 
556
603
                                       MAX(command_len, 4))) {
557
604
                        field->type = PRINT_QOS_RAW;
582
629
                        continue;
583
630
                }
584
631
                
585
 
                if(newlen > 0) 
 
632
                if(newlen) 
586
633
                        field->len = newlen;
587
634
                
588
635
                list_append(print_fields_list, field);          
633
680
                                                     cluster->control_port,
634
681
                                                     (curr_inx == field_count));
635
682
                                break;
 
683
                        case PRINT_CLASS:
 
684
                                field->print_routine(field,
 
685
                                                     get_classification_str(
 
686
                                                             cluster->
 
687
                                                             classification),
 
688
                                                     (curr_inx == field_count));
 
689
                                break;
 
690
                        case PRINT_CPUS:
 
691
                        {
 
692
                                char tmp_char[9];
 
693
                                convert_num_unit((float)cluster->cpu_count,
 
694
                                                 tmp_char, sizeof(tmp_char),
 
695
                                                 UNIT_NONE);
 
696
                                field->print_routine(field,
 
697
                                                     tmp_char,
 
698
                                                     (curr_inx == field_count));
 
699
                                break;
 
700
                        }
636
701
                        case PRINT_FAIRSHARE:
637
702
                                field->print_routine(
638
703
                                        field,
639
 
                                        cluster->root_assoc->fairshare,
640
 
                                        (curr_inx == field_count));
641
 
                                break;
642
 
                        case PRINT_GRPCM:
643
 
                                field->print_routine(
644
 
                                        field,
645
 
                                        assoc->grp_cpu_mins,
 
704
                                        assoc->shares_raw,
646
705
                                        (curr_inx == field_count));
647
706
                                break;
648
707
                        case PRINT_GRPC:
665
724
                                                     assoc->grp_submit_jobs,
666
725
                                                     (curr_inx == field_count));
667
726
                                break;
668
 
                        case PRINT_GRPW:
669
 
                                field->print_routine(
670
 
                                        field,
671
 
                                        assoc->grp_wall,
672
 
                                        (curr_inx == field_count));
673
 
                                break;
674
727
                        case PRINT_MAXCM:
675
728
                                field->print_routine(
676
729
                                        field,
703
756
                                        assoc->max_wall_pj,
704
757
                                        (curr_inx == field_count));
705
758
                                break;
 
759
                                
 
760
                        case PRINT_NODECNT:
 
761
                        {
 
762
                                hostlist_t hl = hostlist_create(cluster->nodes);
 
763
                                int cnt = 0;
 
764
                                if(hl) {
 
765
                                        cnt = hostlist_count(hl);
 
766
                                        hostlist_destroy(hl);
 
767
                                }
 
768
                                field->print_routine(
 
769
                                        field,
 
770
                                        cnt,
 
771
                                        (curr_inx == field_count));
 
772
                                break;
 
773
                        }                               
 
774
                        case PRINT_NODES:
 
775
                                field->print_routine(
 
776
                                        field,
 
777
                                        cluster->nodes,
 
778
                                        (curr_inx == field_count));
 
779
                                break;
 
780
                                
706
781
                        case PRINT_QOS:
707
782
                                if(!qos_list) 
708
783
                                        qos_list = acct_storage_g_get_qos(
756
831
                xmalloc(sizeof(acct_association_cond_t));
757
832
        int cond_set = 0, rec_set = 0, set = 0;
758
833
        List ret_list = NULL;
759
 
 
 
834
        uint16_t class_cond = 0, class_rec = 0;
760
835
 
761
836
        init_acct_association_rec(assoc);
762
837
 
768
843
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
769
844
                        i++;
770
845
                        if(_set_cond(&i, argc, argv,
771
 
                                     assoc_cond->cluster_list, NULL))
 
846
                                     assoc_cond->cluster_list,
 
847
                                     NULL, &class_cond))
772
848
                                cond_set = 1;
773
849
                } else if (!strncasecmp (argv[i], "Set", MAX(command_len, 3))) {
774
850
                        i++;
775
 
                        if(_set_rec(&i, argc, argv, NULL, assoc))
 
851
                        if(_set_rec(&i, argc, argv, NULL, assoc, &class_rec))
776
852
                                rec_set = 1;
777
853
                } else {
778
854
                        if(_set_cond(&i, argc, argv,
779
 
                                     assoc_cond->cluster_list, NULL))
 
855
                                     assoc_cond->cluster_list,
 
856
                                     NULL, &class_cond))
780
857
                                cond_set = 1;
781
858
                }
782
859
        }
800
877
                destroy_acct_association_cond(assoc_cond);
801
878
                return SLURM_ERROR;             
802
879
        }
 
880
        
 
881
        if(class_cond) {
 
882
                List temp_list = NULL;
 
883
                acct_cluster_cond_t cluster_cond;
803
884
 
 
885
                memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
 
886
                cluster_cond.cluster_list = assoc_cond->cluster_list;
 
887
                cluster_cond.classification = class_cond;
 
888
                
 
889
                temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
 
890
                                                        &cluster_cond);
 
891
                if(!temp_list) {
 
892
                        exit_code=1;
 
893
                        fprintf(stderr,
 
894
                                " Problem getting clusters from database.  "
 
895
                                "Contact your admin.\n");
 
896
                        destroy_acct_association_rec(assoc);
 
897
                        destroy_acct_association_cond(assoc_cond);
 
898
                        return SLURM_ERROR;
 
899
                } else if(!list_count(temp_list)) {
 
900
                        fprintf(stderr,
 
901
                                " The class you gave %s didn't "
 
902
                                "return any clusters.\n", 
 
903
                                get_classification_str(class_cond));
 
904
                        destroy_acct_association_rec(assoc);
 
905
                        destroy_acct_association_cond(assoc_cond);
 
906
                        list_destroy(temp_list);
 
907
                        return SLURM_ERROR;
 
908
                }
 
909
                /* we are only looking for the clusters returned from
 
910
                   this query, so we free the cluster_list and replace
 
911
                   it */
 
912
                if(assoc_cond->cluster_list)
 
913
                        list_destroy(assoc_cond->cluster_list);
 
914
                assoc_cond->cluster_list = temp_list;
 
915
        }
 
916
        
804
917
        printf(" Setting\n");
805
918
        if(rec_set) {
806
919
                printf(" Default Limits =\n");
807
920
                sacctmgr_print_assoc_limits(assoc);
 
921
                if(class_rec) 
 
922
                        printf(" Cluster Classification = %s\n", 
 
923
                               get_classification_str(class_rec));
808
924
        }
809
925
 
810
926
        list_append(assoc_cond->acct_list, "root");
831
947
 
832
948
        if(ret_list)
833
949
                list_destroy(ret_list);
 
950
 
 
951
        if(class_rec) {
 
952
                acct_cluster_cond_t cluster_cond;
 
953
                acct_cluster_rec_t cluster_rec;
 
954
                
 
955
                memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
 
956
                memset(&cluster_rec, 0, sizeof(acct_cluster_rec_t));
 
957
                /* the class has already returned these clusters so
 
958
                   just go with it */
 
959
                cluster_cond.cluster_list = assoc_cond->cluster_list;
 
960
 
 
961
                cluster_rec.classification = class_rec;
 
962
 
 
963
                ret_list = acct_storage_g_modify_clusters(
 
964
                        db_conn, my_uid, &cluster_cond, &cluster_rec);
 
965
        
 
966
                if(ret_list && list_count(ret_list)) {
 
967
                        char *object = NULL;
 
968
                        ListIterator itr = list_iterator_create(ret_list);
 
969
                        printf(" Modified cluster classifications...\n");
 
970
                        while((object = list_next(itr))) {
 
971
                                printf("  %s\n", object);
 
972
                        }
 
973
                        list_iterator_destroy(itr);
 
974
                        set = 1;
 
975
                } else if(ret_list) {
 
976
                        printf(" Nothing modified\n");
 
977
                } else {
 
978
                        exit_code=1;
 
979
                        fprintf(stderr, " Error with request\n");
 
980
                        rc = SLURM_ERROR;
 
981
                }
 
982
                
 
983
                if(ret_list)
 
984
                        list_destroy(ret_list);
 
985
        }
 
986
 
834
987
        notice_thread_fini();
835
988
 
836
989
        if(set) {
854
1007
                xmalloc(sizeof(acct_cluster_cond_t));
855
1008
        int i=0;
856
1009
        List ret_list = NULL;
 
1010
        int cond_set = 0;
857
1011
 
858
1012
        cluster_cond->cluster_list = list_create(slurm_destroy_char);
859
1013
        
860
 
        if(!_set_cond(&i, argc, argv, cluster_cond->cluster_list, NULL)) {
 
1014
        for (i=0; i<argc; i++) {
 
1015
                int command_len = strlen(argv[i]);
 
1016
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
 
1017
                    || !strncasecmp (argv[i], "Set", MAX(command_len, 3))) 
 
1018
                        i++;
 
1019
                cond_set += _set_cond(&i, argc, argv,
 
1020
                                      cluster_cond->cluster_list, 
 
1021
                                      NULL,
 
1022
                                      &cluster_cond->classification);
 
1023
        }
 
1024
 
 
1025
        if(exit_code) {
 
1026
                destroy_acct_cluster_cond(cluster_cond);
 
1027
                return SLURM_ERROR;
 
1028
        } else if(!cond_set) {
861
1029
                exit_code=1;
862
1030
                fprintf(stderr, 
863
1031
                        " No conditions given to remove, not executing.\n");
865
1033
                return SLURM_ERROR;
866
1034
        }
867
1035
 
868
 
        if(!list_count(cluster_cond->cluster_list)) {
 
1036
        if(!list_count(cluster_cond->cluster_list) 
 
1037
           && !cluster_cond->classification) {
 
1038
                exit_code=1;
 
1039
                fprintf(stderr, 
 
1040
                        "problem with delete request.  "
 
1041
                        "Nothing given to delete.\n");
869
1042
                destroy_acct_cluster_cond(cluster_cond);
870
1043
                return SLURM_SUCCESS;
871
1044
        }
921
1094
        char *line = NULL;
922
1095
        int i, command_len = 0;
923
1096
        FILE *fd = NULL;
 
1097
        char *class_str = NULL;
924
1098
 
925
1099
        for (i=0; i<argc; i++) {
926
1100
                int end = parse_option_end(argv[i]);
965
1139
                exit_code=1;
966
1140
                fprintf(stderr, " We need a cluster to dump.\n");
967
1141
                return SLURM_ERROR;
 
1142
        } else {
 
1143
                List temp_list = NULL;
 
1144
                acct_cluster_cond_t cluster_cond;
 
1145
                acct_cluster_rec_t *cluster_rec = NULL;
 
1146
 
 
1147
                memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
 
1148
                cluster_cond.cluster_list = list_create(NULL);
 
1149
                list_push(cluster_cond.cluster_list, cluster_name);
 
1150
 
 
1151
                temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
 
1152
                                                        &cluster_cond);
 
1153
                list_destroy(cluster_cond.cluster_list);
 
1154
                if(!temp_list) {
 
1155
                        exit_code=1;
 
1156
                        fprintf(stderr,
 
1157
                                " Problem getting clusters from database.  "
 
1158
                                "Contact your admin.\n");
 
1159
                        xfree(cluster_name);
 
1160
                        return SLURM_ERROR;
 
1161
                }
 
1162
 
 
1163
                cluster_rec = list_peek(temp_list);
 
1164
                if(!cluster_rec) {
 
1165
                        exit_code=1;
 
1166
                        fprintf(stderr, " Cluster %s doesn't exist.\n",
 
1167
                                cluster_name);
 
1168
                        xfree(cluster_name);
 
1169
                        list_destroy(temp_list);
 
1170
                        return SLURM_ERROR;
 
1171
                }
 
1172
                class_str = get_classification_str(cluster_rec->classification);
 
1173
                list_destroy(temp_list);
968
1174
        }
969
1175
 
970
1176
        if(!file_name) {
991
1197
                exit_code=1;
992
1198
                fprintf(stderr, " Your uid (%u) is not in the "
993
1199
                        "accounting system, can't dump cluster.\n", my_uid);
 
1200
                xfree(cluster_name);
994
1201
                xfree(user_name);
995
1202
                if(user_list)
996
1203
                        list_destroy(user_list);
1003
1210
                        exit_code=1;
1004
1211
                        fprintf(stderr, " Your user does not have sufficient "
1005
1212
                                "privileges to dump clusters.\n");
 
1213
                        xfree(cluster_name);
1006
1214
                        if(user_list)
1007
1215
                                list_destroy(user_list);
1008
1216
                        xfree(user_name);
1064
1272
                   "MaxWallDurationPerJob=1\n") < 0) {
1065
1273
                exit_code=1;
1066
1274
                fprintf(stderr, "Can't write to file");
 
1275
                xfree(cluster_name);
1067
1276
                return SLURM_ERROR;
1068
1277
        }
1069
1278
 
1070
1279
        line = xstrdup_printf("Cluster - %s", cluster_name);
1071
1280
 
 
1281
        if(class_str) 
 
1282
                xstrfmtcat(line, ":Classification=%s", class_str);
 
1283
 
1072
1284
        acct_hierarchical_rec = list_peek(acct_hierarchical_rec_list);
1073
1285
        assoc = acct_hierarchical_rec->assoc;
1074
1286
        if(strcmp(assoc->acct, "root"))