Skip to content

Commit 6769e83

Browse files
committed
fix job success calculator
1 parent 7ef5fac commit 6769e83

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

install/firewallUtilities.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def doCommand(command):
2525

2626
@staticmethod
2727
def addRule(proto,port):
28+
29+
print('Adding port: %s' % (port))
30+
2831
if port == "21":
2932
command = "sudo firewall-cmd --add-service=ftp --permanent"
3033
else:
@@ -56,7 +59,6 @@ def addRule(proto,port):
5659

5760
@staticmethod
5861
def deleteRule(proto, port):
59-
print('Adding port: %s' % (port))
6062

6163
if port=="21":
6264
command = "sudo firewall-cmd --remove-service=ftp --permanent"

plogical/backupSchedule.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root')
216216

217217
backupSchedule.remoteBackupLogging(backupLogPath, "")
218218
backupSchedule.remoteBackupLogging(backupLogPath, "")
219+
return 1
219220
else:
220221

221222
backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) )
@@ -227,6 +228,7 @@ def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root')
227228

228229
backupSchedule.remoteBackupLogging(backupLogPath, "")
229230
backupSchedule.remoteBackupLogging(backupLogPath, "")
231+
return 0
230232

231233
except BaseException as msg:
232234
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@@ -332,8 +334,14 @@ def prepare():
332334

333335
for virtualHost in os.listdir("/home"):
334336
if match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', virtualHost, M | I):
335-
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user)
337+
if backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user):
338+
jobSuccessSites = jobSuccessSites + 1
339+
else:
340+
jobFailedSites = jobFailedSites + 1
336341

342+
backupSchedule.backupLog.jobFailedSites = jobFailedSites
343+
backupSchedule.backupLog.jobSuccessSites = jobSuccessSites
344+
backupSchedule.backupLog.save()
337345

338346
backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n")
339347

plogical/backupScheduleLocal.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def prepare():
6262

6363
if retValues[0] == 0:
6464
backupSchedule.remoteBackupLogging(backupLogPath, '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, retValues[1]), backupSchedule.ERROR)
65+
jobFailedSites = jobFailedSites + 1
6566
continue
6667

6768
if os.path.exists(backupScheduleLocal.localBackupPath):

0 commit comments

Comments
 (0)