-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathEC-Admin_for_EC_4.0.xml
More file actions
4369 lines (4369 loc) · 305 KB
/
Copy pathEC-Admin_for_EC_4.0.xml
File metadata and controls
4369 lines (4369 loc) · 305 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<exportedData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="commander.xsd" version="54" buildLabel="build_4.0_50702_OPT_2012.05.16_13:51:27" buildVersion="4.0.2.50702" passkey="2468db457282d61c50085d36a5b66d570f7f6617">
<exportPath>/projects/EC-Admin</exportPath>
<project>
<projectName>EC-Admin</projectName>
<description>A set of tools to help with the administration of a Commander Server.</description>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_savedSearches</propertyName>
<propertySheet>
<property>
<propertyName>last500PerformanceMetricsJobs</propertyName>
<description></description>
<propertySheet>
<property>
<propertyName>displayFilter1</propertyName>
<propertySheet>
<property>
<propertyName>filterName</propertyName>
<expandable>1</expandable>
<value>procedureName</value>
</property>
<property>
<propertyName>operand1</propertyName>
<expandable>1</expandable>
<value>performanceMetrics</value>
</property>
<property>
<propertyName>operator</propertyName>
<expandable>1</expandable>
<value>equals</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>filter1</propertyName>
<propertySheet>
<property>
<propertyName>filterName</propertyName>
<expandable>1</expandable>
<value>procedureName</value>
</property>
<property>
<propertyName>operand1</propertyName>
<expandable>1</expandable>
<value>performanceMetrics</value>
</property>
<property>
<propertyName>operator</propertyName>
<expandable>1</expandable>
<value>equals</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>sort1</propertyName>
<propertySheet>
<property>
<propertyName>order</propertyName>
<expandable>1</expandable>
<value>descending</value>
</property>
<property>
<propertyName>sortName</propertyName>
<expandable>1</expandable>
<value>createTime</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>filterName</propertyName>
<expandable>1</expandable>
<value>jobSearch</value>
</property>
<property>
<propertyName>filter_count</propertyName>
<expandable>1</expandable>
<value>1</value>
</property>
<property>
<propertyName>maxIds</propertyName>
<expandable>1</expandable>
<value>500</value>
</property>
<property>
<propertyName>maxResults</propertyName>
<expandable>1</expandable>
<value>20</value>
</property>
<property>
<propertyName>objectType</propertyName>
<expandable>1</expandable>
<value>job</value>
</property>
<property>
<propertyName>projectionCount</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
<property>
<propertyName>relatedToCount</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
<property>
<propertyName>resultsPage</propertyName>
<expandable>1</expandable>
<value>searchResults.php</value>
</property>
<property>
<propertyName>sortCount</propertyName>
<expandable>1</expandable>
<value>1</value>
</property>
<property>
<propertyName>textSearchCount</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
<property>
<propertyName>performances</propertyName>
<description>A property sheet for performance diagnostic</description>
<propertySheet>
<property>
<propertyName>CORE</propertyName>
<description>Tests for number of cores</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 4</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>> 6</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value><=6</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>CPU</propertyName>
<description>Tests for CPU speed</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 1.5</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>> 2</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value><= 2.0</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>DBPERF</propertyName>
<description>Test for Database Performance</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>> .10</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value><.07</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value>>= .07</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>DISKREAD</propertyName>
<description>Tests for Disk Reading Performance</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 2</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>>5</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value><=5</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>DISKWRITE</propertyName>
<description>Tests for Disk Writing Performance</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 2</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>>5</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value><=5</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>PERF</propertyName>
<description>Test for ping times to resources</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>> 10</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 5</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value>>=5</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>PING</propertyName>
<description>Test for ping times to resources</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description></description>
<expandable>1</expandable>
<value>> 2</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description></description>
<expandable>1</expandable>
<value>< 1</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description></description>
<expandable>1</expandable>
<value>>=1</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>RAM</propertyName>
<description>Test for RAM amount</description>
<propertySheet>
<property>
<propertyName>BAD</propertyName>
<description>Value below 4 GB is bad</description>
<expandable>1</expandable>
<value>< 4</value>
</property>
<property>
<propertyName>BEST</propertyName>
<description>Anything over 8GB is perfect</description>
<expandable>1</expandable>
<value>> 8</value>
</property>
<property>
<propertyName>GOOD</propertyName>
<description>RAM between 4GB and 8GB is acceptable</description>
<expandable>1</expandable>
<value><= 8</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>scripts</propertyName>
<description>perl Library</description>
<propertySheet>
<property>
<propertyName>perf.pm</propertyName>
<description>checkvalue(PERF, value): test the value against BAD, GOOD and BEST logic tests for PERF test (in /myProject/performances/PERF) </description>
<expandable>1</expandable>
<value>$[/myProject/scripts/perlHeader] $[/myProject/scripts/perlLib] sub checkValue { my $test=shift; # the test to perform my $value=shift; # the value to test my $summary=shift; # the summary to display on the job page printf("Value to test: %s\n", $value) if ($DEBUG); printf("Checking Performance for %s: ", $test); InvokeCommander("SuppressLog", "setProperty", "summary", $summary); if (eval $value . getP("/myProject/performances/$test/BAD")) { printf("BAD\n"); InvokeCommander("SuppressLog", "setProperty", "outcome", "warning"); return -1; } elsif (eval $value . getP("/myProject/performances/$test/GOOD")) { printf("GOOD\n"); return 0; } elsif(eval $value . getP("/myProject/performances/$test/BEST")) { printf("BEST\n"); return +1; } else { printf ("\nTest for %s does not resolve. Verify your values in the performances property sheet\n", $test); exit (2); } }</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
<property>
<propertyName>scripts</propertyName>
<description>A list of Perl helpers</description>
<propertySheet>
<property>
<propertyName>jobTemplate</propertyName>
<description></description>
<expandable>1</expandable>
<value>$[/myProject/projectName]-$[/myProcedure/procedureName]_$[jobId]-$[/timestamp]</value>
</property>
<property>
<propertyName>perlCommonLib</propertyName>
<description>Perl Library (format agnostic) for: - getP: a simple getPropertycall. Return undef in case of error - humanSize: return a size in human readable string - compareVersion: a function to compare artifact version strings in the form of x.y.z....</description>
<expandable>1</expandable>
<value>############################################################################# # # Compare 2 version number strings like x.y.z... section by section # return 1 if V1 > v2 # return 0 if v1 == v2 # return -1 if v1 < v2 # ############################################################################# sub compareVersion { my ($v1, $v2)=@_; my @v1Numbers = split('\.', $v1); my @v2Numbers = split('\.', $v2); for (my $index = 0; $index < scalar(@v1Numbers); $index++) { # We ran out of V2 numbers => V1 is a bigger version return 1 if (scalar(@v2Numbers) == $index); # same value, go to next number next if ($v1Numbers[$index] == $v2Numbers[$index]); # V1 is a bigger version return 1 if ($v1Numbers[$index] > $v2Numbers[$index]); ; # V2 is a bigger version return -1; } # We ran out of V1 numbers return -1 if(scalar(@v1Numbers) != scalar(@v2Numbers)); # Same number return 0; } ############################################################################# # # Return property value or undef in case of error (non existing) # ############################################################################# sub getP { my $prop=shift; my($success, $xPath, $errMsg, $errCode)= InvokeCommander("SuppressLog IgnoreError", "getProperty", $prop); return undef if ($success != 1); my $val= $xPath->findvalue("//value"); return($val); } ############################################################################# # # Return human readable size # ############################################################################# sub humanSize { my $size = shift(); if ($size > 1099511627776) { # TB: 1024 GB return sprintf("%.2f TB", $size / 1099511627776); } if ($size > 1073741824) { # GB: 1024 MB return sprintf("%.2f GB", $size / 1073741824); } if ($size > 1048576) { # MB: 1024 KB return sprintf("%.2f MB", $size / 1048576); } elsif ($size > 1024) { # KiB: 1024 B return sprintf("%.2f KB", $size / 1024); } # bytes return "$size byte" . ($size <= 1 ? "" : "s"); }</value>
</property>
<property>
<propertyName>perlHeader</propertyName>
<description>default Perl Header to use the API</description>
<expandable>1</expandable>
<value>############################################################################# # # Copyright 2013 Electric-Cloud Inc. # ############################################################################# use strict; use English; use ElectricCommander; $| = 1; my $DEBUG=0; # Create a single instance of the Perl access to ElectricCommander my $ec = new ElectricCommander(); # Check for the OS Type my $osIsWindows = $^O =~ /MSWin/; </value>
</property>
<property>
<propertyName>perlHeaderJSON</propertyName>
<description>default Perl Header to use the API with JSON format</description>
<expandable>1</expandable>
<value>############################################################################# # # Copyright 2013 Electric-Cloud Inc. # ############################################################################# use strict; use English; use ElectricCommander; use Data::Dumper; $| = 1; my $DEBUG=0; # Create a single instance of the Perl access to ElectricCommander my $ec = new ElectricCommander({'format' => "json"}); # Check for the OS Type my $osIsWindows = $^O =~ /MSWin/;</value>
</property>
<property>
<propertyName>perlLib</propertyName>
<description>Perl Libraries for: - InvokeCommander: Run an ElectricCommander function using the Perl API - getPS: return a Hash for porperties contained in a PropertySheet #------------------------------------------------------------------------- # Run an ElectricCommander function using the Perl API # # Params # optionFlags - "AllowLog" or "SuppressLog" or "SuppressResult" # combined with "IgnoreError" # commanderFunction # Variable Parameters # The parameters required by the ElectricCommander function # according to the Perl API. See the ElectricCommander # Help system for more information. # (the functions and paramenter are based on "ectool" - run it for documentation) # # Returns # success - 1 if no error was detected # xPath - an XML::XPath object with the result. # errMsg - a message string extracted from Commander on error # errCode - the code part <code> of the XML #-------------------------------------------------------------------------</description>
<expandable>1</expandable>
<value>$[/projects/EC-Admin/scripts/perlCommonLib] ############################################################################# # # Invoke a API call # ############################################################################# sub InvokeCommander { my $optionFlags = shift; my $commanderFunction = shift; my $xPath; my $success = 1; my $bSuppressLog = $optionFlags =~ /SuppressLog/i; my $bSuppressResult = $bSuppressLog || $optionFlags =~ /SuppressResult/i; my $bIgnoreError = $optionFlags =~ /IgnoreError/i; # Run the command # print "Request to Commander: $commanderFunction\n" unless ($bSuppressLog); $ec->abortOnError(0) if $bIgnoreError; $xPath = $ec->$commanderFunction(@_); $ec->abortOnError(1) if $bIgnoreError; # Check for error return my $errMsg = $ec->checkAllErrors($xPath); my $errCode=$xPath->findvalue('//code',)->value(); if ($errMsg ne "") { $success = 0; } if ($xPath) { print "Return data from Commander:\n" . $xPath->findnodes_as_string("/") . "\n" unless $bSuppressResult; } # Return the result return ($success, $xPath, $errMsg, $errCode); } ############################################################################# # # Return a hash of the properties contained in a Property Sheet. # Args: # 1. Property Sheet path # 2. Recursive boolean ############################################################################# sub getPS { my $psPath=shift; my $recursive=shift; my $hashRef=undef; my($success, $result, $errMsg, $errCode)=InvokeCommander("SuppressLog IgnoreError", "getProperties", {'path'=>$psPath}); return $hashRef if (!$success); my $nodeset=$result->find('//property'); foreach my $node ($nodeset->get_nodelist) { my $propName=$result->findvalue('propertyName', $node); my $value =$result->findvalue('value', $node); my $psId =$result->findvalue('propertySheetId', $node); # this is not a nested PS if ($psId eq '') { $hashRef->{$propName}=$value; } else { # nested PropertySheet if ($recursive) { $hashRef->{$propName}=getPS("$psPath/$propName"); } else { $hashRef->{$propName}=undef; } } } return $hashRef; }</value>
</property>
<property>
<propertyName>perlLibJSON</propertyName>
<description>Perl Libraries (JSON Format) for: - InvokeCommander: Run an ElectricCommander function using the Perl API - getPS: return a Hash for porperties contained in a PropertySheet #------------------------------------------------------------------------- # Run an ElectricCommander function using the Perl API # # Params # optionFlags - "AllowLog" or "SuppressLog" or "SuppressResult" # combined with "IgnoreError" # commanderFunction # Variable Parameters # The parameters required by the ElectricCommander function # according to the Perl API. See the ElectricCommander # Help system for more information. # (the functions and paramenter are based on "ectool" - run it for documentation) # # Returns # success - 1 if no error was detected # xPath - an XML::XPath object with the result. # errMsg - a message string extracted from Commander on error # errCode - the code part <code> of the XML #-------------------------------------------------------------------------</description>
<expandable>1</expandable>
<value>$[/projects/EC-Admin/scripts/perlCommonLib] ############################################################################# # # Invoke a API call # ############################################################################# sub InvokeCommander { my $optionFlags = shift; my $commanderFunction = shift; my $result; my $success = 1; my $errMsg; my $errCode; my $bSuppressLog = $optionFlags =~ /SuppressLog/i; my $bSuppressResult = $bSuppressLog || $optionFlags =~ /SuppressResult/i; my $bIgnoreError = $optionFlags =~ /IgnoreError/i; # Run the command # print "Request to Commander: $commanderFunction\n" unless ($bSuppressLog); $ec->abortOnError(0) if $bIgnoreError; $result = $ec->$commanderFunction(@_); $ec->abortOnError(1) if $bIgnoreError; # Check for error return if (defined ($result->{responses}->[0]->{error})) { $errCode=$result->{responses}->[0]->{error}->{code}; $errMsg=$result->{responses}->[0]->{error}->{message}; } if ($errMsg ne "") { $success = 0; } if ($result) { print "Return data from Commander:\n" . Dumper($result) . "\n" unless $bSuppressResult; } # Return the result return ($success, $result, $errMsg, $errCode); } ############################################################################# # # Return a hash of the properties contained in a Property Sheet. # Args: # 1. Property Sheet path # 2. Recursive boolean ############################################################################# sub getPS { my $psPath=shift; my $recursive=shift; my $hashRef=undef;; my($success, $result, $errMsg, $errCode)=InvokeCommander("SuppressLog IgnoreError", "getProperties", {'path'=>$psPath}); return $hashRef if (!$success); foreach my $node ($result->findnodes('//property')) { my $propName=$node->{'propertyName'}; my $value=$node->{'value'}; if (defined ($value)) { $hashRef->{$propName}=$node->{'value'}; } else { # nested PropertySheet if ($recursive) { $hashRef->{$propName}=getPS("$psPath/$propName"); } else { $hashRef->{$propName}=undef; } } } return $hashRef; }</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>ec_setup</propertyName>
<expandable>1</expandable>
<value># Data that drives the create step picker registration for this plugin. my %acquireSemaphore = ( label => "EC-Admin - acquireSemaphore", procedure => "acquireSemaphore", description => "Procedure to acquire a token in order to limit access to a set of procedures Changelog: -------------- 10-04-2013 lrochette Add job counter to help abort a job.", category => "Administration" ); my %artifactsCleanup = ( label => "EC-Admin - artifactsCleanup", procedure => "artifactsCleanup", description => "Delete Artifacts and clean caches. A resource matching the Repository server is required or some steps will be skipped. Changelog: -------------- 08-07-2013 lrochette Better Resource management: test for existence, alive and enabled before invoking cleanupRepository. 07-29-2013 lrochette Added ec_parameterForm to give it the same look and feel than jobCleanup Took advantage of createJobStep to simplify the procedure", category => "Administration" ); my %createPluginFromProject = ( label => "EC-Admin - createPluginFromProject", procedure => "createPluginFromProject", description => "Create a plugin from a simple project", category => "Administration" ); my %deleteObjects = ( label => "EC-Admin - deleteObjects", procedure => "deleteObjects", description => "", category => "Administration" ); my %deleteWorkspaceOrphans = ( label => "EC-Admin - deleteWorkspaceOrphans", procedure => "deleteWorkspaceOrphans", description => "Procedure to crawl a workspace directory to find orphan jobs (directories without a matching job)", category => "Administration" ); my %jobCleanup_byResult = ( label => "EC-Admin - jobCleanup_byResult", procedure => "jobCleanup_byResult", description => "Delete jobs and the associated workspace based on result: keeping X goods/warning, and Y failed Report the number of jobs, the disk space and database space that could/was be deleted.", category => "Administration" ); my %jobsCleanup = ( label => "EC-Admin - jobsCleanup", procedure => "jobsCleanup", description => "Delete jobs older than a number of days, along with the associated workspace. Report the number of jobs, the disk space and database space that could/was be deleted. Changelog: -------------- 09-20-2013 lrochette Rewritten using JSON to increase performance Paramater is also now used to skip number of steps computation 09-12-2013 lrochette Add a parameter to skip the computation of the disk space used; to speed up the job", category => "Administration" ); my %performanceMetrics = ( label => "EC-Admin - performanceMetrics", procedure => "performanceMetrics", description => "Performance diagnostics for EC server and agents Changelog: -------------- 08-09-2013 lrochette Fixed bug on Free available RAM with European numbers 08-30-2013 lrochette Added fsutil error management 08-30-2013 lrochette Added a cleanup step for the disk performance temporary file", category => "Administration" ); my %releaseSemaphore = ( label => "EC-Admin - releaseSemaphore", procedure => "releaseSemaphore", description => "Procedure to release the token Changelog: -------------- 10-04-2013 lrochette Add job counter to help abort a job.", category => "Administration" ); my %saveProjects = ( label => "EC-Admin - saveProjects", procedure => "saveProjects", description => "a framework to export projects.", category => "Administration" ); my %workflowCleanup = ( label => "EC-Admin - workflowCleanup", procedure => "workflowCleanup", description => "Delete workflows older than a number of days. Report the number of workflows.", category => "Administration" ); @::createStepPickerSteps = (\%acquireSemaphore, \%artifactsCleanup, \%createPluginFromProject, \%deleteObjects, \%deleteWorkspaceOrphans, \%jobCleanup_byResult, \%jobsCleanup, \%performanceMetrics, \%releaseSemaphore, \%saveProjects, \%workflowCleanup); </value>
</property>
<property>
<propertyName>ec_tags</propertyName>
<expandable>1</expandable>
<value> github </value>
</property>
<property>
<propertyName>ec_visibility</propertyName>
<expandable>1</expandable>
<value>pickerListOnly</value>
</property>
<property>
<propertyName>help</propertyName>
<description><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=us-ascii" http-equiv="content-type" /> <title>EC-Admin Help</title> </head> <body> <h1>EC-Admin</h1> <p>EC-Admin is a collection of administrative procedures to help you manage your server. Its inception was sparked by requests from customers during Professional Services engagement. It has grown over the years to what it is now.</p> <p>It contains the following modules:</p> <ul> <li><a href="#jobs">Jobs and Workspaces management</a></li> <li><a href="#plugin">Plugin creation</a></li> <li><a href="#artifacts">Artifacts management</a></li> <li><a href="#backup">Projects backup</a></li> <li><a href="#semapahore">Semaphore management</a></li> </ul> <h2><a name="installation"></a>Installation</h2> <p>This collection of procedures can be found on our <a href="https://github.com/electriccommunity/electriccommander/tree/master/EC-Admin">community repository on GitHub</a>. It is available either as a simple XML project export or as a plugin in the form of a . jar file.</p> <p>To install the plugin, use the "Install from File/URL" tab in the administration/Plugins or use the "installPlugin" API.</p> <p>To install the .xml project export, use the API call: <br/>ectool import /path_to/EC-Admin.xml --disableSchedules 1</p> <p>To install on 4.0.x or later, import the EC_4.0.xml file. Be aware that some features are not present as the original project makes use of createJobStep() API which was introduced in 4.2.0:<br/> ectool import /path_to/EC-Admin_for_EC_4.0.xml --disableSchedules 1</p> <p>If you get an error with the passKey, use the "--force 1" option</p> <h2><a name="plugin"></a>Plugin creation</h2> <p>The procedure "createPluginFromProject" allows to transform a project into a plugin. The parameters are the following:</p> <dl> <dt><b>Author:</b></dt> <dd>The author of the project to transform into a plugin</dd> <dt><b>Email:</b></dt> <dd>The email of the author</dd> <dt><b>Category</b>:</dt> <dd>The category of the plugin. It helps filter the plugin in the Plugins page and in the pickerList.</dd> <dt><b>Description</b>:</dt> <dd>The descrirption of the plugin do display in the main plugin page</dd> <dt><b>installPlugin</b>:</dt> <dd>A boolean to install or not the plugin after creation</dd> <dt><b>promotePlugin</b>:</dt> <dd>A boolean to promote or not the plugin after installation</dd> <dt><b>Plugin</b>:</dt> <dd>The name of the plugin</dd> <dt><b>Project</b>:</dt> <dd>The name of the project to transform into a plugin</dd> <dt><b>Version</b>:</dt> <dd>Version of the plugin to create.</dd> </dl> <p>In addition each procedure can modify the behavior with the following 2 properties:</p> <dl> <dt>exposeToPlugin</dt> <dd>This property if set to 1 will add the procedure to ec_setup to be shown in the procedure pickerList when choosing a plugin step.</dd> <dt>descriptionForPlugin</dt> <dd>This property will shown as the description in the pickerList mentioned above. If it's empty of non existent, the description will be description of the procedure itself.</dd> </dl> <dl> <dt>jobsCleanup:</dt> <dd>procedure to delete jobs older than a specified number of days. It will also delete associated workspace job directories. You can also provide a property name, if this property is attached to the job, it won't be deleted now matter how old. A report only mode prevents any real deletion.</dd> <dt>artifactsCleanup:</dt> <dd>procedure to delete artifacts older than a specified number of days. Same as above, a property allows to prevent deletion. Once the artifacts have been deleted, artifact repositories and artifact caches are cleaned as well (deleting stale artifacts). A report only mode prevents any real deletion.</dd> <dt>acquireSemaphore and releaseSemaphore:</dt> <dd> those 2 procedures are used to create a gate for a set of steps. The important part is to use a resource with a step limit of one to ensure the atomicty of increasing and decreasing the gate value.</dd> <dt>saveProjects:</dt> <dd> a simple procdure to export individually all (non plugins) projects to create you own versioning. Better to run on a nightly schedule.</dd> </dl> <h2>Contact author</h2> <p>Laurent Rochette (<a href="mailto:lrochette@electric-cloud.com">lrochette@electric-cloud.com</a>) </p> <h2>Legal Jumbo</h2> <p>This module is free for use. Modify it however you see fit to better your experience using ElectricCommander. Share your enhancements and fixes.</p> <p>This module is not officially supported by Electric Cloud. It has undergone no formal testing and you may run into issues that have not been uncovered in the limited manual testing done so far.</p> <p>Electric Cloud should not be held liable for any repercussions of using this software.</p> </body> </html></description>
<expandable>1</expandable>
<value><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=us-ascii" http-equiv="content-type" /> <title>EC-Admin Plugin</title> <style> /* pluginhelp.css - * * This file defines styles used for displaying plugin documentation. * * Copyright (c) 2006-2010 Electric Cloud, Inc. * All rights reserved */ .help { font-family: Times New Roman, Times, serif; font-size: 16px; margin: 10px 10px 0px 30px; } .help h1 { font-family: Verdana, Helvetica, sans-serif; font-size: 25.89px; font-weight: bold; color: #4670B8; margin-left: -10px; } .help h2 { font-family: Verdana, Helvetica, sans-serif; font-size: 125%; font-weight: bold; color: #5981BD; margin-left: -10px; } .help h3 { font-family: Verdana, Helvetica, sans-serif; font-size: 115%; font-weight: bold; color: #5981BD; } .help h4 { font-family: Verdana, Helvetica, sans-serif; font-size: 100%; font-weight: bold; font-style: italic; color: #5981BD; } .help a { color: #333333; text-decoration: none; padding: 1px; background-image: url(../lib/images/dottedBorder1.gif); background-position: bottom; background-repeat: repeat-x; } .help a:hover { color: #CC6600; background-image: url(../lib/images/dottedBorder1Hover.gif); } .help ul li { list-style-position: outside; padding-bottom: 4px; font-size: 110%; margin-left: 5pt; } .help pre { font-size: 100%; } .help img { margin-top: 15px; margin-bottom: 8 px; margin-left: 30px; border-style: solid; border-width: 1px; } .grid { border-collapse: collapse; width: 900px; margin: 15px 0px 0px 30px; } .grid td { border-style: solid; border-width: 1px; padding: 3px 10px 3px 5px; font-size: 110%; } .grid th { border-style: solid; border-width: 1px; padding-right: 10px; padding-left: 5px; padding-top: 3px; padding-bottom: 3px; font-size: 110%; text-align: left; vertical-align: bottom; } .help .required { font-weight: bold; font-style: italic; } .help a:link { text-decoration:underline; } .help div > a { display: none; } </style> </head> <body> <div class="help"> <h1>EC-Admin</h1> <hr style="margin-left: -10px; margin-top: 10px; height: 1px; width: 100%; color: #5981BD;" noshade="noshade" /> <p>EC-Admin is a collection of administrative procedures to help you manage your server. Its inception was sparked by requests from customers during Professional Services engagement. It has grown over the years to what it is now.</p> <p>It contains the following modules:</p> <ul> <li><a href="#jobs">Jobs and Workspaces management</a></li> <li><a href="#plugin">Plugin creation</a></li> <li><a href="#artifacts">Artifacts management</a></li> <li><a href="#backup">Projects backup</a></li> <li><a href="#semapahore">Semaphore management</a></li> </ul> <h2><a name="installation"></a>Installation</h2> <p>This collection of procedures can be found on our <a href="https://github.com/electriccommunity/electriccommander/tree/master/EC-Admin">community repository on GitHub</a>. It is available either as a simple XML project export or as a plugin in the form of a .jar file.</p> <p>To install the plugin, use the "Install from File/URL" tab in the administration/Plugins or use the "installPlugin" API.</p> <p>To install the .xml project export, use the API call: <br/>ectool import /path_to/EC-Admin.xml --disableSchedules 1</p> <p>To install on 4.0.x or later, import the EC_4.0.xml file. Be aware that some features are not present as the original project makes use of createJobStep() API which was introduced in 4.2.0:<br/> ectool import /path_to/EC-Admin_for_EC_4.0.xml --disableSchedules 1</p> <p>If you get an error with the passKey, use the "--force 1" option</p> <h1><a name="jobs"></a>Jobs and Workspaces management</h1> <p>This set of procedures will help you manage your old jobs and the associated workspace.</p> <h2>jobsCleanup:</h2> <p>A procedure to delete jobs older than a specified number of days. It will also delete associated workspace job directories. You can also provide a property name, if this property is attached to the job, it won't be deleted no matter how old. A report only mode prevents any real deletion.</p> <h2>jobCleanup_byResult:</h2> <p>A procedure to delete jobs older than a specified number of days. It will also delete associated workspace job directories. It will keep the number of successful, failed and warning jobs you entered. You can also provide a property name, if this property is attached to the job, it won't be deleted no matter how old. A report only mode prevents any real deletion.</p> <h2>deleteWorksapceOrphans:</h2> <p>A procedure to crawl a workspace directory to find orphan jobs (directories without a matching job) on a specified resource.</p> <h2>deleteObjects:</h2> <p>A procedure to quickly delete jobs or workflows older than a specified number of days. It will <b>not</b> delete associated workspace job directories. This is for customers with huge job or workflow database.</p> <h1><a name="plugin"></a>Plugin creation</h1> <p>The procedure "createPluginFromProject" allows transforming a project into a plugin. The parameters are the following:</p> <dl> <dt><b>Author:</b></dt> <dd>The author of the project to transform into a plugin</dd> <dt><b>Email:</b></dt> <dd>The email of the author</dd> <dt><b>Category</b>:</dt> <dd>The category of the plugin. It helps filter the plugin in the Plugins page and in the pickerList.</dd> <dt><b>Description</b>:</dt> <dd>The description of the plugin do display in the main plugin page. If left empty it will default to the description of the project.</dd> <dt><b>installPlugin</b>:</dt> <dd>A Boolean to install or not the plugin after creation</dd> <dt><b>promotePlugin</b>:</dt> <dd>A Boolean to promote or not the plugin after installation</dd> <dt><b>Plugin</b>:</dt> <dd>The name of the plugin. If left empty, it will default to the project name.</dd> <dt><b>Project</b>:</dt> <dd>The name of the project to transform into a plugin</dd> <dt><b>Version</b>:</dt> <dd>Version of the plugin to create.</dd> </dl> <p>In addition each procedure can modify the behavior with the following 2 properties:</p> <dl> <dt><b>exposeToPlugin:</b></dt> <dd>This property if set to 1 will add the procedure to ec_setup to be shown in the procedure pickerList when choosing a plugin step.</dd> <dt><b>descriptionForPlugin:</b></dt> <dd>This property will be shown as the description in the pickerList mentioned above. If it's empty or non-existent, the description will be description of the procedure itself.</dd> </dl> <h1><a name="artifacts"></a>Artifact Management</h1> <h2>artifactsCleanup</h2> <p>A procedure to delete artifacts older than a specified number of days. Same as for jobs above, a property allows preventing the deletion. Once the artifacts have been deleted, artifact repositories and artifact caches are cleaned as well (deleting stale artifacts). A report only mode prevents any real deletion.</p> <dl> <dt>acquireSemaphore and releaseSemaphore:</dt> <dd>Those 2 procedures are used to create a gate for a set of steps. The important part is to use a resource with a step limit of one to ensure the atomicity of increasing and decreasing the gate value.</dd> <dt>saveProjects:</dt> <dd>A simple procedure to export individually all non-plugin projects to create your own versioning. Better to run on a nightly schedule.</dd> </dl> <h1>Contact author</h1> <p>Laurent Rochette (<a href="mailto:lrochette@electric-cloud.com">lrochette@electric-cloud.com</a>) </p> <h1>Legal Jumbo</h1> <p>This module is free for use. Modify it however you see fit to better your experience using ElectricCommander. Share your enhancements and fixes.</p> <p>This module is not officially supported by Electric Cloud. It has undergone no formal testing and you may run into issues that have not been uncovered in the limited manual testing done so far.</p> <p>Electric Cloud should not be held liable for any repercussions of using this software.</p> </div> </body> </html></value>
</property>
<property>
<propertyName>version</propertyName>
<description>Version of the EC-Admin project History: - version 1.3.5 + Added automatic performance charting + Bug fixes + Also available as a plugin. + jobsCleanup and jobCleanup_byResult: o Add a parameter to skip the computation of the disk space used; to speed up the job + Semaphore o Added a local job counter to decrement the global gate value. Useful when aborting a job. Simply a step that "always run" that will decrement your global gate by /myJob/localSemaphoreCounter + createPluginFromProject o Added to automatically create a plugin from a project - version 1.3.4 + Better resource management for artifactsCleanup and cleanupRepository + perforrmanceMetrics: o Fix bug on Free available RAM with European numbers o Add error management on fsutil call (Windows) o Add a cleanup step for temporary file used in Disk Performance + Refactor jobCleanup_byResult to include Workflow and schedule jobs Add time parameter + Add compareVersion in the PerlLib to compare number strings like x.y.z.... - version 1.3.3 + Added getPS() function in perlLib (JSON and XML format) + Added ec_parameterForm to artifactsCleanup to give it the same look and feel than jobCleanup + Took advantage of createJobStep to simplify artifactsCleanup - version 1.3.2 + Added "available disk space" information in performanceMetrics procedure + Fixed bug with getP() + Added Perl header and library for JSON format + Added new parameters for saveProjects (relocatable, ACLs and notifiers) - version 1.3.1: + Added "available memory" information in performanceMetrics procedure - version 1.3: + New procedure to delete jobs by results + New parameter to cleanupJobs to skip jobs matching a pattern - version 1.2: + New performance diagnostic procedure + provide a getP Perl function for easy getProperty + New procedure to delete workspace orphan job directories - version 1.1: semaphore management saveProjects - version 1.0: initial version including job and artifact management</description>
<expandable>1</expandable>
<value>1.3.5</value>
</property>
</propertySheet>
<credential>
<credentialName>adminLogin</credentialName>
<description></description>
<password>/DHePBz5RUcyoG7IRp4eyQ==</password>
<userName>admin</userName>
<propertySheet>
</propertySheet>
</credential>
<credential>
<credentialName>productionServerCreds</credentialName>
<description>Credentials to log onto the production server to import a project or a set of procedures/workflows</description>
<password>/DHePBz5RUcyoG7IRp4eyQ==</password>
<userName>admin</userName>
<propertySheet>
</propertySheet>
</credential>
<procedure>
<procedureName>acquireSemaphore</procedureName>
<description>Procedure to acquire a token in order to limit access to a set of procedures Changelog: -------------- 10-04-2013 lrochette Add job counter to help abort a job.</description>
<jobNameTemplate>$[/myProject/projectName]-$[/myProcedure/procedureName]_$[jobId]-$[/timestamp]</jobNameTemplate>
<resourceName></resourceName>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_customEditorData</propertyName>
<propertySheet>
<property>
<propertyName>parameters</propertyName>
<propertySheet>
<property>
<propertyName>maxSemaphoreValue</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>semaphoreProperty</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>serializationResource</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
<property>
<propertyName>descriptionForPlugin</propertyName>
<description>Description used in the pickerList when transformed into a plugin</description>
<expandable>1</expandable>
<value>Acquire a token in order to limit access to a set of procedures. </value>
</property>
<property>
<propertyName>exposeToPlugin</propertyName>
<description>So the procedure is shown in the pickerList</description>
<expandable>1</expandable>
<value>1</value>
</property>
<property>
<propertyName>pluginExpose</propertyName>
<description></description>
<expandable>1</expandable>
<value>1</value>
</property>
</propertySheet>
<formalParameter>
<formalParameterName>maxSemaphoreValue</formalParameterName>
<defaultValue></defaultValue>
<description>The maximum sempahore value to gate some procedures.</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<formalParameter>
<formalParameterName>semaphoreProperty</formalParameterName>
<defaultValue></defaultValue>
<description>The path to the property used as a semaphore</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<formalParameter>
<formalParameterName>serializationResource</formalParameterName>
<defaultValue></defaultValue>
<description>This should point to a resouce with a step limit of 1</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<step>
<stepName>acquireSemaphore</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>use strict; use ElectricCommander; $| = 1; my $ec = new ElectricCommander; my $xPath = $ec->getProperty("$[semaphoreProperty]"); my $semaphore = $xPath->findvalue('//value')->string_value; print "First eval: semaphore = $semaphore\n"; while ($semaphore >= $[maxSemaphoreValue]){ sleep(5); $xPath = $ec->getProperty("$[semaphoreProperty]"); $semaphore = $xPath->findvalue('//value')->string_value; print "in loop: semaphore = $semaphore\n"; } # When we get here, a token is available. Acquire it. my $xPath = $ec->incrementProperty("$[semaphoreProperty]"); # Increment local counter as well my $xPath = $ec->incrementProperty("/myJob/localSemaphoreCounter"); </command>
<condition></condition>
<description></description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName>$[serializationResource]</resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
</procedure>
<procedure>
<procedureName>artifactsCleanup</procedureName>
<description>Delete Artifacts and clean caches. A resource matching the Repository server is required or some steps will be skipped. Changelog: -------------- 08-07-2013 lrochette Better Resource management: test for existence, alive and enabled before invoking cleanupRepository. 07-29-2013 lrochette Added ec_parameterForm to give it the same look and feel than jobCleanup Took advantage of createJobStep to simplify the procedure</description>
<jobNameTemplate>$[/myProject/projectName]-$[/myProcedure/procedureName]_$[jobId]-$[/timestamp]</jobNameTemplate>
<resourceName>local</resourceName>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_customEditorData</propertyName>
<propertySheet>
<property>
<propertyName>parameters</propertyName>
<propertySheet>
<property>
<propertyName>adminLogin</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>artifactProperty</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>executeDeletion</propertyName>
<propertySheet>
<property>
<propertyName>checkedValue</propertyName>
<expandable>1</expandable>
<value>true</value>
</property>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
<property>
<propertyName>initiallyChecked</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
<property>
<propertyName>uncheckedValue</propertyName>
<expandable>1</expandable>
<value>false</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>olderThan</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
<property>
<propertyName>descriptionForPlugin</propertyName>
<description>Description used in the pickerList when transformed into a plugin</description>
<expandable>1</expandable>
<value>Delete old artifacts and clean caches.</value>
</property>
<property>
<propertyName>ec_parameterForm</propertyName>
<description></description>
<expandable>1</expandable>
<value><editor> <formElement> <label>Delete artifact versions older than</label> <property>olderThan</property> <documentation>Indicate the numbers of days after which artifact versions should be deleted</documentation> <type>select</type> <option> <name>1 month</name> <value>30</value> </option> <option> <name>2 months</name> <value>60</value> </option> <option> <name>3 months</name> <value>91</value> </option> <option> <name>6 months</name> <value>182</value> </option> <option> <name>1 year</name> <value>365</value> </option> <value>91</value> <required>1</required> </formElement> <formElement> <label>Artifact property</label> <property>artifactProperty</property> <documentation>Name of a property attached to your artifact versions. If this property is set, your artifact version won't be deleted. </documentation> <type>entry</type> <value>doNotDelete</value> <required>1</required> </formElement> <formElement> <label>Delete</label> <property>executeDeletion</property> <documentation>If this option is not set, only report is done. No real data are deleted</documentation> <type>select</type> <option> <name>Report</name> <value>false</value> </option> <option> <name>Delete</name> <value>true</value> </option> <value>false</value> </formElement> </editor></value>
</property>
<property>
<propertyName>exposeToPlugin</propertyName>
<description>So the procedure is shown in the pickerList</description>
<expandable>1</expandable>
<value>1</value>
</property>
</propertySheet>
<formalParameter>
<formalParameterName>artifactProperty</formalParameterName>
<defaultValue>doNotDelete</defaultValue>
<description>Name of a property attached to your artifactVersions. If this property is set, your artifactVersions won't be deleted no matter how old it is. </description>
<expansionDeferred>0</expansionDeferred>
<required>0</required>
<type>entry</type>
</formalParameter>
<formalParameter>
<formalParameterName>executeDeletion</formalParameterName>
<defaultValue>false</defaultValue>
<description>If this option is not set, only report is done. No real data are deleted</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>checkbox</type>
</formalParameter>
<formalParameter>
<formalParameterName>olderThan</formalParameterName>
<defaultValue>90</defaultValue>
<description>Indicate the numbers of days after which artifactVersions should be deleted</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<step>
<stepName>deleteArtifactVersions</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>############################################################################# # # deleteArtifactVersions -- Script to delete artifacts and caches # Copyright 2013 Electric-Cloud Inc. # ############################################################################# use DateTime; $[/myProject/scripts/perlHeader] $[/myProject/scripts/perlLib] ############################################################################# # # Assign Commander parameters to variables # ############################################################################# my $artifactProperty = "$[artifactProperty]"; my $timeLimit = $[olderThan]; my $executeDeletion= "$[executeDeletion]"; ############################################################################# # # Global Variables # ############################################################################# ############################################################################# # # Main # ############################################################################# printf("%s artifacts older than $timeLimit days (%s).\n", $executeDeletion eq "true"?"Deleting":"Reporting", calculateDate($timeLimit)); my ($success, $xPath) = InvokeCommander("SuppressLog", "findObjects", "artifact", {sort => [ {propertyName => "groupId", order => "ascending"} ]}); # Loop over artifacts my $nodeset = $xPath->find('//artifact'); foreach my $node ($nodeset->get_nodelist) { my $artifactName=$xPath->findvalue('artifactName', $node); printf("%s\n", $artifactName); # create filterList my @filterList; push (@filterList, {"propertyName" => 'artifactName', "operator" => "equals", "operand1" => $artifactName}); push (@filterList, {"propertyName" => "createTime", "operator" => "lessThan", "operand1" => calculateDate($timeLimit)}); push (@filterList, {"propertyName" => $artifactProperty, "operator" => "isNull"}); my ($success, $xPath) = InvokeCommander("SuppressLog", "findObjects", "artifactVersion", {'filter' => \@filterList}); my $versionset = $xPath->findnodes('//artifactVersion'); foreach my $version ($versionset->get_nodelist) { #print $version->findnodes_as_string("/") . "\n"; my $versionNumber=$version->findvalue('./artifactVersionName', $node); if ($executeDeletion eq "true") { my ($success, $xPath) = InvokeCommander("SuppressLog", "deleteArtifactVersion", $versionNumber); printf("\tDeleting %s\n", $versionNumber); } else { printf("\t%s\n", $versionNumber); } } printf("\n"); } ############################################################################# # # Calculate the size of the workspace directory # ############################################################################# sub getDirSize { my $dir = shift; my $size = 0; opendir(D,"$dir") || return 0; foreach my $dirContent (grep(!/^\.\.?/,readdir(D))) { my $st=stat("$dir/$dirContent"); if (S_ISREG($st->mode)) { $size += $st->size; } elsif (S_ISDIR($st->mode)) { $size += getDirSize("$dir/$dirContent"); } } closedir(D); return $size; } ############################################################################# # # Calculate the Date based on now and the number of days required by # the user before deleting jobs # ############################################################################# sub calculateDate { my $nbDays=shift; return DateTime->now()->subtract(days => $nbDays)->iso8601() . ".000Z"; } ############################################################################# # # Return human readable size # ############################################################################# sub humanSize { my $size = shift(); if ($size > 1099511627776) { # TB: 1024 GB return sprintf("%.2f TB", $size / 1099511627776); } if ($size > 1073741824) { # GB: 1024 MB return sprintf("%.2f GB", $size / 1073741824); } if ($size > 1048576) { # MB: 1024 KB return sprintf("%.2f MB", $size / 1048576); } elsif ($size > 1024) { # KiB: 1024 B return sprintf("%.2f KB", $size / 1024); } # bytes return "$size byte" . ($size <= 1 ? "" : "s"); } </command>
<condition></condition>
<description>Script to delete old Artifact Versions</description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName></resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
<step>
<stepName>dynamicCleanRepoProcedure</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>############################################################################# # # Copyright 2013 Electric-Cloud Inc. # ############################################################################# use DateTime; $[/myProject/scripts/perlHeader] $[/myProject/scripts/perlLib] ############################################################################# # # Assign Commander parameters to variables # ############################################################################# my $executeDeletion="$[executeDeletion]"; my $jobId = $[jobId]; my ($success, $xPath) = InvokeCommander("SuppressLog", "getRepositories"); my $nodeset = $xPath->find('//repository'); foreach my $node ($nodeset->get_nodelist) { my $repoName=$node->findvalue('repositoryName'); my $repoServerName = $node->findvalue('url'); my $repoDisabled = $node->findvalue('repositoryDisabled'); printf("AR: %s\n", $repoName); # # Skip disable repositories if ($repoDisabled) { printf (" Repository disabled: Skipping!\n"); next; } $repoServerName =~ s#https?://([\-\w]+)(:\d+)?#$1#; # checking that the resource exist and is enabled # ($success, $xPath) = InvokeCommander("SuppressLog IgnoreError", "getResource", $repoServerName); if (! $success) { printf(" Associated resource '%s' does not exist. Skipping!\n", $repoServerName); next; } my $resDisabled=$xPath->findvalue('//resource/resourceDisabled'); if ($resDisabled eq "1") { printf(" Associated resource '%s' disabled. Skipping!\n", $repoServerName); next; } my $agentAlive=$xPath->findvalue('//resource/agentState/alive'); if ($agentAlive eq "0") { printf(" Associated resource '%s' is not alive. Skipping!\n", $repoServerName); next; } my $stepName = "clean Step For ".$repoName; $ec->createJobStep({'jobStepName' => $stepName, 'subprocedure' => 'cleanupRepository', 'actualParameter' => [{'actualParameterName' => 'executeDeletion', 'value'=>$executeDeletion}, {'actualParameterName' => 'resource', 'value'=>$repoServerName}, ] }); } </command>
<condition></condition>
<description></description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName></resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
</procedure>
<procedure>
<procedureName>cleanupCacheDirectory</procedureName>
<description>Clear out all stale artifacts from a given artifact cache. Can be called manually on 1 resource or automatically on all</description>
<jobNameTemplate></jobNameTemplate>
<resourceName>$[resource]</resourceName>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_customEditorData</propertyName>
<propertySheet>
<property>
<propertyName>parameters</propertyName>
<propertySheet>
<property>
<propertyName>executeDeletion</propertyName>
<propertySheet>
<property>
<propertyName>checkedValue</propertyName>
<expandable>1</expandable>
<value>true</value>
</property>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
<property>
<propertyName>initiallyChecked</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
<property>
<propertyName>uncheckedValue</propertyName>
<expandable>1</expandable>
<value>false</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>olderThan</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>resource</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
<formalParameter>
<formalParameterName>executeDeletion</formalParameterName>
<defaultValue>false</defaultValue>
<description>If this option is not set, only report is done. No real data are deleted</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>checkbox</type>
</formalParameter>
<formalParameter>
<formalParameterName>olderThan</formalParameterName>
<defaultValue>90</defaultValue>
<description></description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<formalParameter>
<formalParameterName>resource</formalParameterName>
<defaultValue></defaultValue>
<description>The resource on which to run this job. The agent running on this resource must have access to the specified artifact cache directory. Note that if no artifact cache directory is specified, the job will cleanup the default artifact cache used by the resource.</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<step>
<stepName>clearInvalidArtifactVersions</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>$[/myProject/scripts/perlHeader] ############################################################################# # # Assign Commander parameters to variables # ############################################################################# my $executeDeletion= "$[executeDeletion]"; # We're going to try and find a valid cache directory. Mark the directory as invalid for now # and update it only once we find and validate the directory. $ec->setProperty("/myJob/cacheDirectoryIsValid", {value => 0}); # Check the environment variable COMMANDER_ARTIFACT_CACHE. my $cacheEnv = "COMMANDER_ARTIFACT_CACHE"; my $dir; if (defined($ENV{$cacheEnv})) { $dir = $ENV{$cacheEnv}; print "Cache directory found in environment: \"$dir\".\n"; } else { # We came up empty; give up since we don't know what directory to cleanup. warn "ERROR: No cache directory was found in the environment.\n"; $ec->setProperty("outcome", "warning"); $ec->setProperty("summary", "No cache directory"); exit(0); } if (! -d $dir) { # The directory can't be read; no need to try to clean it up. warn "ERROR: Cannot access directory \"$dir\".\n"; $ec->setProperty("outcome", "warning"); $ec->setProperty("summary", "Cache directory does not exit"); exit(0); } $ec->setProperty("/myJob/actualCacheDirectory", {value => $dir}); $ec->setProperty("/myJob/cacheDirectoryIsValid", {value => 1}); if ($executeDeletion eq "true") { print "Cleaning up artifact cache.\n"; $ec->cleanupArtifactCache($dir, {'force' => 1}); } else { print "Would call cleanupArtifactCache on \"$dir\".\n"; }</command>
<condition></condition>
<description></description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName></resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
<step>
<stepName>traverseCacheDirectory</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>$[/myProject/scripts/perlHeader] use ElectricCommander::Batch; use Data::Dumper; sub getContents($) { my ($dir) = @_; opendir(DIR, $dir) or die "ERROR: Couldn't open directory \"$dir\".\n"; my @contents = readdir(DIR); closedir(DIR); return @contents; } # Keep track of whether we found any candidates for time or space based deletion. $ec->setProperty("/myJob/candidatesForDeletion", {value => 0}); # Get the value of the actualCacheDirectory property. my $cache = $ec->getProperty("actualCacheDirectory")->findvalue("//value"); # Create a new parallel batch of getArtifactVersion requests. Use parallel mode # because we need to allow non-existent artifact versions, and single mode will # have a cascaded failure at the first error it encounters. my $gavBatch = $ec->newBatch('parallel'); # Create a map of GAV => requestId so we can get the appropriate response and # store the needed data. my %gavMap = (); foreach my $g (getContents($cache)) { # First level = (g)roup if ($g eq "." || $g eq ".." || ! -d "$cache/$g") { next; } else { foreach my $a (getContents("$cache/$g")) { # Second level = (a)rtifact if ($a eq "." || $a eq ".." || ! -d "$cache/$g/$a") { next; } else { foreach my $v (getContents("$cache/$g/$a")) { # Third level = (v)ersion if ($v eq "." || $v eq ".." || ! -d "$cache/$g/$a/$v") { next; } else { # Check to see if "g:a:v" is an artifact version. my $gav = "$g:$a:$v"; print "Potential artifact version: $gav\n"; my $reqId = $gavBatch->getArtifactVersion($gav, { includeRetrieverJobSteps => 1, maxRetrievers => 1 } ); $gavMap{$gav} = $reqId; } } } } } } if (keys %gavMap == 0) { print "No potential GAV directories were found in \"$cache\".\n"; exit 0; } # Allow "no such aritfact version" errors. $ec->abortOnError(0); $gavBatch->submit(); $ec->abortOnError(1); # Create a new parallel batch of getProperty requests. my $stepBatch = $ec->newBatch('single'); foreach my $gav (keys %gavMap) { my $reqId = $gavMap{$gav}; my $jobStepId = $gavBatch->findvalue($reqId, "artifactVersion/retriever/jobStepId")->string_value; if ($jobStepId ne "") { print "Artifact version \"$gav\" was last retrieved by job step $jobStepId.\n"; my $reqId = $stepBatch->getProperty("/jobSteps/$jobStepId/start"); $gavMap{$gav} = $reqId; } else { # Remove this artifact version from our map if no job step id was found, # which would happen if the artifact was never retrieved in a job context. delete $gavMap{$gav}; } } if (keys %gavMap == 0) { print "No potential GAV directories were retrieved by job steps.\n"; exit 0; } $stepBatch->submit(); # Get the start times for the last job step to access each artifact version and store # the artifact version => last access time in a property sheet on the job for future # steps to consume. foreach my $gav (keys %gavMap) { my $reqId = $gavMap{$gav}; my $start = $stepBatch->findvalue($reqId, "property/value")->string_value; $ec->setProperty("/myJob/validArtifactVersions/$gav", {value => $start}); } $ec->setProperty("/myJob/candidatesForDeletion", {value => 1});</command>
<condition>$[/javascript myJob.cacheDirectoryIsValid == '1']</condition>
<description></description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName></resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
<step>
<stepName>timeBaseDeletion</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>$[/myProject/scripts/perlHeader] use ElectricCommander::Batch; use File::Path; use Time::Local; ############################################################################# # # Assign Commander parameters to variables # ############################################################################# my $days=$[olderThan]; my $executeDeletion="$[executeDeletion]"; # Get the value of the actualCacheDirectory property. my $cache = $ec->getProperty("actualCacheDirectory")->findvalue("//value"); # Create a new parallel batch of deleteProperty requests for all artifact versions # that we are blowing away, so the /myJob/validArtifactVersions property sheet is # up to date for future steps that consume it. my $deleteBatch = $ec->newBatch('parallel'); # Figure out the time limit for deletion based on the number of days specified. my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time() - (3600*24*$days)); my $timeLimit = sprintf("%4d%02d%02d%02d%02d%02d", 1900+$year, $mon+1, $mday, $hour, $min, $sec); print "Time limit for deletion: $timeLimit\n"; # Get the properties stored in /myJob/validArtifactVersions so we can go through # each one to figure out if we should delete it. my $validVersions = $ec->getProperties({path => "/myJob/validArtifactVersions"}); foreach my $validVersion($validVersions->findnodes("//property")) { my $accessTime = $validVersion->findvalue("value")->string_value; $accessTime =~ s/[^.\d]//g; if ($accessTime < $timeLimit) { my $gav = $validVersion->findvalue("propertyName")->string_value; $gav =~ m/(.*):(.*):(.*)/; my $dir = "$cache/$1/$2/$3"; if ($executeDeletion eq "true") { print "Deleting \"$dir\" (last accessed $accessTime).\n"; rmtree($dir); } else { print "Would delete \"$dir\" (last accessed $accessTime).\n"; } } } </command>
<condition>$[/javascript myJob.candidatesForDeletion == '1']</condition>
<description></description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName></resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
</step>
</procedure>
<procedure>
<procedureName>cleanupRepository</procedureName>
<description>Clear out all stale artifacts from a repository's backing store. This procedure can be run on an individual repository or can be called on all repositories by "Artifact Cleanup"</description>
<jobNameTemplate>$[/myProject/projectName]-$[/myProcedure/procedureName]_$[jobId]-$[/timestamp]</jobNameTemplate>
<resourceName>$[resource]</resourceName>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_customEditorData</propertyName>
<propertySheet>
<property>
<propertyName>parameters</propertyName>
<propertySheet>
<property>
<propertyName>adminLogin</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>executeDeletion</propertyName>
<propertySheet>
<property>
<propertyName>checkedValue</propertyName>
<expandable>1</expandable>
<value>true</value>
</property>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
<property>
<propertyName>initiallyChecked</propertyName>
<expandable>1</expandable>
<value>0</value>
</property>
<property>
<propertyName>uncheckedValue</propertyName>
<expandable>1</expandable>
<value>false</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>resource</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
</property>
</propertySheet>
<formalParameter>
<formalParameterName>executeDeletion</formalParameterName>
<defaultValue>false</defaultValue>
<description>If this option is not set, only report is done. No real data are deleted</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>checkbox</type>
</formalParameter>
<formalParameter>
<formalParameterName>resource</formalParameterName>
<defaultValue>local</defaultValue>
<description>The resource on which to run this job. This resource must be running on the same machine as a repository server. The job will detect the repository's backing store location based on the assumption that the resource is installed along with the repository.</description>
<expansionDeferred>0</expansionDeferred>
<required>1</required>
<type>entry</type>
</formalParameter>
<step>
<stepName>clearInvalidArtifactVersions</stepName>
<alwaysRun>0</alwaysRun>
<broadcast>0</broadcast>
<command>$[/myProject/scripts/perlHeader] use warnings; use File::Spec; my $executeDeletion="$[executeDeletion]"; my $response; my $dataEnv = "COMMANDER_DATA"; my $dataDir; if (defined($ENV{$dataEnv})) { $dataDir = $ENV{$dataEnv}; print "Data directory found in environment: \"$dataDir\".\n"; } else { # No data directory in the environment; probably a pre-4.0 agent. die "ERROR: No data directory was found in the environment.\n"; } if (! -d $dataDir) { # The data directory is invalid. die "ERROR: Cannot access data directory \"$dataDir\".\n"; } my $propsFile = "$dataDir/conf/repository/server.properties"; if (! -f $propsFile) { # There's no repository server.properties. die "ERROR: Cannot find repository configuration file \"$propsFile\".\n"; } open PROPS, $propsFile or die "Could not open repository configuration file \"$propsFile\": $!"; binmode PROPS; my $propsContents = join("", <PROPS>); close PROPS; $propsContents =~ m/REPOSITORY_BACKING_STORE=([^\n]*)/; my $backingStore = $1; if (!defined($backingStore) || $backingStore eq "") { # Invalid backing store. die "ERROR: Cannot find backing store in repository configuration file \"$propsFile\".\n"; } # If the backing store isn't an absolute path, it is relative to the data directory. if (!File::Spec->file_name_is_absolute($backingStore)) { $backingStore = "$dataDir/$backingStore"; } if (! -d $backingStore) { # The backing store directory is invalid. die "ERROR: Cannot access backing store directory \"$backingStore\".\n"; } if ($executeDeletion eq "true") { # Get Admin user/password from project-level credential # getFullCredential will not reveal the contents of the "password" field my $xPath = $ec->getFullCredential("adminLogin"); my $user = $xPath->findvalue("//userName"); my $passwd = $xPath->findvalue("//password"); print "Cleaning up repository backing store \"$backingStore\".\n"; $ec->login($user, $passwd); $ec->cleanupRepository($backingStore); } else { print "Would call cleanupRepository on \"$backingStore\".\n"; }</command>
<condition></condition>
<description>Check the environment variable COMMANDER_DATA, then check for a repository server.properties relative to this directory. Error out if the properties file can't be found, otherwise parse it for the backing store location. Once we have the backing store, call cleanupRepository on that directory. </description>
<errorHandling>failProcedure</errorHandling>
<exclusiveMode>none</exclusiveMode>
<logFileName></logFileName>
<parallel>0</parallel>
<postProcessor></postProcessor>
<releaseMode>none</releaseMode>
<resourceName>$[resource]</resourceName>
<shell>ec-perl</shell>
<workingDirectory></workingDirectory>
<workspaceName></workspaceName>
<propertySheet>
</propertySheet>
<attachedCredentials>
<credentialName>adminLogin</credentialName>
</attachedCredentials>
</step>
</procedure>
<procedure>
<procedureName>createPluginFromProject</procedureName>
<description>Create a plugin from a simple project</description>
<jobNameTemplate>$[/myProject/scripts/jobTemplate]</jobNameTemplate>
<resourceName>local</resourceName>
<workspaceName></workspaceName>
<propertySheet>
<property>
<propertyName>ec_customEditorData</propertyName>
<propertySheet>
<property>
<propertyName>parameters</propertyName>
<propertySheet>
<property>
<propertyName>Author</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>Category</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>Description</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>Email</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>
</property>
<property>
<propertyName>Plugin</propertyName>
<propertySheet>
<property>
<propertyName>formType</propertyName>
<expandable>1</expandable>
<value>standard</value>
</property>
</propertySheet>