Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions irodscollector_multi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# template of a configuration file for EUDAT's irodscollector
#

# section containing the logging options
[Logging]
log_file=eudatacct.log

# section containing the properties to access the accounting server
# to get statistical data and report them
[Report]
# base URL of the accounting server to be used
base_url=https://accounting.eudat.eu
# domain: either eudat or test or demo
domain=eudat

# institutes which this iRODS instance handles
institutes=inst_a,inst_b

[inst_a]
# uid of the corresponding registered storage resource on DPMT
# (same as storage_space_uuid on RCT)
account=<insert uid here>
# username of the provider on the accouniting server
# owning the account specified above
# contact dp-admin@mpcdf.mpg.de if you need one
user=<username of provider>
# if you have an access token from RCT already reuse that here
password=<password or access token>
service_uuid=<unsuported at the moment>

# section contains the list of collections to be accounted together, replace
# the examples with your collections, the script sums the values of all
# collections and sends it to EUDAT's accounting service.
clist=
/vzx/eudat/A
/vzx/other/pathA

[inst_b]
# uid of the corresponding registered storage resource on DPMT
# (same as storage_space_uuid on RCT)
account=<insert uid here>
# username of the provider on the accouniting server
# owning the account specified above
# contact dp-admin@mpcdf.mpg.de if you need one
user=<username of provider>
# if you have an access token from RCT already reuse that here
password=<password or access token>
service_uuid=<unsuported at the moment>

# section contains the list of collections to be accounted together, replace
# the examples with your collections, the script sums the values of all
# collections and sends it to EUDAT's accounting service.
clist=
/vzx/eudat/B
/vzx/other/pathB
66 changes: 59 additions & 7 deletions src/eudat/accounting/client/iRODScollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,37 @@ def parseConf(self):
self.logfile = self.fileparser.get('Logging','log_file')
self.base_url = self.fileparser.get('Report','base_url')
self.domain = self.fileparser.get('Report','domain')
self.account = self.fileparser.get('Report','account')
self.user = self.fileparser.get('Report','user')
self.password = self.fileparser.get('Report','password')
self.service_uuid = self.fileparser.get('Report','service_uuid')
self.collections = self.fileparser.get('Collections','clist')

### Reads the information of the institutes into a list of dictionaries, one for each institute
# !!! Assumes correct syntax in config file: Does not check if there is a separate section for each institute listed in the 'Report' section
if self.fileparser.has_option('Report', 'institutes'):
self.hasInstitutes = True
inst = self.fileparser.get('Report','institutes')
inst = inst.split(',')
self.institutes = []
for instName in inst:
valueDict = {}
valueDict['name'] = instName
valueDict['account'] = self.fileparser.get(instName, 'account')
valueDict['user'] = self.fileparser.get(instName, 'user')
valueDict['password'] = self.fileparser.get(instName, 'password')
valueDict['service_uuid'] = self.fileparser.get(instName, 'service_uuid')
valueDict['clist'] = self.fileparser.get(instName, 'clist')
self.institutes.append(valueDict)
self.currentInst = -1
else:
# ensures that it works with the original version of the config file that doesn't have separate institutes
self.hasInstitutes = False
self.account = self.fileparser.get('Report','account')
self.user = self.fileparser.get('Report','user')
self.password = self.fileparser.get('Report','password')
self.service_uuid = self.fileparser.get('Report','service_uuid')
self.collections = self.fileparser.get('Collections','clist')
self.currentInst = -2

self.setNextInstitute()

###

#create a file handler
handler = logging.handlers.RotatingFileHandler(self.logfile, \
Expand All @@ -66,6 +92,30 @@ def parseConf(self):
# add the handlers to the logger
self.logger.addHandler(handler)

def setNextInstitute(self):

"""" Used to iterate between institutes that are in the config file:
increments self.currentInst and sets the information in the configuration class to that of the new institute
Starts from the begining when the currentInst is -1 and ends (returns False) currentInst+1 falls out of the list range
"""

self.currentInst += 1
instNum = self.currentInst

if not self.hasInstitutes or instNum < 0 or instNum >= len(self.institutes):
self.currentInst = -2
return False
self.account = self.institutes[instNum]['account']
self.user = self.institutes[instNum]['user']
self.password = self.institutes[instNum]['password']
self.service_uuid = self.institutes[instNum]['service_uuid']
self.collections = self.institutes[instNum]['clist']

print("*** institute: " + self.institutes[instNum]['name'])

return self.institutes[instNum]['name']


################################################################################
# EUDAT accounting Class #
################################################################################
Expand Down Expand Up @@ -245,13 +295,15 @@ def run(self):

logger = logging.getLogger('StorageAccounting')
logger.setLevel(logging.INFO)

###
configuration = Configuration(self.args.configpath,
logger, fileparser)
configuration.parseConf()

eurep = EUDATAccounting(configuration, logger)
logger.info("Accounting starting ...")
eurep.reportStatistics(self.args)
# ierate between instituteds and report statistics for each one separately
while configuration.setNextInstitute():
eurep.reportStatistics(self.args)
logger.info("Accounting finished")