Skip to content

Commit 766a880

Browse files
authored
Merge pull request #2308 from zlamalp/sponsor
CLI: Support SPONSOR role in setRole/unsetRole tools
2 parents adbeb91 + 1211ccb commit 766a880

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

perun-cli/Perun/VosAgent.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,13 @@ sub getRichAdminsWithAttributes
8383
return Perun::Common::callManagerMethod('getRichAdminsWithAttributes', '[]RichUser', @_);
8484
}
8585

86+
sub addSponsorRole
87+
{
88+
return Perun::Common::callManagerMethod('addSponsorRole', 'null', @_);
89+
}
90+
sub removeSponsorRole
91+
{
92+
return Perun::Common::callManagerMethod('removeSponsorRole', 'null', @_);
93+
}
94+
8695
1;

perun-cli/setRole

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ if ($role eq "PERUNADMIN") {
104104
my $vosAgent = $agent->getVosAgent;
105105
my $vo = $vosAgent->getVoById( id => $voId );
106106
if (defined($userId)) {
107-
$authzResolverAgent->setRole( user => $userId, complementaryObject => $vo, role => $role );
107+
if ("SPONSOR" eq $role) {
108+
$vosAgent->addSponsorRole( user => $userId, vo => $vo->getId());
109+
} else {
110+
$authzResolverAgent->setRole( user => $userId, complementaryObject => $vo, role => $role );
111+
}
108112
printMessage("$role role is successfully set for user $userId and VO $voId", $batch);
109113
} else {
110-
$authzResolverAgent->setRole( authorizedGroup => $authorizedGroupId, complementaryObject => $vo, role => $role );
114+
if ("SPONSOR" eq $role) {
115+
$vosAgent->addSponsorRole( authorizedGroup => $authorizedGroupId, vo => $vo->getId());
116+
} else {
117+
$authzResolverAgent->setRole( authorizedGroup => $authorizedGroupId, complementaryObject => $vo, role => $role );
118+
}
111119
printMessage("$role role is successfully set for authorizedGroup $authorizedGroupId and VO $voId", $batch);
112120
}
113121
#resource

perun-cli/unsetRole

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,19 @@ if ($role eq "PERUNADMIN") {
104104
my $vosAgent = $agent->getVosAgent;
105105
my $vo = $vosAgent->getVoById( id => $voId );
106106
if (defined($userId)) {
107-
$authzResolverAgent->unsetRole( user => $userId, complementaryObject => $vo, role => $role );
107+
if ("SPONSOR" eq $role) {
108+
$vosAgent->removeSponsorRole( user => $userId, vo => $vo->getId());
109+
} else {
110+
$authzResolverAgent->unsetRole( user => $userId, complementaryObject => $vo, role => $role );
111+
}
108112
printMessage("$role role was removed from user $userId and VO $voId", $batch);
109113
} else {
110-
$authzResolverAgent->unsetRole( authorizedGroup => $authorizedGroupId, complementaryObject => $vo, role => $role );
114+
if ("SPONSOR" eq $role) {
115+
$vosAgent->removeSponsorRole( authorizedGroup => $authorizedGroupId, vo => $vo->getId());
116+
} else {
117+
$authzResolverAgent->unsetRole( authorizedGroup => $authorizedGroupId, complementaryObject => $vo, role => $role );
118+
}
119+
111120
printMessage("$role role was removed from authorizedGroup $authorizedGroupId and VO $voId", $batch);
112121
}
113122
#resource

0 commit comments

Comments
 (0)