-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into production
- Loading branch information
Showing
13 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use File::Basename; | ||
use perunDataGenerator; | ||
|
||
local $::SERVICE_NAME = basename($0); | ||
local $::PROTOCOL_VERSION = "3.0.0"; | ||
|
||
perunDataGenerator::generateUsersDataInJSON; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use perunServicesInit; | ||
use perunServicesUtils; | ||
use JSON::XS; | ||
|
||
our $SERVICE_NAME = "openstack_projects"; | ||
our $PROTOCOL_VERSION = "3.0.0"; | ||
my $SCRIPT_VERSION = "3.0.0"; | ||
|
||
perunServicesInit::init; | ||
my $DIRECTORY = perunServicesInit::getDirectory; | ||
my $data = perunServicesInit::getHashedHierarchicalData; | ||
|
||
our $A_FACILITY_PROJECT_NAMESPACE; *A_FACILITY_PROJECT_NAMESPACE = \'urn:perun:facility:attribute-def:def:projectNamespace'; | ||
our $A_USER_MAIL; *A_USER_MAIL = \'urn:perun:user:attribute-def:def:preferredMail'; | ||
our $A_USER_FACILITY_LOGIN; *A_USER_FACILITY_LOGIN = \'urn:perun:user_facility:attribute-def:virt:login'; | ||
our $A_USER_OPTIONAL_LOGIN; *A_USER_OPTIONAL_LOGIN = \'urn:perun:user:attribute-def:virt:optionalLogin-namespace:mu'; | ||
our $A_RESOURCE_NAME; *A_RESOURCE_NAME = \'urn:perun:resource:attribute-def:core:name'; | ||
our $A_MEMBER_EXPIRATION; *A_MEMBER_EXPIRATION = \'urn:perun:member:attribute-def:def:membershipExpiration'; | ||
our $A_MEMBER_STATUS; *A_MEMBER_STATUS = \'urn:perun:member:attribute-def:core:status'; | ||
|
||
our $STATUS_VALID; *STATUS_VALID = \'VALID'; | ||
|
||
our $members = {}; | ||
|
||
my $instance = $data->getFacilityAttributeValue(attrName => $A_FACILITY_PROJECT_NAMESPACE); | ||
my $projectPrefix = lc $instance . "_"; | ||
|
||
foreach my $resourceId ($data->getResourceIds()) { | ||
|
||
my $resourceName = $data->getResourceAttributeValue(resource => $resourceId, attrName => $A_RESOURCE_NAME); | ||
my $projectName = $resourceName; | ||
|
||
my $hasAccess = 0; | ||
if ($resourceName =~ /-access$/) { | ||
$hasAccess = 1; | ||
$projectName = $projectPrefix . substr $resourceName, 0, length($resourceName) - 7; | ||
} | ||
|
||
my $isManager = 0; | ||
if ($resourceName =~ /-managers$/) { | ||
$isManager = 1; | ||
$projectName = $projectPrefix . substr $resourceName, 0, length($resourceName) - 9; | ||
} | ||
|
||
my $isPersonalProject = 0; | ||
if ($resourceName =~ /-personalProjects$/) { | ||
$isPersonalProject = 1; | ||
} | ||
|
||
foreach my $memberId ($data->getMemberIdsForResource(resource => $resourceId)) { | ||
my $identifier = $data->getUserFacilityAttributeValue(member => $memberId, attrName => $A_USER_FACILITY_LOGIN); | ||
$identifier = $identifier . "\@muni.cz" if $projectPrefix eq "mu_"; | ||
|
||
if($members->{$identifier}) { | ||
if ($hasAccess) { | ||
push @{$members->{$identifier}->{'projects_access'}}, $projectName; | ||
} | ||
if ($isManager) { | ||
push @{$members->{$identifier}->{'projects_managers'}}, $projectName; | ||
} | ||
if ($isPersonalProject) { | ||
my $status = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_STATUS); | ||
if($status eq $STATUS_VALID) { | ||
$members->{$identifier}->{'personal_project'} = JSON::XS::true; | ||
my $memberExpiration = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_EXPIRATION); | ||
if (!$memberExpiration) { | ||
$memberExpiration = ""; | ||
} | ||
$members->{$identifier}->{'expiration'} = $memberExpiration; | ||
} | ||
} | ||
} else { | ||
my @additionalIdentifier = (); | ||
my $muLogin = $data->getUserAttributeValue(member => $memberId, attrName => $A_USER_OPTIONAL_LOGIN); | ||
if ($muLogin) { | ||
push @additionalIdentifier, $muLogin . "\@muni.cz"; | ||
} | ||
|
||
my $mail = $data->getUserAttributeValue(member => $memberId, attrName => $A_USER_MAIL); | ||
|
||
my @projects_access = (); | ||
if ($hasAccess) { | ||
push @projects_access, $projectName; | ||
} | ||
my @projects_managers = (); | ||
if ($isManager) { | ||
push @projects_managers, $projectName; | ||
} | ||
|
||
my $member = { | ||
identifier => $identifier, | ||
additional_identifier => \@additionalIdentifier, | ||
mail => $mail, | ||
projects_access => \@projects_access, | ||
projects_managers => \@projects_managers | ||
}; | ||
|
||
my $status = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_STATUS); | ||
if ($isPersonalProject && $status eq $STATUS_VALID) { | ||
$member->{'personal_project'} = JSON::XS::true; | ||
my $memberExpiration = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_EXPIRATION); | ||
if(!$memberExpiration) { | ||
$memberExpiration = ""; | ||
} | ||
$member->{'expiration'} = $memberExpiration; | ||
} else { | ||
$member->{'personal_project'} = JSON::XS::false; | ||
} | ||
|
||
$members->{$identifier} = $member; | ||
} | ||
} | ||
} | ||
|
||
my @values = values(%$members); | ||
my $fileData = { | ||
instance => $instance, | ||
access => \@values | ||
}; | ||
my $file = $DIRECTORY . "access.json"; | ||
open FILE_USERS, ">$file" or die "Cannot open $file: $! \n"; | ||
print FILE_USERS JSON::XS->new->utf8->pretty->canonical->encode($fileData), "\n"; | ||
close(FILE_USERS) or die "Cannot close $file: $! \n"; | ||
|
||
perunServicesInit::finalize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
SERVICE_NAME="o365_mu_account_status" | ||
|
||
. generic_send |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
SERVICE_NAME="openstack_projects" | ||
|
||
. generic_send |
28 changes: 28 additions & 0 deletions
28
slave/process-o365-mu-account-status/bin/process-o365_mu_account_status.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
PROTOCOL_VERSION='3.0.0' | ||
|
||
function process { | ||
|
||
### Status codes | ||
I_CHANGED=(0 "${DST_FILE} updated") | ||
I_NOT_CHANGED=(0 "${DST_FILE} has not changed") | ||
|
||
E_MISSING_DST=(50 'Missing destination of file (DST_FILE), need to be set in pre_script.') | ||
|
||
FROM_PERUN="${WORK_DIR}/o365_mu_account_status" | ||
|
||
if [ -z ${DST_FILE} ]; then | ||
log_msg E_MISSING_DST | ||
fi | ||
|
||
create_lock | ||
|
||
# Create diff between old.perun and .new | ||
diff_mv_sync "${FROM_PERUN}" "${DST_FILE}" | ||
|
||
if [ $? -eq 0 ]; then | ||
log_msg I_CHANGED | ||
else | ||
log_msg I_NOT_CHANGED | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
perun-slave-process-o365-mu-account-status (3.1.1) stable; urgency=low | ||
|
||
* New package version for perun-slave-process-o365-mu-account-status | ||
|
||
-- Michal Stava <[email protected]> Wed, 29 Sep 2021 15:21:00 +0200 |
3 changes: 3 additions & 0 deletions
3
slave/process-o365-mu-account-status/conf/example-pre_01_set_target_dir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
#SET destination file | ||
#DST_FILE=/var/opt/perun/o365_mu_account_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package for perun service - o365_mu_account_status |