mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 15:17:22 +02:00
push changes
This commit is contained in:
191
CLManager/CLManagerMain.py
Normal file
191
CLManager/CLManagerMain.py
Normal file
@@ -0,0 +1,191 @@
|
||||
import threading as multi
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from django.shortcuts import render
|
||||
import os
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
import json
|
||||
from django.shortcuts import HttpResponse
|
||||
from math import ceil
|
||||
from websiteFunctions.models import Websites
|
||||
from .models import CLPackages
|
||||
|
||||
|
||||
class CLManagerMain(multi.Thread):
|
||||
|
||||
def __init__(self, request=None, templateName=None, function=None, data=None):
|
||||
multi.Thread.__init__(self)
|
||||
self.request = request
|
||||
self.templateName = templateName
|
||||
self.function = function
|
||||
self.data = data
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.function == 'submitCageFSInstall':
|
||||
self.submitCageFSInstall()
|
||||
elif self.function == 'enableOrDisable':
|
||||
self.enableOrDisable()
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]')
|
||||
|
||||
def renderC(self):
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = {}
|
||||
data['CL'] = 0
|
||||
data['CAGEFS'] = 0
|
||||
CLPath = '/etc/sysconfig/cloudlinux'
|
||||
CageFSPath = '/usr/sbin/cagefsctl'
|
||||
|
||||
if os.path.exists(CLPath):
|
||||
data['CL'] = 1
|
||||
|
||||
if os.path.exists(CageFSPath):
|
||||
data['CAGEFS'] = 1
|
||||
|
||||
if data['CL'] == 0:
|
||||
return render(self.request, 'CLManager/notAvailable.html', data)
|
||||
elif data['CAGEFS'] == 0:
|
||||
return render(self.request, 'CLManager/notAvailable.html', data)
|
||||
else:
|
||||
return render(self.request, self.templateName, self.data)
|
||||
|
||||
def submitCageFSInstall(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Not authorized to install container packages. [404].',
|
||||
1)
|
||||
return 0
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/CLManager/CageFS.py"
|
||||
execPath = execPath + " --function submitCageFSInstall"
|
||||
ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def findWebsitesJson(self, currentACL, userID, pageNumber):
|
||||
finalPageNumber = ((pageNumber * 10)) - 10
|
||||
endPageNumber = finalPageNumber + 10
|
||||
websites = ACLManager.findWebsiteObjects(currentACL, userID)[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
command = '/usr/sbin/cagefsctl --list-enabled'
|
||||
Enabled = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
for items in websites:
|
||||
if Enabled.find(items.externalApp) > -1:
|
||||
status = 1
|
||||
else:
|
||||
status = 0
|
||||
dic = {'domain': items.domain, 'externalApp': items.externalApp, 'status': status}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
return json_data
|
||||
|
||||
def websitePagination(self, currentACL, userID):
|
||||
websites = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
pages = float(len(websites)) / float(10)
|
||||
pagination = []
|
||||
|
||||
if pages <= 1.0:
|
||||
pages = 1
|
||||
pagination.append('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
return pagination
|
||||
|
||||
def getFurtherAccounts(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
pageNumber = int(data['page'])
|
||||
json_data = self.findWebsitesJson(currentACL, userID, pageNumber)
|
||||
pagination = self.websitePagination(currentACL, userID)
|
||||
|
||||
cageFSPath = '/home/cyberpanel/cagefs'
|
||||
|
||||
if os.path.exists(cageFSPath):
|
||||
default = 'On'
|
||||
else:
|
||||
default = 'Off'
|
||||
|
||||
final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data,
|
||||
'pagination': pagination, 'default': default}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
except BaseException, msg:
|
||||
dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def enableOrDisable(self):
|
||||
try:
|
||||
websites = Websites.objects.all()
|
||||
if self.data['mode'] == 1:
|
||||
for items in websites:
|
||||
command = '/usr/sbin/cagefsctl --enable %s' % (items.externalApp)
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
for items in websites:
|
||||
command = '/usr/sbin/cagefsctl --disable %s' % (items.externalApp)
|
||||
ProcessUtilities.executioner(command)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
def fetchPackages(self, currentACL):
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
for items in CLPackages.objects.all():
|
||||
dic = {'name': items.name, 'SPEED': items.speed, 'VMEM': items.vmem, 'PMEM': items.pmem, 'IO': items.io, 'IOPS': items.iops, 'EP': items.ep,
|
||||
'NPROC': items.nproc, 'inodessoft': items.inodessoft, 'inodeshard': items.inodeshard}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
final_dic = {'status': 1, 'error_message': "None", "data": json_data}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
82
CLManager/CLPackages.py
Normal file
82
CLManager/CLPackages.py
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
import argparse
|
||||
from websiteFunctions.models import Websites
|
||||
from CLManager.models import CLPackages
|
||||
import pwd
|
||||
|
||||
class CLinuxPackages:
|
||||
|
||||
@staticmethod
|
||||
def listAll():
|
||||
for items in Websites.objects.all():
|
||||
itemPackage = items.package
|
||||
try:
|
||||
clPackage = CLPackages.objects.get(owner=itemPackage)
|
||||
statement = '%s %s' % (pwd.getpwnam(items.externalApp).pw_uid, clPackage.name)
|
||||
print statement
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@staticmethod
|
||||
def listPackages():
|
||||
for items in CLPackages.objects.all():
|
||||
print items.name
|
||||
|
||||
@staticmethod
|
||||
def userIDPackage(user):
|
||||
website = Websites.objects.get(externalApp=user)
|
||||
itemPackage = website.package
|
||||
try:
|
||||
clPackage = CLPackages.objects.get(owner=itemPackage)
|
||||
print clPackage
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@staticmethod
|
||||
def packageForUser(package):
|
||||
for items in Websites.objects.all():
|
||||
itemPackage = items.package
|
||||
try:
|
||||
clPackage = CLPackages.objects.get(owner=itemPackage)
|
||||
if clPackage.name == package:
|
||||
print pwd.getpwnam(items.externalApp).pw_uid
|
||||
except:
|
||||
pass
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Container Manager')
|
||||
parser.add_argument('--userid', help='User ID')
|
||||
parser.add_argument('--package', help='Package')
|
||||
parser.add_argument('--function', help='Function')
|
||||
parser.add_argument('--list-all', help='List all users/packages.', action='store_true')
|
||||
parser.add_argument('--list-packages', help='List all packages.', action='store_true')
|
||||
|
||||
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
if args['userid']:
|
||||
CLinuxPackages.userIDPackage(args['userid'])
|
||||
elif args['package']:
|
||||
CLinuxPackages.packageForUser(args['package'])
|
||||
elif args['list_all']:
|
||||
CLinuxPackages.listAll()
|
||||
elif args['list_packages']:
|
||||
CLinuxPackages.listPackages()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
60
CLManager/CageFS.py
Normal file
60
CLManager/CageFS.py
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
import argparse
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
|
||||
class CageFS:
|
||||
packages = ['talksho']
|
||||
users = ['5001']
|
||||
|
||||
@staticmethod
|
||||
def submitCageFSInstall():
|
||||
try:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Packages Installation..\n", 1)
|
||||
|
||||
command = 'sudo yum install cagefs -y'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo /usr/sbin/cagefsctl --init'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo /usr/sbin/cagefsctl --update-etc'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo /usr/sbin/cagefsctl --force-update'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Packages successfully installed.[200]\n", 1)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel CageFS Manager')
|
||||
parser.add_argument('--function', help='Function')
|
||||
|
||||
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
if args["function"] == "submitCageFSInstall":
|
||||
CageFS.submitCageFSInstall()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
0
CLManager/__init__.py
Normal file
0
CLManager/__init__.py
Normal file
6
CLManager/admin.py
Normal file
6
CLManager/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
8
CLManager/apps.py
Normal file
8
CLManager/apps.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ClmanagerConfig(AppConfig):
|
||||
name = 'CLManager'
|
||||
0
CLManager/migrations/__init__.py
Normal file
0
CLManager/migrations/__init__.py
Normal file
20
CLManager/models.py
Normal file
20
CLManager/models.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from packages.models import Package
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class CLPackages(models.Model):
|
||||
owner = models.ForeignKey(Package)
|
||||
name = models.CharField(max_length=50,unique=True)
|
||||
speed = models.CharField(max_length=50)
|
||||
vmem = models.CharField(max_length=50)
|
||||
pmem = models.CharField(max_length=50)
|
||||
io = models.CharField(max_length=50)
|
||||
iops = models.CharField(max_length=50)
|
||||
ep = models.CharField(max_length=50)
|
||||
nproc = models.CharField(max_length=50)
|
||||
inodessoft = models.CharField(max_length=50)
|
||||
inodeshard = models.CharField(max_length=50)
|
||||
934
CLManager/static/CLManager/CLManager.js
Normal file
934
CLManager/static/CLManager/CLManager.js
Normal file
@@ -0,0 +1,934 @@
|
||||
app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.installDockerStatus = true;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = false;
|
||||
|
||||
$scope.submitCageFSInstall = function () {
|
||||
|
||||
$scope.installDockerStatus = false;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = true;
|
||||
|
||||
url = "/CloudLinux/submitCageFSInstall";
|
||||
|
||||
var data = {};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.cyberPanelLoading = true;
|
||||
$timeout.cancel();
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
if (response.data.installed === 1) {
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
app.controller('listWebsitesCage', function ($scope, $http) {
|
||||
|
||||
var globalPageNumber;
|
||||
$scope.getFurtherWebsitesFromDB = function (pageNumber) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
globalPageNumber = pageNumber;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {page: pageNumber};
|
||||
|
||||
|
||||
dataurl = "/CloudLinux/submitWebsiteListing";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.listWebSiteStatus === 1) {
|
||||
var finalData = JSON.parse(response.data.data);
|
||||
$scope.WebSitesList = finalData;
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.default = response.data.default;
|
||||
$("#listFail").hide();
|
||||
} else {
|
||||
$("#listFail").fadeIn();
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
console.log(response.data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
console.log("not good");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.getFurtherWebsitesFromDB(1);
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
|
||||
$scope.searchWebsites = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
patternAdded: $scope.patternAdded
|
||||
};
|
||||
|
||||
dataurl = "/websites/searchWebsites";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.listWebSiteStatus === 1) {
|
||||
|
||||
var finalData = JSON.parse(response.data.data);
|
||||
$scope.WebSitesList = finalData;
|
||||
$("#listFail").hide();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Connect disrupted, refresh the page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.enableOrDisable = function (domain, all, mode, toggle = 0) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/CloudLinux/enableOrDisable";
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
all: all,
|
||||
mode: mode,
|
||||
toggle: toggle
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: response.data.success,
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
if (all === 0) {
|
||||
$scope.getFurtherWebsitesFromDB(globalPageNumber);
|
||||
}
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.refreshStatus = function () {
|
||||
$scope.getFurtherWebsitesFromDB(globalPageNumber);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.controller('createCLPackage', function ($scope, $http) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.modifyPackageForm = true;
|
||||
$scope.toggleView = function () {
|
||||
$scope.modifyPackageForm = false;
|
||||
};
|
||||
|
||||
$scope.createPackage = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/CloudLinux/submitCreatePackage";
|
||||
|
||||
var data = {
|
||||
selectedPackage: $scope.selectedPackage,
|
||||
name: $scope.name,
|
||||
SPEED: $scope.SPEED,
|
||||
VMEM: $scope.VMEM,
|
||||
PMEM: $scope.PMEM,
|
||||
IO: $scope.IO,
|
||||
IOPS: $scope.IOPS,
|
||||
EP: $scope.EP,
|
||||
NPROC: $scope.NPROC,
|
||||
INODESsoft: $scope.INODESsoft,
|
||||
INODEShard: $scope.INODEShard,
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully created.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
app.controller('listCloudLinuxPackages', function ($scope, $http) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
|
||||
$scope.fetchPackageas = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {};
|
||||
|
||||
|
||||
dataurl = "/CloudLinux/fetchPackages";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.packages = JSON.parse(response.data.data);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.fetchPackageas();
|
||||
|
||||
$scope.deleteCLPackage = function (name) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/CloudLinux/deleteCLPackage";
|
||||
|
||||
var data = {
|
||||
name: name
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully deleted.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchPackageas();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
$scope.populatePackage = function (name, speed, vmem, pmem, io, iops, ep, nproc, inodessoft, inodeshard) {
|
||||
$scope.name = name;
|
||||
$scope.SPEED = speed;
|
||||
$scope.VMEM = vmem;
|
||||
$scope.PMEM = pmem;
|
||||
$scope.IO = io;
|
||||
$scope.IOPS = iops;
|
||||
$scope.EP = ep;
|
||||
$scope.NPROC = nproc;
|
||||
$scope.inodessoft = inodessoft;
|
||||
$scope.inodeshard = inodeshard;
|
||||
|
||||
};
|
||||
|
||||
$scope.saveSettings = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/CloudLinux/saveSettings";
|
||||
|
||||
var data = {
|
||||
name: $scope.name,
|
||||
SPEED: $scope.SPEED,
|
||||
VMEM: $scope.VMEM,
|
||||
PMEM: $scope.PMEM,
|
||||
IO: $scope.IO,
|
||||
IOPS: $scope.IOPS,
|
||||
EP: $scope.EP,
|
||||
NPROC: $scope.NPROC,
|
||||
INODESsoft: $scope.inodessoft,
|
||||
INODEShard: $scope.inodeshard,
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes successfully applied.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchPackageas();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('websiteContainerLimitCL', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
|
||||
// Get CPU Usage of User
|
||||
|
||||
var cpu = [];
|
||||
var dataset;
|
||||
var totalPoints = 100;
|
||||
var updateInterval = 1000;
|
||||
var now = new Date().getTime();
|
||||
|
||||
var options = {
|
||||
series: {
|
||||
lines: {
|
||||
lineWidth: 1.2
|
||||
},
|
||||
bars: {
|
||||
align: "center",
|
||||
fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
|
||||
barWidth: 500,
|
||||
lineWidth: 1
|
||||
}
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
tickSize: [5, "second"],
|
||||
tickFormatter: function (v, axis) {
|
||||
var date = new Date(v);
|
||||
|
||||
if (date.getSeconds() % 20 == 0) {
|
||||
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "Time",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 10
|
||||
},
|
||||
yaxes: [
|
||||
{
|
||||
min: 0,
|
||||
max: 100,
|
||||
tickSize: 5,
|
||||
tickFormatter: function (v, axis) {
|
||||
if (v % 10 == 0) {
|
||||
return v + "%";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "CPU loading",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}, {
|
||||
max: 5120,
|
||||
position: "right",
|
||||
axisLabel: "Disk",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}
|
||||
],
|
||||
legend: {
|
||||
noColumns: 0,
|
||||
position: "nw"
|
||||
},
|
||||
grid: {
|
||||
backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
|
||||
}
|
||||
};
|
||||
|
||||
function initData() {
|
||||
for (var i = 0; i < totalPoints; i++) {
|
||||
var temp = [now += updateInterval, 0];
|
||||
|
||||
cpu.push(temp);
|
||||
}
|
||||
}
|
||||
|
||||
function GetData() {
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text()
|
||||
};
|
||||
$.ajaxSetup({cache: false});
|
||||
|
||||
$.ajax({
|
||||
url: "/CloudLinux/getUsageData",
|
||||
dataType: 'json',
|
||||
success: update,
|
||||
type: "POST",
|
||||
headers: {'X-CSRFToken': getCookie('csrftoken')},
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data), // Our valid JSON string
|
||||
error: function () {
|
||||
setTimeout(GetData, updateInterval);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var temp;
|
||||
|
||||
function update(_data) {
|
||||
cpu.shift();
|
||||
|
||||
now += updateInterval;
|
||||
|
||||
temp = [now, _data.cpu];
|
||||
cpu.push(temp);
|
||||
|
||||
|
||||
dataset = [
|
||||
{label: "CPU:" + _data.cpu + "%", data: cpu, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
|
||||
];
|
||||
|
||||
$.plot($("#flot-placeholder1"), dataset, options);
|
||||
setTimeout(GetData, updateInterval);
|
||||
}
|
||||
|
||||
// Memory Usage of User
|
||||
|
||||
var memory = [];
|
||||
var datasetMemory;
|
||||
var totalPointsMemory = 100;
|
||||
var updateIntervalMemory = 1000;
|
||||
var nowMemory = new Date().getTime();
|
||||
|
||||
var optionsMemory = {
|
||||
series: {
|
||||
lines: {
|
||||
lineWidth: 1.2
|
||||
},
|
||||
bars: {
|
||||
align: "center",
|
||||
fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
|
||||
barWidth: 500,
|
||||
lineWidth: 1
|
||||
}
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
tickSize: [5, "second"],
|
||||
tickFormatter: function (v, axis) {
|
||||
var date = new Date(v);
|
||||
|
||||
if (date.getSeconds() % 20 == 0) {
|
||||
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "Time",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 10
|
||||
},
|
||||
yaxes: [
|
||||
{
|
||||
min: 0,
|
||||
max: $scope.memory,
|
||||
tickSize: 5,
|
||||
tickFormatter: function (v, axis) {
|
||||
if (v % 10 == 0) {
|
||||
return v + "MB";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "CPU loading",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}, {
|
||||
max: 5120,
|
||||
position: "right",
|
||||
axisLabel: "Disk",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}
|
||||
],
|
||||
legend: {
|
||||
noColumns: 0,
|
||||
position: "nw"
|
||||
},
|
||||
grid: {
|
||||
backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
|
||||
}
|
||||
};
|
||||
|
||||
function initDataMemory() {
|
||||
for (var i = 0; i < totalPointsMemory; i++) {
|
||||
var temp = [nowMemory += updateIntervalMemory, 0];
|
||||
|
||||
memory.push(temp);
|
||||
}
|
||||
}
|
||||
|
||||
function GetDataMemory() {
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
type: 'memory'
|
||||
};
|
||||
$.ajaxSetup({cache: false});
|
||||
|
||||
$.ajax({
|
||||
url: "/CloudLinux/getUsageData",
|
||||
dataType: 'json',
|
||||
headers: {'X-CSRFToken': getCookie('csrftoken')},
|
||||
success: updateMemory,
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data), // Our valid JSON string
|
||||
error: function () {
|
||||
setTimeout(GetDataMemory, updateIntervalMemory);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tempMemory;
|
||||
|
||||
function updateMemory(_data) {
|
||||
memory.shift();
|
||||
|
||||
nowMemory += updateIntervalMemory;
|
||||
|
||||
tempMemory = [nowMemory, _data.memory];
|
||||
memory.push(tempMemory);
|
||||
|
||||
|
||||
datasetMemory = [
|
||||
{
|
||||
label: "Memory:" + _data.memory + "MB",
|
||||
data: memory,
|
||||
lines: {fill: true, lineWidth: 1.2},
|
||||
color: "#00FF00"
|
||||
}
|
||||
];
|
||||
|
||||
$.plot($("#memoryUsage"), datasetMemory, optionsMemory);
|
||||
setTimeout(GetDataMemory, updateIntervalMemory);
|
||||
}
|
||||
|
||||
// Disk Usage
|
||||
|
||||
var readRate = [], writeRate = [];
|
||||
var datasetDisk;
|
||||
var totalPointsDisk = 100;
|
||||
var updateIntervalDisk = 5000;
|
||||
var now = new Date().getTime();
|
||||
|
||||
var optionsDisk = {
|
||||
series: {
|
||||
lines: {
|
||||
lineWidth: 1.2
|
||||
},
|
||||
bars: {
|
||||
align: "center",
|
||||
fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
|
||||
barWidth: 500,
|
||||
lineWidth: 1
|
||||
}
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
tickSize: [30, "second"],
|
||||
tickFormatter: function (v, axis) {
|
||||
var date = new Date(v);
|
||||
|
||||
if (date.getSeconds() % 20 == 0) {
|
||||
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "Time",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 10
|
||||
},
|
||||
yaxes: [
|
||||
{
|
||||
min: 0,
|
||||
max: $scope.networkSpeed,
|
||||
tickSize: 5,
|
||||
tickFormatter: function (v, axis) {
|
||||
if (v % 10 == 0) {
|
||||
return v + "mb/sec";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
axisLabel: "CPU loading",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}, {
|
||||
max: 5120,
|
||||
position: "right",
|
||||
axisLabel: "Disk",
|
||||
axisLabelUseCanvas: true,
|
||||
axisLabelFontSizePixels: 12,
|
||||
axisLabelFontFamily: 'Verdana, Arial',
|
||||
axisLabelPadding: 6
|
||||
}
|
||||
],
|
||||
legend: {
|
||||
noColumns: 0,
|
||||
position: "nw"
|
||||
},
|
||||
grid: {
|
||||
backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
|
||||
}
|
||||
};
|
||||
|
||||
function initDataDisk() {
|
||||
for (var i = 0; i < totalPointsDisk; i++) {
|
||||
var temp = [now += updateIntervalDisk, 0];
|
||||
|
||||
readRate.push(temp);
|
||||
writeRate.push(temp);
|
||||
}
|
||||
}
|
||||
|
||||
function GetDataDisk() {
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
type: 'io'
|
||||
};
|
||||
|
||||
$.ajaxSetup({cache: false});
|
||||
|
||||
$.ajax({
|
||||
url: "/CloudLinux/getUsageData",
|
||||
dataType: 'json',
|
||||
headers: {'X-CSRFToken': getCookie('csrftoken')},
|
||||
success: updateDisk,
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data), // Our valid JSON string
|
||||
error: function () {
|
||||
setTimeout(GetDataMemory, updateIntervalMemory);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tempDisk;
|
||||
|
||||
function updateDisk(_data) {
|
||||
readRate.shift();
|
||||
writeRate.shift();
|
||||
|
||||
now += updateIntervalDisk;
|
||||
|
||||
tempDisk = [now, _data.readRate];
|
||||
readRate.push(tempDisk);
|
||||
|
||||
tempDisk = [now, _data.readRate];
|
||||
writeRate.push(tempDisk);
|
||||
|
||||
datasetDisk = [
|
||||
{
|
||||
label: "Read IO/s " + _data.readRate + " mb/s ",
|
||||
data: readRate,
|
||||
lines: {fill: true, lineWidth: 1.2},
|
||||
color: "#00FF00"
|
||||
},
|
||||
{
|
||||
label: "Write IO/s " + _data.writeRate + " mb/s ",
|
||||
data: writeRate,
|
||||
lines: {lineWidth: 1.2},
|
||||
color: "#FF0000"
|
||||
}
|
||||
];
|
||||
|
||||
$.plot($("#diskUsage"), datasetDisk, optionsDisk);
|
||||
setTimeout(GetDataDisk, updateIntervalDisk);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Report Memory Usage
|
||||
|
||||
initDataMemory();
|
||||
|
||||
datasetMemory = [
|
||||
{label: "Memory", data: memory, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
|
||||
];
|
||||
|
||||
$.plot($("#memoryUsage"), datasetMemory, optionsMemory);
|
||||
setTimeout(GetDataMemory, updateIntervalMemory);
|
||||
|
||||
// Report CPU Usage
|
||||
|
||||
initData();
|
||||
|
||||
dataset = [
|
||||
{label: "CPU", data: cpu, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
|
||||
];
|
||||
|
||||
$.plot($("#flot-placeholder1"), dataset, options);
|
||||
setTimeout(GetData, updateInterval);
|
||||
|
||||
// Report Disk Usage
|
||||
|
||||
initDataDisk();
|
||||
|
||||
datasetDisk = [
|
||||
{label: "Read IO/s: ", data: readRate, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"},
|
||||
{label: "Write IO/s: ", data: writeRate, color: "#0044FF", bars: {show: true}, yaxis: 2}
|
||||
];
|
||||
|
||||
$.plot($("#diskUsage"), datasetDisk, optionsDisk);
|
||||
setTimeout(GetDataDisk, updateIntervalDisk);
|
||||
});
|
||||
});
|
||||
146
CLManager/templates/CLManager/createPackage.html
Normal file
146
CLManager/templates/CLManager/createPackage.html
Normal file
@@ -0,0 +1,146 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create Cloud Linux Package - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create CloudLinux Package." %}</h2>
|
||||
<p>{% trans "Each CloudLinux package have one associated (owner) CyberPanel package. During website creation associated CloudLinux package will be assigned to website user." %}</p>
|
||||
</div>
|
||||
<div ng-controller="createCLPackage" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Create Package" %} <img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Package" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="toggleView()" ng-model="selectedPackage" class="form-control">
|
||||
{% for items in packList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
<div ng-hide="modifyPackageForm">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Package Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="name" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "SPEED" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="SPEED" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 100%</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "VMEM" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="VMEM" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 256m or 1G</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "PMEM" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="PMEM" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 256m or 1G</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IO" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="IO" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 1024</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IOPS" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="IOPS" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 1024</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "EP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="EP" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 10</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "NPROC" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="NPROC" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 10</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "INODES soft" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="INODESsoft" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 1024</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "INODES hard" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="INODEShard" required>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Ex 1024</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
|
||||
<div ng-hide="modifyPackageForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createPackage()"
|
||||
class="btn btn-primary btn-lg ">{% trans "Create Package" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
236
CLManager/templates/CLManager/listPackages.html
Normal file
236
CLManager/templates/CLManager/listPackages.html
Normal file
@@ -0,0 +1,236 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Manage CloudLinux Packages - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div ng-controller="listCloudLinuxPackages" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "Manage CloudLinux Packages" %}</h2>
|
||||
<p>{% trans "Manage/Delete CloudLinux Packages." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered"
|
||||
id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name<img ng-hide="cyberPanelLoading" src="/static/images/loading.gif"></th>
|
||||
<th>SPEED</th>
|
||||
<th>VMEM</th>
|
||||
<th>PMEM</th>
|
||||
<th>IO</th>
|
||||
<th>IOPS</th>
|
||||
<th>EP</th>
|
||||
<th>NPROC</th>
|
||||
<th>INODES soft</th>
|
||||
<th>INODES hard</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="pack in packages track by $index">
|
||||
<td ng-bind="pack.name"></td>
|
||||
<td ng-bind="pack.SPEED"></td>
|
||||
<td ng-bind="pack.VMEM"></td>
|
||||
<td ng-bind="pack.PMEM"></td>
|
||||
<td ng-bind="pack.IO"></td>
|
||||
<td ng-bind="pack.IOPS"></td>
|
||||
<td ng-bind="pack.EP"></td>
|
||||
<td ng-bind="pack.NPROC"></td>
|
||||
<td ng-bind="pack.inodessoft"></td>
|
||||
<td ng-bind="pack.inodeshard"></td>
|
||||
<td>
|
||||
<a ng-click='deleteCLPackage(pack.name)'
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>Delete</span></a>
|
||||
<a ng-click="populatePackage(pack.name, pack.SPEED, pack.VMEM, pack.PMEM, pack.IO, pack.IOPS, pack.EP, pack.NPROC, pack.inodessoft, pack.inodeshard)" data-toggle="modal" data-target="#settings" ng-click='deleteCLPackage()'
|
||||
class="btn btn-border btn-alt border-green btn-link font-green"
|
||||
title=""><span>Edit</span></a>
|
||||
<div id="settings" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">Edit Package
|
||||
<img id="containerSettingLoading" src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="name" type="text" class="form-control"
|
||||
ng-model="name" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "SPEED" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="SPEED" type="text" class="form-control"
|
||||
ng-model="$parent.SPEED" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "VMEM" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="VMEM" type="text" class="form-control"
|
||||
ng-model="$parent.VMEM" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "PMEM" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="PMEM" type="text" class="form-control"
|
||||
ng-model="$parent.PMEM" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IO" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="IO" type="text" class="form-control"
|
||||
ng-model="$parent.IO" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IOPS" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="IOPS" type="text" class="form-control"
|
||||
ng-model="$parent.IOPS" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "EP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="EP" type="text" class="form-control"
|
||||
ng-model="$parent.EP" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "NPROC" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="NPROC" type="text" class="form-control"
|
||||
ng-model="$parent.NPROC" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "INODES soft" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="inodessoft" type="text" class="form-control"
|
||||
ng-model="$parent.inodessoft" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "INODES hard" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="inodeshard" type="text" class="form-control"
|
||||
ng-model="$parent.inodeshard" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-primary"
|
||||
ng-click="saveSettings()" data-dismiss="modal">Save
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
<li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)"
|
||||
id="webPages"><a
|
||||
href="">{$ $index + 1 $}</a></li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
117
CLManager/templates/CLManager/listWebsites.html
Normal file
117
CLManager/templates/CLManager/listWebsites.html
Normal file
@@ -0,0 +1,117 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "CageFS - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div ng-controller="listWebsitesCage" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "List Websites" %}</h2>
|
||||
<p>{% trans "Enable/Disable and view CageFS status for websites." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<div style="padding-bottom: 0px; padding-top: 15px;" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div class="content-box remove-border clearfix text-center">
|
||||
|
||||
<a class="btn btn-primary" href="#" title="">
|
||||
<span>{% trans "Default: " %}
|
||||
<b>{$ default $}</b></span>
|
||||
</a>
|
||||
|
||||
<a href="#" ng-click="enableOrDisable(0, 0, 0, 1)"
|
||||
class="btn btn-border btn-alt border-green btn-link font-green"
|
||||
title=""><span>Toggle Default</span></a>
|
||||
|
||||
|
||||
<a href="#" ng-click="enableOrDisable(0, 1, 1, 0)" class="btn btn-success" title="Enable All">
|
||||
|
||||
<i class="fa fa-play btn-icon"></i>
|
||||
</a>
|
||||
<a href="#" ng-click="enableOrDisable(0, 1, 0, 0)" class="btn btn-warning" title="Disable All">
|
||||
|
||||
<i class="fa fa-pause btn-icon"></i>
|
||||
</a>
|
||||
|
||||
<a href="#" ng-click="refreshStatus()" class="btn btn-info" title="Refresh Status">
|
||||
<i class="fa fa-refresh btn-icon"></i>
|
||||
</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered"
|
||||
id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Domain <img ng-hide="cyberPanelLoading" src="/static/images/loading.gif"></th>
|
||||
<th>User</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="web in WebSitesList track by $index">
|
||||
<td ng-bind="web.domain"></td>
|
||||
<td ng-bind="web.externalApp"></td>
|
||||
<td>
|
||||
<a ng-click="enableOrDisable(web.domain, 0, 0, 0)" ng-hide="web.status==0"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>Disable</span></a>
|
||||
<a ng-click="enableOrDisable(web.domain, 0, 1, 0)" ng-hide="web.status==1"
|
||||
class="btn btn-border btn-alt border-green btn-link font-green"
|
||||
title=""><span>Enable</span></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
<li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)"
|
||||
id="webPages"><a
|
||||
href="">{$ $index + 1 $}</a></li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
87
CLManager/templates/CLManager/monitorUsage.html
Normal file
87
CLManager/templates/CLManager/monitorUsage.html
Normal file
@@ -0,0 +1,87 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Monitor Usage - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "List Websites" %}</h2>
|
||||
<p>{% trans "Monitor usage of your websites." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Websites" %}
|
||||
</h3>
|
||||
<div ng-controller="listWebsites" class="example-box-wrapper">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered"
|
||||
id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>Launch</th>
|
||||
<th>IP Address</th>
|
||||
<th>Package</th>
|
||||
<th>Owner</th>
|
||||
<th>State</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="web in WebSitesList track by $index">
|
||||
<td ng-bind="web.domain"></td>
|
||||
<td><a href="/CloudLinux/manage/{$ web.domain $}"><img width="30px" height="30"
|
||||
class="center-block"
|
||||
src="{% static 'baseTemplate/assets/image-resources/webPanel.png' %}"></a>
|
||||
</td>
|
||||
<td ng-bind="web.ipAddress"></td>
|
||||
<td ng-bind="web.package"></td>
|
||||
<td ng-bind="web.admin"></td>
|
||||
<td ng-bind="web.state"></td>
|
||||
<td ng-bind="web.adminEmail"></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
<li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)" id="webPages"><a
|
||||
href="">{$ $index + 1 $}</a></li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
67
CLManager/templates/CLManager/notAvailable.html
Normal file
67
CLManager/templates/CLManager/notAvailable.html
Normal file
@@ -0,0 +1,67 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Not available - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Not available" %}</h2>
|
||||
<p>{% trans "Either CageFS is not installed or you are not on CloudLinux OS." %}</p>
|
||||
</div>
|
||||
|
||||
{% if not CL %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="alert alert-danger">
|
||||
<p>{% trans "CageFS is only available with CloudLinux OS. " %} <a target="_blank"
|
||||
href="https://go.cyberpanel.net/CLConvert">Click
|
||||
Here</a> {% trans " for conversion details." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div ng-controller="installCageFS" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Install Packages" %} <img ng-hide="installDockerStatus"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<p>{% trans "CageFS is not installed on this server. Please proceed to installation." %}</p>
|
||||
<!------ LSWS Switch box ----------------->
|
||||
|
||||
<div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12">
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
<div class="form-group">
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15"
|
||||
class="form-control">{{ requestData }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!----- LSWS Switch box ----------------->
|
||||
<br>
|
||||
<button ng-hide="dockerInstallBTN" class="btn btn-primary" ng-click="submitCageFSInstall()">Install Now</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
52
CLManager/templates/CLManager/websiteContainerLimit.html
Normal file
52
CLManager/templates/CLManager/websiteContainerLimit.html
Normal file
@@ -0,0 +1,52 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{{ domain }}{% trans " usage - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div ng-controller="websiteContainerLimitCL" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "Usage" %}</h2>
|
||||
<p>{% trans "View CPU, Memory and Disk usage for " %} <span id="domain">{{ domain }}</span></p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h2 class="title-hero">
|
||||
{% trans "CPU Usage of" %} {{ domain }}
|
||||
</h2>
|
||||
<div class="example-box-wrapper">
|
||||
<div id="flot-placeholder1" style="width:auto;height:300px"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2 class="title-hero">
|
||||
{% trans "Memory Usage of" %} {{ domain }}
|
||||
</h2>
|
||||
<div class="example-box-wrapper">
|
||||
<div id="memoryUsage" style="width:auto;height:300px"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2 class="title-hero">
|
||||
{% trans "Disk Usage of" %} {{ domain }}
|
||||
</h2>
|
||||
<div class="example-box-wrapper">
|
||||
<div id="diskUsage" style="width:auto;height:300px"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
6
CLManager/tests.py
Normal file
6
CLManager/tests.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
18
CLManager/urls.py
Normal file
18
CLManager/urls.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.conf.urls import url
|
||||
import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^CageFS$', views.CageFS, name='CageFS'),
|
||||
url(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'),
|
||||
url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
|
||||
url(r'^enableOrDisable$', views.enableOrDisable, name='enableOrDisable'),
|
||||
url(r'^CreatePackage$', views.CreatePackage, name='CreatePackageCL'),
|
||||
url(r'^submitCreatePackage$', views.submitCreatePackage, name='submitCreatePackageCL'),
|
||||
url(r'^listPackages$', views.listPackages, name='listPackagesCL'),
|
||||
url(r'^fetchPackages$', views.fetchPackages, name='fetchPackagesCL'),
|
||||
url(r'^deleteCLPackage$', views.deleteCLPackage, name='deleteCLPackage'),
|
||||
url(r'^saveSettings$', views.saveSettings, name='saveSettings'),
|
||||
url(r'^monitorUsage$', views.monitorUsage, name='monitorUsage'),
|
||||
url(r'^manage/(?P<domain>(.*))$', views.websiteContainerLimit, name='websiteContainerLimitCL'),
|
||||
url(r'^getUsageData$', views.getUsageData, name='getUsageData'),
|
||||
]
|
||||
358
CLManager/views.py
Normal file
358
CLManager/views.py
Normal file
@@ -0,0 +1,358 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import redirect, HttpResponse
|
||||
from loginSystem.views import loadLoginPage
|
||||
from plogical.acl import ACLManager
|
||||
from CLManagerMain import CLManagerMain
|
||||
import json
|
||||
from websiteFunctions.models import Websites
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import os
|
||||
from packages.models import Package
|
||||
from .models import CLPackages
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
import pwd
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
# Create your views here.
|
||||
|
||||
def CageFS(request):
|
||||
try:
|
||||
templateName = 'CLManager/listWebsites.html'
|
||||
c = CLManagerMain(request, templateName)
|
||||
return c.renderC()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def submitCageFSInstall(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
c = CLManagerMain(request, None, 'submitCageFSInstall')
|
||||
c.start()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def getFurtherAccounts(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = CLManagerMain()
|
||||
return wm.getFurtherAccounts(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def enableOrDisable(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
if data['toggle'] == 1:
|
||||
cageFSPath = '/home/cyberpanel/cagefs'
|
||||
if os.path.exists(cageFSPath):
|
||||
os.remove(cageFSPath)
|
||||
else:
|
||||
writeToFile = open(cageFSPath, 'w')
|
||||
writeToFile.writelines('enable')
|
||||
writeToFile.close()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'success': 'Default status successfully changed changed.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
if data['all'] == 0:
|
||||
if data['mode'] == 1:
|
||||
website = Websites.objects.get(domain=data['domain'])
|
||||
command = '/usr/sbin/cagefsctl --enable %s' % (website.externalApp)
|
||||
else:
|
||||
website = Websites.objects.get(domain=data['domain'])
|
||||
command = '/usr/sbin/cagefsctl --disable %s' % (website.externalApp)
|
||||
|
||||
ProcessUtilities.executioner(command)
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'success': 'Changes successfully applied.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
c = CLManagerMain(request, None, 'enableOrDisable', data)
|
||||
c.start()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'success': 'Job started in background, refresh in few seconds to see the status.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def CreatePackage(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
templateName = 'CLManager/createPackage.html'
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
data = {}
|
||||
data['packList'] = packageList
|
||||
c = CLManagerMain(request, templateName, None, data)
|
||||
return c.renderC()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def submitCreatePackage(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
selectedPackage = data['selectedPackage']
|
||||
|
||||
package = Package.objects.get(packageName=selectedPackage)
|
||||
|
||||
if package.clpackages_set.all().count() == 1:
|
||||
data_ret = {'status': 0, 'error_message': 'This package already have one associated CloudLinux Package.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
name = data['name']
|
||||
SPEED = data['SPEED']
|
||||
VMEM = data['VMEM']
|
||||
PMEM = data['PMEM']
|
||||
IO = data['IO']
|
||||
IOPS = data['IOPS']
|
||||
EP = data['EP']
|
||||
NPROC = data['NPROC']
|
||||
INODESsoft = data['INODESsoft']
|
||||
INODEShard = data['INODEShard']
|
||||
|
||||
clPackage = CLPackages(name=name, owner=package, speed=SPEED, vmem=VMEM, pmem=PMEM, io=IO, iops=IOPS, ep=EP, nproc=NPROC, inodessoft=INODESsoft, inodeshard=INODEShard)
|
||||
clPackage.save()
|
||||
|
||||
command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % (name, SPEED, PMEM, IO, NPROC, IOPS, VMEM, EP)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo lvectl apply all'
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def listPackages(request):
|
||||
try:
|
||||
templateName = 'CLManager/listPackages.html'
|
||||
c = CLManagerMain(request, templateName)
|
||||
return c.renderC()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchPackages(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = CLManagerMain()
|
||||
return wm.fetchPackages(ACLManager.loadedACL(userID))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def deleteCLPackage(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
name = data['name']
|
||||
|
||||
clPackage = CLPackages.objects.get(name=name)
|
||||
clPackage.delete()
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def saveSettings(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
name = data['name']
|
||||
SPEED = data['SPEED']
|
||||
VMEM = data['VMEM']
|
||||
PMEM = data['PMEM']
|
||||
IO = data['IO']
|
||||
IOPS = data['IOPS']
|
||||
EP = data['EP']
|
||||
NPROC = data['NPROC']
|
||||
INODESsoft = data['INODESsoft']
|
||||
INODEShard = data['INODEShard']
|
||||
|
||||
clPackage = CLPackages.objects.get(name=name)
|
||||
clPackage.speed = SPEED
|
||||
clPackage.vmem = VMEM
|
||||
clPackage.pmem = PMEM
|
||||
clPackage.io = IO
|
||||
clPackage.iops = IOPS
|
||||
clPackage.ep = EP
|
||||
clPackage.nproc = NPROC
|
||||
clPackage.inodessoft = INODESsoft
|
||||
clPackage.inodeshard = INODEShard
|
||||
clPackage.save()
|
||||
|
||||
command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % (
|
||||
name, SPEED, PMEM, IO, NPROC, IOPS, VMEM, EP)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo lvectl apply all'
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def monitorUsage(request):
|
||||
try:
|
||||
templateName = 'CLManager/monitorUsage.html'
|
||||
c = CLManagerMain(request, templateName)
|
||||
return c.renderC()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def websiteContainerLimit(request, domain):
|
||||
try:
|
||||
templateName = 'CLManager/websiteContainerLimit.html'
|
||||
data = {}
|
||||
data['domain'] = domain
|
||||
c = CLManagerMain(request, templateName, None, data)
|
||||
return c.renderC()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def getUsageData(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
data = json.loads(request.body)
|
||||
domain = data['domain']
|
||||
website = Websites.objects.get(domain=domain)
|
||||
uid = pwd.getpwnam(website.externalApp).pw_uid
|
||||
|
||||
try:
|
||||
type = data['type']
|
||||
finalData = {}
|
||||
finalData['status'] = 1
|
||||
|
||||
try:
|
||||
if type == 'memory':
|
||||
|
||||
command = 'sudo lveps -o id:10,mem:10'
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
for items in output:
|
||||
if items.find(website.externalApp) > -1:
|
||||
finalData['memory'] = int(items.split(' ')[-1])
|
||||
break
|
||||
|
||||
elif type == 'io':
|
||||
|
||||
finalData['readRate'] = 0
|
||||
finalData['writeRate'] = 0
|
||||
|
||||
command = 'sudo lveps -o id:10,iops:10'
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
for items in output:
|
||||
if items.find(website.externalApp) > -1:
|
||||
finalData['readRate'] = int(items.split(' ')[-1])
|
||||
break
|
||||
|
||||
except:
|
||||
finalData['memory'] = '0'
|
||||
finalData['readRate'] = 0
|
||||
finalData['writeRate'] = 0
|
||||
except:
|
||||
|
||||
finalData = {}
|
||||
finalData['status'] = 1
|
||||
|
||||
command = 'sudo lveps -o id:10,cpu:10 -d'
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
for items in output:
|
||||
if items.find(website.externalApp) > -1:
|
||||
finalData['cpu'] = int(items.split(' ')[-1].rstrip('%'))
|
||||
break
|
||||
|
||||
final_json = json.dumps(finalData)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
Reference in New Issue
Block a user