2017-10-24 19:16:36 +05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from django.shortcuts import render,redirect
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
# Create your views here.
|
|
|
|
|
import json
|
2018-08-28 01:19:34 +05:00
|
|
|
from websiteFunctions.models import dest, backupSchedules
|
2017-10-24 19:16:36 +05:00
|
|
|
import plogical.CyberCPLogFileWriter as logging
|
|
|
|
|
from loginSystem.views import loadLoginPage
|
|
|
|
|
import os
|
|
|
|
|
import time
|
|
|
|
|
import shlex
|
|
|
|
|
import subprocess
|
|
|
|
|
import requests
|
2017-11-05 03:02:51 +05:00
|
|
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
2017-12-09 22:30:10 +05:00
|
|
|
from random import randint
|
2018-05-11 00:03:26 +05:00
|
|
|
from plogical.mailUtilities import mailUtilities
|
2018-08-18 00:39:10 +05:00
|
|
|
from plogical.acl import ACLManager
|
2018-08-28 01:19:34 +05:00
|
|
|
from plogical.backupManager import BackupManager
|
2018-02-16 21:05:15 +05:00
|
|
|
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def loadBackupHome(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.loadBackupHome(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
def backupSite(request):
|
2017-10-24 19:16:36 +05:00
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.backupSite(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
def restoreSite(request):
|
2017-10-24 19:16:36 +05:00
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.restoreSite(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
|
|
|
|
def getCurrentBackups(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.getCurrentBackups(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def submitBackupCreation(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.submitBackupCreation(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def backupStatus(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.backupStatus(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def cancelBackupCreation(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.cancelBackupCreation(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def deleteBackup(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.deleteBackup(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def submitRestore(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.submitRestore(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def restoreStatus(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.restoreStatus(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def backupDestinations(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.backupDestinations(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
|
|
|
|
def submitDestinationCreation(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.submitDestinationCreation(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def getCurrentBackupDestinations(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.getCurrentBackupDestinations(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def getConnectionStatus(request):
|
|
|
|
|
try:
|
2018-08-28 01:19:34 +05:00
|
|
|
userID = request.session['userID']
|
|
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.getConnectionStatus(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def deleteDestination(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.deleteDestination(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def scheduleBackup(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.scheduleBackup(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
|
|
|
|
def getCurrentBackupSchedules(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.getCurrentBackupSchedules(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def submitBackupSchedule(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.submitBackupSchedule(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def scheduleDelete(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.scheduleDelete(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def remoteBackups(request):
|
|
|
|
|
try:
|
|
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
bm = BackupManager()
|
|
|
|
|
return bm.remoteBackups(request, userID)
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
|
|
|
|
|
|
|
|
|
def submitRemoteBackups(request):
|
|
|
|
|
try:
|
2018-06-30 15:29:56 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.submitRemoteBackups(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2017-10-26 23:50:59 +05:00
|
|
|
def starRemoteTransfer(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.starRemoteTransfer(userID, json.loads(request.body))
|
2017-10-26 23:50:59 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def getRemoteTransferStatus(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.getRemoteTransferStatus(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
|
|
|
|
def remoteBackupRestore(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.remoteBackupRestore(userID, json.loads(request.body))
|
2017-10-24 19:16:36 +05:00
|
|
|
except KeyError:
|
2018-08-28 01:19:34 +05:00
|
|
|
return redirect(loadLoginPage)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2017-10-26 23:50:59 +05:00
|
|
|
def localRestoreStatus(request):
|
2017-10-24 19:16:36 +05:00
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.localRestoreStatus(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|
2017-10-26 23:50:59 +05:00
|
|
|
|
|
|
|
|
def cancelRemoteBackup(request):
|
|
|
|
|
try:
|
2018-08-18 00:39:10 +05:00
|
|
|
userID = request.session['userID']
|
2018-08-28 01:19:34 +05:00
|
|
|
wm = BackupManager()
|
|
|
|
|
return wm.cancelRemoteBackup(userID, json.loads(request.body))
|
|
|
|
|
except KeyError:
|
|
|
|
|
return redirect(loadLoginPage)
|