Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v6r11] Fix for ProxyDB_logs table #1988

Merged
merged 8 commits into from
Jun 23, 2014
Merged
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
18 changes: 10 additions & 8 deletions DataManagementSystem/DB/DataLoggingDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DataLoggingDB( DB ):
Status VARCHAR(255) NOT NULL,
MinorStatus VARCHAR(255) NOT NULL DEFAULT 'Unknown',
StatusTime DATETIME,
StatusTimeOrder DOUBLE(11,3) NOT NULL,
StatusTimeOrder DOUBLE(12,3) NOT NULL,
Source VARCHAR(127) NOT NULL DEFAULT 'Unknown',
PRIMARY KEY (FileID),
INDEX (LFN)
Expand All @@ -55,7 +55,7 @@ class DataLoggingDB( DB ):
'Status': 'VARCHAR(255) NOT NULL',
'MinorStatus': 'VARCHAR(255) NOT NULL DEFAULT "Unknown" ',
'StatusTime':'DATETIME NOT NULL',
'StatusTimeOrder': 'DOUBLE(11,3) NOT NULL',
'StatusTimeOrder': 'DOUBLE(12,3) NOT NULL',
'Source': 'VARCHAR(127) NOT NULL DEFAULT "Unknown"',
},
'PrimaryKey': 'FileID',
Expand Down Expand Up @@ -108,22 +108,24 @@ def addFileRecord( self, lfns, status, minor = "Unknown", date = None, source =
:param str source: source setting the new status
"""
self.gLogger.info( "Entering records for %s lfns: %s/%s from source %s" % ( len( lfns ), status, minor, source ) )
_date = date
if not date:
_date = Time.dateTime()
if type( date ) in StringTypes:
_date = Time.fromString( date )
else:
if type( date ) in StringTypes:
_date = Time.fromString( date )
else:
_date = date

try:
time_order = Time.to2K( _date ) - NEW_MAGIC_EPOCH_2K
except AttributeError:
gLogger.error( 'Wrong date argument given using current time stamp' )
date = Time.dateTime()
time_order = Time.to2K( date ) - NEW_MAGIC_EPOCH_2K
dateNow = Time.dateTime()
time_order = Time.to2K( dateNow ) - NEW_MAGIC_EPOCH_2K

inDict = { 'Status': status,
'MinorStatus': minor,
'StatusTime': date,
'StatusTime': _date,
'StatusTimeOrder': time_order,
'Source': source
}
Expand Down
12 changes: 6 additions & 6 deletions FrameworkSystem/DB/ProxyDB.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
########################################################################
# $HeadURL$
########################################################################
""" ProxyRepository class is a front-end to the proxy repository Database
"""

Expand Down Expand Up @@ -95,13 +92,16 @@ def __initializeDB( self ):
}

if 'ProxyDB_Log' not in tablesInDB:
tablesD[ 'ProxyDB_Log' ] = { 'Fields' : { 'IssuerDN' : 'VARCHAR(255) NOT NULL',
tablesD[ 'ProxyDB_Log' ] = { 'Fields' : { 'ID': 'BIGINT NOT NULL AUTOINCREMENT',
'IssuerDN' : 'VARCHAR(255) NOT NULL',
'IssuerGroup' : 'VARCHAR(255) NOT NULL',
'TargetDN' : 'VARCHAR(255) NOT NULL',
'TargetGroup' : 'VARCHAR(255) NOT NULL',
'Action' : 'VARCHAR(128) NOT NULL',
'Timestamp' : 'DATETIME',
}
},
'PrimaryKey': 'ID',
'Indexes' : { 'Timestamp' : [ 'Timestamp' ]}
}

if 'ProxyDB_Tokens' not in tablesInDB:
Expand Down Expand Up @@ -854,7 +854,7 @@ def purgeLogs( self ):
"""
Purge expired requests from the db
"""
cmd = "DELETE FROM `ProxyDB_Log` WHERE TIMESTAMPDIFF( SECOND, UTC_TIMESTAMP(), ExpirationTime ) > 15552000"
cmd = "DELETE FROM `ProxyDB_Log` WHERE TIMESTAMPDIFF( SECOND, Timestamp, UTC_TIMESTAMP() ) > 15552000"
return self._update( cmd )

def getLogsContent( self, selDict, sortList, start = 0, limit = 0 ):
Expand Down
15 changes: 5 additions & 10 deletions FrameworkSystem/Service/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
########################################################################
# $HeadURL$
########################################################################

""" ProxyManager is the implementation of the ProxyManagement service
in the DISET framework
"""
Expand All @@ -10,11 +6,10 @@

import types
from DIRAC.Core.DISET.RequestHandler import RequestHandler
from DIRAC import gLogger, S_OK, S_ERROR, gConfig
from DIRAC import gLogger, S_OK, S_ERROR
from DIRAC.FrameworkSystem.DB.ProxyDB import ProxyDB
from DIRAC.Core.Security import Properties, CS
from DIRAC.Core.Security import Properties
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.Core.Security.VOMS import VOMS
from DIRAC.Core.Utilities.ThreadScheduler import gThreadScheduler

class ProxyManagerHandler( RequestHandler ):
Expand All @@ -31,7 +26,7 @@ def initializeHandler( cls, serviceInfoDict ):
return S_ERROR( "Can't connect to ProxyDB: %s" % excp )
gThreadScheduler.addPeriodicTask( 900, cls.__proxyDB.purgeExpiredTokens, elapsedTime = 900 )
gThreadScheduler.addPeriodicTask( 900, cls.__proxyDB.purgeExpiredRequests, elapsedTime = 900 )
gThreadScheduler.addPeriodicTask( 3600, cls.__proxyDB.purgeLogs )
gThreadScheduler.addPeriodicTask( 21600, cls.__proxyDB.purgeLogs )
gThreadScheduler.addPeriodicTask( 3600, cls.__proxyDB.purgeExpiredProxies )
gLogger.info( "MyProxy: %s\n MyProxy Server: %s" % ( useMyProxy, cls.__proxyDB.getMyProxyServer() ) )
return S_OK()
Expand Down Expand Up @@ -223,7 +218,7 @@ def __getVOMSProxy( self, userDN, userGroup, requestPem, requiredLifetime, vomsA
requireLimited = forceLimited )
if not retVal[ 'OK' ]:
return retVal
credDict = self.getRemoteCredentials()
_credDict = self.getRemoteCredentials()
return S_OK( retVal[ 'Value' ] )

types_setPersistency = [ types.StringType, types.StringType, types.BooleanType ]
Expand All @@ -249,7 +244,7 @@ def export_deleteProxyBundle( self, idList ):
"""
errorInDelete = []
deleted = 0
for id in idList:
for _id in idList:
if len( id ) != 2:
errorInDelete.append( "%s doesn't have two fields" % str( id ) )
retVal = self.export_deleteProxy( id[0], id[1] )
Expand Down