Commit 08b37a4d authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added hours and minutes as parameters in config file + minor changes to cleaner.py.

parent b2ef1e08
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -17,12 +17,16 @@ dbConn = DbConnector(params["user"],
                     1,
                     1)
params = config.loadSection("cleanup")
maxDays = params.getint("max_days")
maxSeconds = params.getint("max_seconds")
days = params.getint("days")
seconds = params.getint("hours") * 3600 + params.getint("minutes") * 60 + params.getint("seconds")

if maxDays <= 0 and maxSeconds < 30:
    maxDays = 0
    maxSeconds = 30
# Avoid "all zero" condition
if days <= 0 and seconds < 30:
    days = 0
    seconds = 30
elif seconds >= 86400:
    days += seconds // 86400
    seconds = seconds % 86400

fileList = dbConn.getNodesToBeDeleted()
basePaths = []
@@ -35,7 +39,7 @@ for row in fileList:
    phyDeletedTstamp = row["phy_deleted_on"]
    nodeId = row["node_id"]
    delta = cTime - dTime
    if delta.days >= maxDays and delta.seconds > maxSeconds and phyDeletedTstamp is None:                
    if delta.days >= days and delta.seconds > seconds and phyDeletedTstamp is None:                
        os.remove(filePath)
        print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' ' + filePath)
        dbConn.setPhyDeletedOn(nodeId)
+6 −4
Original line number Diff line number Diff line
@@ -71,10 +71,12 @@ max_terminated_jobs = 8
exec_wait_time = 15

[cleanup]
; Physically delete from disk all nodes previously deleted by the user via ui
; 'max_days' days and 'max_seconds' seconds ago (if any)
max_days = 0
max_seconds = 30
; Physically delete from disk all nodes previously deleted by the user via ui,
; that are older than a given amount of time specified here below
days = 0
hours = 0
minutes = 1
seconds = 30


####################