-
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
8 changed files
with
141 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
use perunServicesInit; | ||
use perunServicesUtils; | ||
use File::Basename; | ||
use utf8; | ||
|
||
binmode STDOUT, ":utf8"; | ||
|
||
our $SERVICE_NAME = basename($0); | ||
our $PROTOCOL_VERSION = "3.0.0"; | ||
my $SCRIPT_VERSION = "3.0.0"; | ||
|
||
perunServicesInit::init; | ||
my $DIRECTORY = perunServicesInit::getDirectory; | ||
my $data = perunServicesInit::getHashedHierarchicalData; | ||
|
||
#Constants | ||
our $A_USER_ID; *A_USER_ID = \'urn:perun:user:attribute-def:core:id'; | ||
our $A_USER_EPPN; *A_USER_EPPN = \'urn:perun:user:attribute-def:virt:eduPersonPrincipalNames'; | ||
our $A_MEMBER_STATUS; *A_MEMBER_STATUS = \'urn:perun:member:attribute-def:core:status'; | ||
our $A_MEMBER_MAIL; *A_MEMBER_MAIL = \'urn:perun:member:attribute-def:def:mail'; | ||
our $A_RES_VO_NAME; *A_RES_VO_NAME = \'urn:perun:resource:attribute-def:virt:voShortName'; | ||
|
||
our $STATUS_VALID; *STATUS_VALID = \'VALID'; | ||
|
||
#Other constants | ||
our $EINFRA_DOMAIN = '@einfra.cesnet.cz'; | ||
our $META_DOMAIN = '@meta.cesnet.cz'; | ||
|
||
my $service_file_name = "$DIRECTORY/$::SERVICE_NAME"; | ||
|
||
my $usersStructureByUserId = {}; | ||
|
||
##################################### | ||
|
||
foreach my $resourceId ($data->getResourceIds()) { | ||
|
||
my $voName = $data->getResourceAttributeValue(attrName => $A_RES_VO_NAME, resource => $resourceId); | ||
|
||
if ($voName ne 'cesnet') { | ||
# allow only single VO "cesnet" -> data from all resources will be the same, including member mail | ||
next; | ||
} | ||
|
||
foreach my $memberId ($data->getMemberIdsForResource(resource => $resourceId)) { | ||
|
||
#skip non-valid members | ||
next if $data->getMemberAttributeValue(attrName => $A_MEMBER_STATUS, member => $memberId) ne $STATUS_VALID; | ||
|
||
my $userId = $data->getUserAttributeValue(attrName => $A_USER_ID, member => $memberId); | ||
|
||
unless(defined $usersStructureByUserId->{$userId}) { | ||
|
||
my $mail = $data->getMemberAttributeValue(attrName => $A_MEMBER_MAIL, member => $memberId); | ||
$usersStructureByUserId->{$userId}->{$A_MEMBER_MAIL} = $mail; | ||
|
||
#if user has meta eppn, he should have also einfra eppn | ||
my %userEPPNs = map { $_ => 1 } @{$data->getUserAttributeValue(attrName => $A_USER_EPPN, member => $memberId)}; | ||
foreach my $eppn (keys %userEPPNs) { | ||
if($eppn =~ m/$META_DOMAIN/) { | ||
my $neweppn = $eppn; | ||
$neweppn =~ s/$META_DOMAIN/$EINFRA_DOMAIN/ge; | ||
$userEPPNs{$neweppn} = 1; | ||
} | ||
} | ||
#list of eppns must be unique | ||
$usersStructureByUserId->{$userId}->{$A_USER_EPPN} = \%userEPPNs; | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
####### FILE WITH DATA FOR OUTPUT FILE ###### | ||
open SERVICE_FILE,">$service_file_name" or die "Cannot open $service_file_name: $! \n"; | ||
binmode SERVICE_FILE, ":utf8"; | ||
|
||
#print header to the file | ||
print SERVICE_FILE "user_id\tmail\teppns\n"; | ||
|
||
foreach my $userId (sort { $a <=> $b } keys %$usersStructureByUserId) { | ||
print SERVICE_FILE $userId . "\t"; | ||
print SERVICE_FILE $usersStructureByUserId->{$userId}->{$A_MEMBER_MAIL} . "\t"; | ||
print SERVICE_FILE join(',', sort keys %{$usersStructureByUserId->{$userId}->{$A_USER_EPPN}}); | ||
print SERVICE_FILE "\n"; | ||
} | ||
|
||
close(SERVICE_FILE); | ||
|
||
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="rt_data_vocesnet" | ||
|
||
. generic_send |
25 changes: 25 additions & 0 deletions
25
slave/process-rt-data-vocesnet/bin/process-rt_data_vocesnet.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,25 @@ | ||
#!/bin/bash | ||
|
||
PROTOCOL_VERSION='3.0.0' | ||
|
||
function process { | ||
|
||
DST_DIR="/tmp/" | ||
DST_FILE="rt-data-vocesnet" | ||
|
||
### Status codes | ||
I_CHANGED=(0 "${DST_FILE} updated") | ||
E_NOT_CHANGE=(50 'Cannot copy file ${FROM_PERUN} to ${DST_FILE}') | ||
|
||
FROM_PERUN="${WORK_DIR}/rt_data_vocesnet" | ||
|
||
create_lock | ||
|
||
cp "${FROM_PERUN}" "${DST_DIR}/${DST_FILE}" | ||
|
||
if [ $? -eq 0 ]; then | ||
log_msg I_CHANGED | ||
else | ||
log_msg E_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-rt-data-vocesnet (3.0.0) stable; urgency=low | ||
|
||
* New package for processing service rt_data_vocesnet | ||
|
||
-- Pavel Zlamal <[email protected]> Wed, 16 Mar 2022 13:20:00 +0100 |
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 - rt_data_vocesnet |