forked from kjdowney/EC-Admin
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathec_setup_custom.pl
More file actions
126 lines (114 loc) · 4.51 KB
/
Copy pathec_setup_custom.pl
File metadata and controls
126 lines (114 loc) · 4.51 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
use Cwd;
use File::Spec;
use POSIX;
use MIME::Base64;
use File::Temp qw(tempfile tempdir);
use Archive::Zip;
use Digest::MD5 qw(md5_hex);
my $dir = getcwd;
# promote/demote action
if ( $promoteAction eq 'promote' ) {
local $self->{abortOnError} = 0;
# If the licenseLogger config PS does not already exist, create it
my $cfg = $commander->getProperty("/server/EC-Admin/licenseLogger/config");
if ($cfg->findvalue("//code") eq "NoSuchProperty") {
# we need the top PS later for the ACLs
$commander->createProperty("/server/EC-Admin", {propertyType => 'sheet'});
$batch->setProperty( "/server/EC-Admin/licenseLogger/config/emailTo", "admin",{description=>'comma separated list of userid or email'} );
$batch->setProperty( "/server/EC-Admin/licenseLogger/config/emailConfig", "default",{description=>'The name of your email configuration'} );
$batch->setProperty( "/server/EC-Admin/licenseLogger/config/cleanpOldJobs", 1 );
$batch->setProperty( "/server/EC-Admin/licenseLogger/config/resource", "local" );
$batch->setProperty( "/server/EC-Admin/licenseLogger/config/workspace", "default" );
}
# If the cleanup config PS does not already exist, create it
$cfg = $commander->getProperty("/server/EC-Admin/cleanup/config");
if ($cfg->findvalue("//code") eq "NoSuchProperty") {
$batch->setProperty( "/server/EC-Admin/cleanup/config/timeout", 600);
}
# Give project Electric Cloud permission on ec_reportData
my $projPrincipal = "project: Electric Cloud";
my $ecAdminProj = $pluginName;
$cfg = $commander->getProperty("ec_reportData", {projectName => $ecAdminProj});
my $psId= $cfg->findvalue("//propertySheetId");
my $xpath = $commander->getAclEntry("user", $projPrincipal,
{
projectName => $ecAdminProj,
propertySheetId => $psId
});
if ($xpath->findvalue('//code') eq 'NoSuchAclEntry') {
$batch->createAclEntry("user", $projPrincipal,
{
projectName => $ecAdminProj,
propertySheetId => $psId,
"readPrivilege"=>"allow",
"modifyPrivilege"=>"allow",
});
}
#
# Give Everyone permission on /server/counters/EC-Admin
$cfg = $commander->getProperty("/server/counters/EC-Admin/jobCounter");
if ($cfg->findvalue("//code") eq "NoSuchProperty") {
$commander->setProperty( "/server/counters/EC-Admin/jobCounter", 0,
{
description => "job counter property for EC-Admin plugin"
});
}
$cfg=$commander->getProperty("/server/counters/EC-Admin");
$psId= $cfg->findvalue("//propertySheetId");
$xpath = $commander->getAclEntry("group", "Everyone", {propertySheetId => $psId});
if ($xpath->findvalue('//code') eq 'NoSuchAclEntry') {
$batch->createAclEntry("group", "Everyone",
{
propertySheetId => $psId,
"readPrivilege" =>"allow",
"modifyPrivilege" =>"allow",
});
}
# Give plugin permission on /server/EC-Admin
$projPrincipal="project: $pluginName";
$cfg = $commander->getProperty("/server/EC-Admin");
$psId= $cfg->findvalue("//propertySheetId");
$xpath = $commander->getAclEntry("user", $projPrincipal,
{
propertySheetId => $psId
});
if ($xpath->findvalue('//code') eq 'NoSuchAclEntry') {
$batch->createAclEntry("user", "$projPrincipal",
{
propertySheetId => $psId,
"readPrivilege" =>"allow",
"modifyPrivilege" =>"allow",
"changePermissionsPrivilege" => "allow",
});
}
# Remove previous plugin permission on /server/EC-Admin
if ($otherPluginName ne "") {
my $otherProjPrincipal="project: $otherPluginName";
# $psId is the same than above
$xpath = $commander->getAclEntry("user", $otherProjPrincipal,
{
propertySheetId => $psId
});
if ($xpath->findvalue('//principalName') eq $otherProjPrincipal) {
$batch->deleteAclEntry("user", "$otherProjPrincipal",
{
propertySheetId => $psId,
});
}
}
} elsif ( $promoteAction eq 'demote' ) {
# Remove plugin permission on /server/EC-Admin
my $projPrincipal="project: $pluginName";
my $cfg = $commander->getProperty("/server/EC-Admin");
my $psId= $cfg->findvalue("//propertySheetId");
my $xpath = $commander->getAclEntry("user", $projPrincipal,
{
propertySheetId => $psId
});
if ($xpath->findvalue('//principalName') eq $projPrincipal) {
$batch->deleteAclEntry("user", "$projPrincipal",
{
propertySheetId => $psId,
});
}
}