Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Apr 21, 2020
1 parent 45f4187 commit b48c11e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 44 deletions.
6 changes: 3 additions & 3 deletions ConfigurationSystem/test/Test_agentOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
('DIRAC.ConfigurationSystem.Agent.VOMS2CSAgent', {'IgnoreOptions': ['VO']}),
('DIRAC.DataManagementSystem.Agent.FTS3Agent', {}),
('DIRAC.FrameworkSystem.Agent.CAUpdateAgent', {}),
('DIRAC.FrameworkSystem.Agent.MyProxyRenewalAgent', {'IgnoreOptions': ['MinValidity', 'ValidityPeriod',
'MinimumLifeTime',
'RenewedLifeTime']}),
('DIRAC.FrameworkSystem.Agent.MyProxyRenewalAgent', {'IgnoreOptions': ['MinValidity', 'ValidityPeriod',
'MinimumLifeTime',
'RenewedLifeTime']}),
('DIRAC.RequestManagementSystem.Agent.CleanReqDBAgent', {'IgnoreOptions': ['KickLimit', 'KickGraceHours',
'DeleteGraceDays']}),
('DIRAC.RequestManagementSystem.Agent.RequestExecutingAgent', {'IgnoreOptions': ['MaxProcess',
Expand Down
67 changes: 34 additions & 33 deletions FrameworkSystem/Agent/MyProxyRenewalAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,59 @@
from DIRAC.FrameworkSystem.DB.ProxyDB import ProxyDB
from DIRAC.Core.Utilities.ThreadPool import ThreadPool


class MyProxyRenewalAgent(AgentModule):

def initialize(self):

requiredLifeTime = self.am_getOption( "MinimumLifeTime", 3600 )
renewedLifeTime = self.am_getOption( "RenewedLifeTime", 54000 )
self.proxyDB = ProxyDB( useMyProxy = True )
requiredLifeTime = self.am_getOption("MinimumLifeTime", 3600)
renewedLifeTime = self.am_getOption("RenewedLifeTime", 54000)
self.proxyDB = ProxyDB(useMyProxy=True)

gLogger.info( "Minimum Life time : %s" % requiredLifeTime )
gLogger.info( "Life time on renew : %s" % renewedLifeTime )
gLogger.info( "MyProxy server : %s" % self.proxyDB.getMyProxyServer() )
gLogger.info( "MyProxy max proxy time : %s" % self.proxyDB.getMyProxyMaxLifeTime() )
gLogger.info("Minimum Life time : %s" % requiredLifeTime)
gLogger.info("Life time on renew : %s" % renewedLifeTime)
gLogger.info("MyProxy server : %s" % self.proxyDB.getMyProxyServer())
gLogger.info("MyProxy max proxy time : %s" % self.proxyDB.getMyProxyMaxLifeTime())

self.__threadPool = ThreadPool( 1, 10 )
self.__threadPool = ThreadPool(1, 10)
return S_OK()

def __renewProxyForCredentials( self, userDN, userGroup ):
lifeTime = self.am_getOption( "RenewedLifeTime", 54000 )
gLogger.info( "Renewing for %s@%s %s secs" % ( userDN, userGroup, lifeTime ) )
retVal = self.proxyDB.renewFromMyProxy( userDN,
userGroup,
lifeTime = lifeTime )
if not retVal[ 'OK' ]:
gLogger.error( "Failed to renew proxy", "for %s@%s : %s" %( userDN, userGroup, retVal[ 'Message' ] ) )
def __renewProxyForCredentials(self, userDN, userGroup):
lifeTime = self.am_getOption("RenewedLifeTime", 54000)
gLogger.info("Renewing for %s@%s %s secs" % (userDN, userGroup, lifeTime))
retVal = self.proxyDB.renewFromMyProxy(userDN,
userGroup,
lifeTime=lifeTime)
if not retVal['OK']:
gLogger.error("Failed to renew proxy", "for %s@%s : %s" % (userDN, userGroup, retVal['Message']))
else:
gLogger.info( "Renewed proxy for %s@%s" % ( userDN, userGroup ) )
gLogger.info("Renewed proxy for %s@%s" % (userDN, userGroup))

def __treatRenewalCallback( self, oTJ, exceptionList ):
gLogger.exception( lException = exceptionList )
def __treatRenewalCallback(self, oTJ, exceptionList):
gLogger.exception(lException=exceptionList)

def execute(self):
""" The main agent execution method
"""
self.proxyDB.purgeLogs()
gLogger.info( "Purging expired requests" )
gLogger.info("Purging expired requests")
retVal = self.proxyDB.purgeExpiredRequests()
if retVal[ 'OK' ]:
gLogger.info( " purged %s requests" % retVal[ 'Value' ] )
gLogger.info( "Purging expired proxies" )
if retVal['OK']:
gLogger.info(" purged %s requests" % retVal['Value'])
gLogger.info("Purging expired proxies")
retVal = self.proxyDB.purgeExpiredProxies()
if retVal[ 'OK' ]:
gLogger.info( " purged %s proxies" % retVal[ 'Value' ] )
retVal = self.proxyDB.getCredentialsAboutToExpire( self.am_getOption( "MinimumLifeTime" , 3600 ) )
if not retVal[ 'OK' ]:
if retVal['OK']:
gLogger.info(" purged %s proxies" % retVal['Value'])
retVal = self.proxyDB.getCredentialsAboutToExpire(self.am_getOption("MinimumLifeTime", 3600))
if not retVal['OK']:
return retVal
data = retVal[ 'Value' ]
gLogger.info( "Renewing %s proxies..." % len( data ) )
data = retVal['Value']
gLogger.info("Renewing %s proxies..." % len(data))
for record in data:
userDN = record[0]
userGroup = record[1]
self.__threadPool.generateJobAndQueueIt( self.__renewProxyForCredentials,
args = ( userDN, userGroup ),
oExceptionCallback = self.__treatRenewalCallback )
self.__threadPool.generateJobAndQueueIt(self.__renewProxyForCredentials,
args=(userDN, userGroup),
oExceptionCallback=self.__treatRenewalCallback)
self.__threadPool.processAllResults()
return S_OK()
return S_OK()
3 changes: 0 additions & 3 deletions FrameworkSystem/DB/ProxyDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@

__RCSID__ = "$Id$"

import os
import glob
import time
from six.moves.urllib.request import urlopen
import random
import hashlib
import commands

from DIRAC import gConfig, gLogger, S_OK, S_ERROR
from DIRAC.Core.Base.DB import DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
fieldLengths.append(len(param))

for record in records:
for i in range(len(record)):
for i, _ in enumerate(record):
if paramNames[i] in fieldsToShow:
fieldLengths[i] = max(fieldLengths[i], len(str(record[i])))
# Print time!
line = []
sepLine = []
for i in range(len(paramNames)):
for i, _ in enumerate(paramNames):
param = paramNames[i]
if param in fieldsToShow:
line.append("%s%s" % (param, " " * (fieldLengths[i] - len(param))))
Expand All @@ -41,9 +41,8 @@
print(sepLine)
for record in records:
line = []
for i in range(len(record)):
for i, _ in enumerate(record):
if paramNames[i] in fieldsToShow:
val = str(record[i])
line.append("%s%s" % (val, " " * (fieldLengths[i] - len(val))))
print("|".join(line))
# print sepLine
2 changes: 1 addition & 1 deletion tests/Jenkins/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function getCFGFile(){


####################################################
# This installs the DIRAC client
# This installs the DIRAC client, considering the alternative modules
# it needs a $DIRAC_RELEASE env var defined
# it also wants the env variables DIRACSETUP and CSURLS
#
Expand Down

0 comments on commit b48c11e

Please sign in to comment.