~ubuntu-branches/ubuntu/saucy/slurm-llnl/saucy

« back to all changes in this revision

Viewing changes to src/sacctmgr/cluster_functions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2008-12-03 11:56:28 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20081203115628-93t417da6wkazmo5
Tags: 1.3.11-1
New upstream release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        int i;
48
48
        int set = 0;
49
49
        int end = 0;
 
50
        int command_len = 0;
 
51
        int option = 0;
50
52
 
51
53
        for (i=(*start); i<argc; i++) {
52
54
                end = parse_option_end(argv[i]);
53
 
                if (!strncasecmp (argv[i], "Set", 3)) {
 
55
                if(!end)
 
56
                        command_len=strlen(argv[i]);
 
57
                else {
 
58
                        command_len=end-1;
 
59
                        if(argv[i][end] == '=') {
 
60
                                option = (int)argv[i][end-1];
 
61
                                end++;
 
62
                        }
 
63
                }
 
64
 
 
65
                if (!strncasecmp (argv[i], "Set", MAX(command_len, 3))) {
54
66
                        i--;
55
67
                        break;
56
 
                } else if(!end && !strncasecmp(argv[i], "where", 5)) {
 
68
                } else if(!end && !strncasecmp(argv[i], "where",
 
69
                                               MAX(command_len, 5))) {
57
70
                        continue;
58
 
                } else if(!end || !strncasecmp (argv[i], "Names", 1)
59
 
                          || !strncasecmp (argv[i], "Clusters", 1)) {
 
71
                } else if(!end || !strncasecmp (argv[i], "Names",
 
72
                                                MAX(command_len, 1))
 
73
                          || !strncasecmp (argv[i], "Clusters",
 
74
                                           MAX(command_len, 1))) {
60
75
                        if(cluster_list) {
61
76
                                if(slurm_addto_char_list(cluster_list,
62
77
                                                         argv[i]+end))
63
78
                                        set = 1;
64
79
                        }
65
 
                } else if (!strncasecmp (argv[i], "Format", 1)) {
 
80
                } else if (!strncasecmp (argv[i], "Format",
 
81
                                         MAX(command_len, 1))) {
66
82
                        if(format_list)
67
83
                                slurm_addto_char_list(format_list, argv[i]+end);
68
84
                } else {
85
101
        int set = 0;
86
102
        int end = 0;
87
103
        List qos_list = NULL;
 
104
        int command_len = 0;
 
105
        int option = 0;
88
106
 
89
107
        for (i=(*start); i<argc; i++) {
90
108
                end = parse_option_end(argv[i]);
91
 
                if (!strncasecmp (argv[i], "Where", 5)) {
 
109
                if(!end)
 
110
                        command_len=strlen(argv[i]);
 
111
                else {
 
112
                        command_len=end-1;
 
113
                        if(argv[i][end] == '=') {
 
114
                                option = (int)argv[i][end-1];
 
115
                                end++;
 
116
                        }
 
117
                }
 
118
                
 
119
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
92
120
                        i--;
93
121
                        break;
94
 
                } else if(!end && !strncasecmp(argv[i], "set", 3)) {
 
122
                } else if(!end && !strncasecmp(argv[i], "set", 
 
123
                                               MAX(command_len, 3))) {
95
124
                        continue;
96
125
                } else if(!end
97
 
                          || !strncasecmp (argv[i], "Names", 1) 
98
 
                          || !strncasecmp (argv[i], "Clusters", 1)) {
 
126
                          || !strncasecmp (argv[i], "Names",
 
127
                                           MAX(command_len, 1)) 
 
128
                          || !strncasecmp (argv[i], "Clusters", 
 
129
                                           MAX(command_len, 1))) {
99
130
                        if(name_list)
100
131
                                slurm_addto_char_list(name_list, argv[i]+end);
101
 
                } else if (!strncasecmp (argv[i], "FairShare", 1)) {
 
132
                } else if (!strncasecmp (argv[i], "FairShare", 
 
133
                                         MAX(command_len, 1))) {
102
134
                        if (get_uint(argv[i]+end, &assoc->fairshare, 
103
135
                            "FairShare") == SLURM_SUCCESS)
104
136
                                set = 1;
105
 
                } else if (!strncasecmp (argv[i], "GrpCPUMins", 7)) {
 
137
                } else if (!strncasecmp (argv[i], "GrpCPUMins",
 
138
                                         MAX(command_len, 7))) {
106
139
                        if (get_uint64(argv[i]+end, 
107
140
                                       &assoc->grp_cpu_mins, 
108
141
                                       "GrpCPUMins") == SLURM_SUCCESS)
109
142
                                set = 1;
110
 
                } else if (!strncasecmp (argv[i], "GrpCpus", 7)) {
 
143
                } else if (!strncasecmp (argv[i], "GrpCpus",
 
144
                                         MAX(command_len, 7))) {
111
145
                        if (get_uint(argv[i]+end, &assoc->grp_cpus,
112
146
                            "GrpCpus") == SLURM_SUCCESS)
113
147
                                set = 1;
114
 
                } else if (!strncasecmp (argv[i], "GrpJobs", 4)) {
 
148
                } else if (!strncasecmp (argv[i], "GrpJobs", 
 
149
                                         MAX(command_len, 4))) {
115
150
                        if (get_uint(argv[i]+end, &assoc->grp_jobs,
116
151
                            "GrpJobs") == SLURM_SUCCESS)
117
152
                                set = 1;
118
 
                } else if (!strncasecmp (argv[i], "GrpNodes", 4)) {
 
153
                } else if (!strncasecmp (argv[i], "GrpNodes",
 
154
                                         MAX(command_len, 4))) {
119
155
                        if (get_uint(argv[i]+end, &assoc->grp_nodes,
120
156
                            "GrpNodes") == SLURM_SUCCESS)
121
157
                                set = 1;
122
 
                } else if (!strncasecmp (argv[i], "GrpSubmitJobs", 4)) {
 
158
                } else if (!strncasecmp (argv[i], "GrpSubmitJobs",
 
159
                                         MAX(command_len, 4))) {
123
160
                        if (get_uint(argv[i]+end, &assoc->grp_submit_jobs,
124
161
                            "GrpSubmitJobs") == SLURM_SUCCESS)
125
162
                                set = 1;
126
 
                } else if (!strncasecmp (argv[i], "GrpWall", 4)) {
 
163
                } else if (!strncasecmp (argv[i], "GrpWall",
 
164
                                         MAX(command_len, 4))) {
127
165
                        mins = time_str2mins(argv[i]+end);
128
166
                        if (mins != NO_VAL) {
129
167
                                assoc->grp_wall = (uint32_t) mins;
134
172
                                        " Bad GrpWall time format: %s\n", 
135
173
                                        argv[i]);
136
174
                        }
137
 
                } else if (!strncasecmp (argv[i], "MaxCPUMins", 7)) {
 
175
                } else if (!strncasecmp (argv[i], "MaxCPUMins",
 
176
                                         MAX(command_len, 7))) {
138
177
                        if (get_uint64(argv[i]+end, 
139
178
                                       &assoc->max_cpu_mins_pj, 
140
179
                                       "MaxCPUMins") == SLURM_SUCCESS)
141
180
                                set = 1;
142
 
                } else if (!strncasecmp (argv[i], "MaxCpus", 7)) {
 
181
                } else if (!strncasecmp (argv[i], "MaxCpus", 
 
182
                                         MAX(command_len, 7))) {
143
183
                        if (get_uint(argv[i]+end, &assoc->max_cpus_pj,
144
184
                            "MaxCpus") == SLURM_SUCCESS)
145
185
                                set = 1;
146
 
                } else if (!strncasecmp (argv[i], "MaxJobs", 4)) {
 
186
                } else if (!strncasecmp (argv[i], "MaxJobs",
 
187
                                         MAX(command_len, 4))) {
147
188
                        if (get_uint(argv[i]+end, &assoc->max_jobs,
148
189
                            "MaxJobs") == SLURM_SUCCESS)
149
190
                                set = 1;
150
 
                } else if (!strncasecmp (argv[i], "MaxNodes", 4)) {
 
191
                } else if (!strncasecmp (argv[i], "MaxNodes",
 
192
                                         MAX(command_len, 4))) {
151
193
                        if (get_uint(argv[i]+end, 
152
194
                            &assoc->max_nodes_pj,
153
195
                            "MaxNodes") == SLURM_SUCCESS)
154
196
                                set = 1;
155
 
                } else if (!strncasecmp (argv[i], "MaxSubmitJobs", 4)) {
 
197
                } else if (!strncasecmp (argv[i], "MaxSubmitJobs",
 
198
                                         MAX(command_len, 4))) {
156
199
                        if (get_uint(argv[i]+end, &assoc->max_submit_jobs,
157
200
                            "MaxSubmitJobs") == SLURM_SUCCESS)
158
201
                                set = 1;
159
 
                } else if (!strncasecmp (argv[i], "MaxWall", 4)) {
 
202
                } else if (!strncasecmp (argv[i], "MaxWall", 
 
203
                                         MAX(command_len, 4))) {
160
204
                        mins = time_str2mins(argv[i]+end);
161
205
                        if (mins != NO_VAL) {
162
206
                                assoc->max_wall_pj = (uint32_t) mins;
167
211
                                        " Bad MaxWall time format: %s\n", 
168
212
                                        argv[i]);
169
213
                        }
170
 
                } else if (!strncasecmp (argv[i], "QosLevel", 1)) {
171
 
                        int option = 0;
 
214
                } else if (!strncasecmp (argv[i], "QosLevel", 
 
215
                                         MAX(command_len, 1))) {
172
216
                        if(!assoc->qos_list) 
173
217
                                assoc->qos_list = 
174
218
                                        list_create(slurm_destroy_char);
177
221
                                qos_list = acct_storage_g_get_qos(
178
222
                                        db_conn, my_uid, NULL);
179
223
                                                
180
 
                        if(end > 2 && argv[i][end-1] == '='
181
 
                           && (argv[i][end-2] == '+' 
182
 
                               || argv[i][end-2] == '-'))
183
 
                                option = (int)argv[i][end-2];
184
 
 
185
224
                        if(addto_qos_char_list(assoc->qos_list,
186
225
                                               qos_list, argv[i]+end, option))
187
226
                                set = 1;
404
443
        itr = list_iterator_create(format_list);
405
444
        while((object = list_next(itr))) {
406
445
                char *tmp_char = NULL;
 
446
                int command_len = strlen(object);
 
447
 
407
448
                field = xmalloc(sizeof(print_field_t));
408
 
                if(!strncasecmp("Cluster", object, 2)
409
 
                   || !strncasecmp("Name", object, 2)) {
 
449
                if(!strncasecmp("Cluster", object, MAX(command_len, 2))
 
450
                   || !strncasecmp("Name", object, MAX(command_len, 2))) {
410
451
                        field->type = PRINT_CLUSTER;
411
452
                        field->name = xstrdup("Cluster");
412
453
                        field->len = 10;
413
454
                        field->print_routine = print_fields_str;
414
 
                } else if(!strncasecmp("ControlHost", object, 8)) {
 
455
                } else if(!strncasecmp("ControlHost", object,
 
456
                                       MAX(command_len, 8))) {
415
457
                        field->type = PRINT_CHOST;
416
458
                        field->name = xstrdup("Control Host");
417
459
                        field->len = 12;
418
460
                        field->print_routine = print_fields_str;
419
 
                } else if(!strncasecmp("ControlPort", object, 8)) {
 
461
                } else if(!strncasecmp("ControlPort", object,
 
462
                                       MAX(command_len, 8))) {
420
463
                        field->type = PRINT_CPORT;
421
464
                        field->name = xstrdup("Control Port");
422
465
                        field->len = 12;
423
466
                        field->print_routine = print_fields_uint;
424
 
                } else if(!strncasecmp("FairShare", object, 1)) {
 
467
                } else if(!strncasecmp("FairShare", object, 
 
468
                                       MAX(command_len, 1))) {
425
469
                        field->type = PRINT_FAIRSHARE;
426
470
                        field->name = xstrdup("FairShare");
427
471
                        field->len = 9;
428
472
                        field->print_routine = print_fields_uint;
429
 
                } else if(!strncasecmp("GrpCPUMins", object, 8)) {
 
473
                } else if(!strncasecmp("GrpCPUMins", object, 
 
474
                                       MAX(command_len, 8))) {
430
475
                        field->type = PRINT_GRPCM;
431
476
                        field->name = xstrdup("GrpCPUMins");
432
477
                        field->len = 11;
433
478
                        field->print_routine = print_fields_uint64;
434
 
                } else if(!strncasecmp("GrpCPUs", object, 8)) {
 
479
                } else if(!strncasecmp("GrpCPUs", object, 
 
480
                                       MAX(command_len, 8))) {
435
481
                        field->type = PRINT_GRPC;
436
482
                        field->name = xstrdup("GrpCPUs");
437
483
                        field->len = 8;
438
484
                        field->print_routine = print_fields_uint;
439
 
                } else if(!strncasecmp("GrpJobs", object, 4)) {
 
485
                } else if(!strncasecmp("GrpJobs", object,
 
486
                                       MAX(command_len, 4))) {
440
487
                        field->type = PRINT_GRPJ;
441
488
                        field->name = xstrdup("GrpJobs");
442
489
                        field->len = 7;
443
490
                        field->print_routine = print_fields_uint;
444
 
                } else if(!strncasecmp("GrpNodes", object, 4)) {
 
491
                } else if(!strncasecmp("GrpNodes", object,
 
492
                                       MAX(command_len, 4))) {
445
493
                        field->type = PRINT_GRPN;
446
494
                        field->name = xstrdup("GrpNodes");
447
495
                        field->len = 8;
448
496
                        field->print_routine = print_fields_uint;
449
 
                } else if(!strncasecmp("GrpSubmitJobs", object, 4)) {
 
497
                } else if(!strncasecmp("GrpSubmitJobs", object,
 
498
                                       MAX(command_len, 4))) {
450
499
                        field->type = PRINT_GRPS;
451
500
                        field->name = xstrdup("GrpSubmit");
452
501
                        field->len = 9;
453
502
                        field->print_routine = print_fields_uint;
454
 
                } else if(!strncasecmp("GrpWall", object, 4)) {
 
503
                } else if(!strncasecmp("GrpWall", object,
 
504
                                       MAX(command_len, 4))) {
455
505
                        field->type = PRINT_GRPW;
456
506
                        field->name = xstrdup("GrpWall");
457
507
                        field->len = 11;
458
508
                        field->print_routine = print_fields_time;
459
 
                } else if(!strncasecmp("MaxCPUMins", object, 7)) {
 
509
                } else if(!strncasecmp("MaxCPUMins", object,
 
510
                                       MAX(command_len, 7))) {
460
511
                        field->type = PRINT_MAXCM;
461
512
                        field->name = xstrdup("MaxCPUMins");
462
513
                        field->len = 11;
463
514
                        field->print_routine = print_fields_uint64;
464
 
                } else if(!strncasecmp("MaxCPUs", object, 7)) {
 
515
                } else if(!strncasecmp("MaxCPUs", object,
 
516
                                       MAX(command_len, 7))) {
465
517
                        field->type = PRINT_MAXC;
466
518
                        field->name = xstrdup("MaxCPUs");
467
519
                        field->len = 8;
468
520
                        field->print_routine = print_fields_uint;
469
 
                } else if(!strncasecmp("MaxJobs", object, 4)) {
 
521
                } else if(!strncasecmp("MaxJobs", object,
 
522
                                       MAX(command_len, 4))) {
470
523
                        field->type = PRINT_MAXJ;
471
524
                        field->name = xstrdup("MaxJobs");
472
525
                        field->len = 7;
473
526
                        field->print_routine = print_fields_uint;
474
 
                } else if(!strncasecmp("MaxNodes", object, 4)) {
 
527
                } else if(!strncasecmp("MaxNodes", object, 
 
528
                                       MAX(command_len, 4))) {
475
529
                        field->type = PRINT_MAXN;
476
530
                        field->name = xstrdup("MaxNodes");
477
531
                        field->len = 8;
478
532
                        field->print_routine = print_fields_uint;
479
 
                } else if(!strncasecmp("MaxSubmitJobs", object, 4)) {
 
533
                } else if(!strncasecmp("MaxSubmitJobs", object,
 
534
                                       MAX(command_len, 4))) {
480
535
                        field->type = PRINT_MAXS;
481
536
                        field->name = xstrdup("MaxSubmit");
482
537
                        field->len = 9;
483
538
                        field->print_routine = print_fields_uint;
484
 
                } else if(!strncasecmp("MaxWall", object, 4)) {
 
539
                } else if(!strncasecmp("MaxWall", object, 
 
540
                                       MAX(command_len, 4))) {
485
541
                        field->type = PRINT_MAXW;
486
542
                        field->name = xstrdup("MaxWall");
487
543
                        field->len = 11;
488
544
                        field->print_routine = print_fields_time;
489
 
                } else if(!strncasecmp("QOSRAW", object, 4)) {
 
545
                } else if(!strncasecmp("QOSRAWLevel", object, 
 
546
                                       MAX(command_len, 4))) {
490
547
                        field->type = PRINT_QOS_RAW;
491
548
                        field->name = xstrdup("QOS_RAW");
492
549
                        field->len = 10;
493
550
                        field->print_routine = print_fields_char_list;
494
 
                } else if(!strncasecmp("QOS", object, 1)) {
 
551
                } else if(!strncasecmp("QOSLevel", object,
 
552
                                       MAX(command_len, 1))) {
495
553
                        field->type = PRINT_QOS;
496
554
                        field->name = xstrdup("QOS");
497
555
                        field->len = 20;
498
556
                        field->print_routine = sacctmgr_print_qos_list;
499
 
                } else if(!strncasecmp("RPC", object, 1)) {
 
557
                } else if(!strncasecmp("RPC", object, MAX(command_len, 1))) {
500
558
                        field->type = PRINT_RPC_VERSION;
501
559
                        field->name = xstrdup("RPC");
502
560
                        field->len = 3;
691
749
        assoc_cond->acct_list = list_create(NULL);
692
750
 
693
751
        for (i=0; i<argc; i++) {
694
 
                if (!strncasecmp (argv[i], "Where", 5)) {
 
752
                int command_len = strlen(argv[i]);
 
753
                if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
695
754
                        i++;
696
755
                        if(_set_cond(&i, argc, argv,
697
756
                                     assoc_cond->cluster_list, NULL))
698
757
                                cond_set = 1;
699
 
                } else if (!strncasecmp (argv[i], "Set", 3)) {
 
758
                } else if (!strncasecmp (argv[i], "Set", MAX(command_len, 3))) {
700
759
                        i++;
701
760
                        if(_set_rec(&i, argc, argv, NULL, assoc))
702
761
                                rec_set = 1;
845
904
        char *file_name = NULL;
846
905
        char *user_name = NULL;
847
906
        char *line = NULL;
848
 
        int i;
 
907
        int i, command_len = 0;
849
908
        FILE *fd = NULL;
850
909
 
851
910
        memset(&user_cond, 0, sizeof(acct_user_cond_t));
879
938
 
880
939
        for (i=0; i<argc; i++) {
881
940
                int end = parse_option_end(argv[i]);
882
 
                if(!end || !strncasecmp (argv[i], "Cluster", 1)) {
 
941
                int option = 0;
 
942
 
 
943
                if(!end)
 
944
                        command_len=strlen(argv[i]);
 
945
                else {
 
946
                        command_len=end-1;
 
947
                        if(argv[i][end] == '=') {
 
948
                                option = (int)argv[i][end-1];
 
949
                                end++;
 
950
                        }
 
951
                }
 
952
                if(!end || !strncasecmp (argv[i], "Cluster",
 
953
                                         MAX(command_len, 1))) {
883
954
                        if(cluster_name) {
884
955
                                exit_code=1;
885
956
                                fprintf(stderr, 
888
959
                                continue;
889
960
                        }
890
961
                        cluster_name = xstrdup(argv[i]+end);
891
 
                } else if (!strncasecmp (argv[i], "File", 1)) {
 
962
                } else if (!strncasecmp (argv[i], "File",
 
963
                                         MAX(command_len, 1))) {
892
964
                        if(file_name) {
893
965
                                exit_code=1;
894
966
                                fprintf(stderr,