mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-06 19:06:46 +02:00
specific custom mac address
This commit is contained in:
@@ -12,4 +12,17 @@ class secMiddleware:
|
||||
if request.body.find(';') > -1 or request.body.find('&&') > -1 or request.body.find('|') > -1 or request.body.find('...') > -1:
|
||||
logging.writeToFile('Bad Input on.')
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
return response
|
||||
|
||||
# def __call__(self, request):
|
||||
# if request.method == 'POST':
|
||||
# data = json.loads(request.body)
|
||||
# for key, value in data.iteritems():
|
||||
# if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1:
|
||||
# logging.writeToFile(request.body)
|
||||
# return HttpResponse('Error')
|
||||
# if key.find(';') > -1 or key.find('&&') > -1 or key.find('|') > -1 or key.find('...') > -1:
|
||||
# logging.writeToFile(request.body)
|
||||
# return HttpResponse('Error')
|
||||
# response = self.get_response(request)
|
||||
# return response
|
||||
@@ -26,6 +26,7 @@ from os import remove
|
||||
class CyberTron(multi.Thread):
|
||||
imagesPath = join('/var', 'lib', 'libvirt', 'images')
|
||||
templatesPath = join('/var', 'lib', 'libvirt', 'templates')
|
||||
templates = 'images.cyberpanel.net/templates'
|
||||
|
||||
def __init__(self, data):
|
||||
multi.Thread.__init__(self)
|
||||
@@ -235,6 +236,17 @@ class CyberTron(multi.Thread):
|
||||
finalPath = join(virtualMachineAPI.imagesPath, vmName + ".qcow2")
|
||||
|
||||
## Creating temporary disk image.
|
||||
logging.CyberCPLogFileWriter.writeToFile(sourcePath + ' spath')
|
||||
|
||||
if not os.path.exists('/var/lib/libvirt/templates'):
|
||||
command = 'sudo mkdir -p /var/lib/libvirt/templates/'
|
||||
call(split(command))
|
||||
|
||||
if not os.path.exists(sourcePath):
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Downloading image, it will take some time..,20')
|
||||
command = 'wget -O ' + sourcePath + ' ' + CyberTron.templates + "/" + osName + '.img'
|
||||
call(split(command))
|
||||
|
||||
|
||||
command = "sudo cp " + sourcePath + " " + tempPath
|
||||
result = call(split(command))
|
||||
@@ -322,6 +334,7 @@ class CyberTron(multi.Thread):
|
||||
uploadCommand = " --upload " + uploadSource[0] + ":" + "/etc/sysconfig/network-scripts/ifcfg-ens3"
|
||||
|
||||
finalImageLocation = join(CyberTron.imagesPath, vmName + '.qcow2')
|
||||
osName = osName.strip('\n')
|
||||
|
||||
|
||||
## "virt-builder centos-7.1 -o /var/lib/libvirt/images192.168.100.1.qcow2 --size 50G --format qcow2 --upload ifcfg-eth0:/etc/sysconfig/network-scripts/ --upload network:/etc/sysconfig
|
||||
@@ -366,7 +379,7 @@ class CyberTron(multi.Thread):
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + ' [404]')
|
||||
return 0
|
||||
|
||||
def bootVirtualMachine(self, package, vmName, vncHost, vncPort, vncPassword, webSocketPort, hostname, bridgeName, isoPath, tempStatusPath):
|
||||
def bootVirtualMachine(self, package, vmName, vncHost, vncPort, vncPassword, ip, hostname, bridgeName, isoPath, tempStatusPath):
|
||||
try:
|
||||
|
||||
if logLevel.debug == True:
|
||||
@@ -376,19 +389,24 @@ class CyberTron(multi.Thread):
|
||||
|
||||
# virt-install --name 109.238.12.214 --ram 2048 --vcpus=1 --disk 109.238.12.214.qcow2 --graphics vnc,listen=localhost,port=5500 --noautoconsole --hvm --import --os-type=linux --os-variant=rhel7 --network bridge=virbr0
|
||||
|
||||
macStr = ''
|
||||
|
||||
if ip.macAddress != 'Auto':
|
||||
macStr = ',mac=' + ip.macAddress
|
||||
|
||||
if isoPath == None:
|
||||
|
||||
command = "sudo virt-install --name " + hostname + " --ram " + str(package.guaranteedRam) + " --vcpu " + str(package.cpuCores) + " --disk " + \
|
||||
finalImageLocation + " --graphics vnc,listen=" + vncHost + ",port=" + vncPort + ",password=" + vncPassword + \
|
||||
" --noautoconsole --hvm --import --autostart --os-type=linux " \
|
||||
+ "--network bridge=" + bridgeName
|
||||
+ "--network bridge=" + bridgeName + macStr
|
||||
else:
|
||||
size = package.diskSpace
|
||||
command = "sudo virt-install --name " + hostname + " --ram " + str(package.guaranteedRam) + " --vcpu " \
|
||||
+ str(package.cpuCores) + " --disk path=" + finalImageLocation + ",size=" + size + \
|
||||
" --graphics vnc,listen=" + vncHost + ",port=" + vncPort + ",password=" + vncPassword + \
|
||||
" --noautoconsole --hvm --autostart --os-type=linux " \
|
||||
+ "--network bridge=" + bridgeName + ' --cdrom=' + isoPath
|
||||
+ "--network bridge=" + bridgeName + + macStr + ' --cdrom=' + isoPath
|
||||
|
||||
result = call(split(command))
|
||||
|
||||
@@ -496,7 +514,7 @@ class CyberTron(multi.Thread):
|
||||
|
||||
vncPassword = randomPassword.generate_pass(50)
|
||||
|
||||
if self.bootVirtualMachine(package, hostname, vncHost, str(vncPort), vncPassword, str(webSocketPort), hostname, 'virbr0', isoPath, data['tempStatusPath']) == 0:
|
||||
if self.bootVirtualMachine(package, hostname, vncHost, str(vncPort), vncPassword, ip, hostname, 'virbr0', isoPath, data['tempStatusPath']) == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(data['tempStatusPath'], 'Failed to boot virtual machine. [404]')
|
||||
return 0
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def getCurrentBackups(request):
|
||||
|
||||
def submitBackupCreation(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
userID = 1
|
||||
wm = BackupManager()
|
||||
return wm.submitBackupCreation(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
@@ -51,7 +51,7 @@ def submitBackupCreation(request):
|
||||
|
||||
def backupStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
userID = 1
|
||||
wm = BackupManager()
|
||||
return wm.backupStatus(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
|
||||
@@ -5,8 +5,8 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
PIDFile=/run/gunicorn/pid
|
||||
User=cyberpanel
|
||||
Group=cyberpanel
|
||||
User=root
|
||||
Group=root
|
||||
RuntimeDirectory=gunicorn
|
||||
WorkingDirectory=/usr/local/CyberCP
|
||||
ExecStart=/usr/local/CyberCP/bin/gunicorn --pid /run/gunicorn/gucpid \
|
||||
|
||||
@@ -9,6 +9,17 @@ from firewallUtilities import FirewallUtilities
|
||||
import time
|
||||
import string
|
||||
import random
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import installLog as logging
|
||||
import argparse
|
||||
import os
|
||||
import shlex
|
||||
from firewallUtilities import FirewallUtilities
|
||||
import time
|
||||
import string
|
||||
import random
|
||||
|
||||
# There can not be peace without first a great suffering.
|
||||
|
||||
@@ -3146,6 +3157,30 @@ milter_default_action = accept
|
||||
logging.InstallLog.writeToFile(str(msg) + " [installNoVNC]")
|
||||
return 0
|
||||
|
||||
def touchOSFile(self):
|
||||
try:
|
||||
osPath = "/home/cyberpanel/os"
|
||||
|
||||
osS = """centos-6
|
||||
centos-7.2
|
||||
debian-9
|
||||
fedora-28
|
||||
ubuntu-16.04
|
||||
ubuntu-18.04
|
||||
"""
|
||||
|
||||
osFile = open(osPath, 'w')
|
||||
osFile.write(osS)
|
||||
osFile.close()
|
||||
|
||||
except OSError, msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [touchOSFile]")
|
||||
return 0
|
||||
except ValueError, msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [touchOSFile]")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -3258,6 +3293,7 @@ def main():
|
||||
|
||||
checks.modSecPreReqs()
|
||||
checks.setupPHPAndComposer()
|
||||
checks.touchOSFile()
|
||||
|
||||
|
||||
if args.postfix != None:
|
||||
|
||||
@@ -1011,7 +1011,7 @@ app.controller('emailForwarding', function($scope,$http) {
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteForwarding = function(destination){
|
||||
$scope.deleteForwarding = function(source, destination){
|
||||
|
||||
$scope.creationBox = true;
|
||||
$scope.emailDetails = true;
|
||||
@@ -1025,7 +1025,8 @@ app.controller('emailForwarding', function($scope,$http) {
|
||||
|
||||
|
||||
var data = {
|
||||
destination:destination
|
||||
destination:destination,
|
||||
source: source
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<td ng-bind="record.id"></td>
|
||||
<td ng-bind="record.source"></td>
|
||||
<td ng-bind="record.destination"></td>
|
||||
<td ng-click="deleteForwarding(record.destination)"><img src="{% static 'images/delete.png' %}"></td>
|
||||
<td ng-click="deleteForwarding(record.source, record.destination)"><img src="{% static 'images/delete.png' %}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -311,8 +311,9 @@ def submitForwardDeletion(request):
|
||||
|
||||
data = json.loads(request.body)
|
||||
destination = data['destination']
|
||||
source = data['source']
|
||||
|
||||
forwarding = Forwardings.objects.get(destination=destination)
|
||||
forwarding = Forwardings.objects.get(destination=destination, source=source)
|
||||
forwarding.delete()
|
||||
|
||||
data_ret = {'deleteForwardingStatus': 1, 'error_message': "None", 'successMessage':'Successfully deleted!'}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</div>
|
||||
|
||||
<div id="packageCreated" class="alert alert-success">
|
||||
<p>{% trans "Package" %} <strong>{$ createdPackage $}</strong> {% trans "Successfully Created" %}"</p>
|
||||
<p>{% trans "Package" %} <strong>{$ createdPackage $}</strong> {% trans "Successfully Created" %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ class BackupManager:
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
final_dic = {'metaStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
|
||||
@@ -864,27 +864,19 @@ class backupUtilities:
|
||||
@staticmethod
|
||||
def getAliases(masterDomain):
|
||||
try:
|
||||
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
command = "sudo cat " + confPath
|
||||
data = subprocess.check_output(shlex.split(command)).splitlines()
|
||||
aliases = []
|
||||
master = Websites.objects.get(domain=masterDomain)
|
||||
aliasDomains = master.aliasdomains_set.all()
|
||||
|
||||
for items in data:
|
||||
if items.find(masterDomain) > -1 and items.find('map') > -1:
|
||||
data = filter(None, items.split(" "))
|
||||
if data[1] == masterDomain:
|
||||
length = len(data)
|
||||
for i in range(3, length):
|
||||
currentAlias = data[i].rstrip(',').strip('\n')
|
||||
aliases.append(currentAlias)
|
||||
|
||||
for items in aliasDomains:
|
||||
aliases.append(items.aliasDomain)
|
||||
|
||||
return aliases
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getAliases]")
|
||||
print 0
|
||||
return 0
|
||||
|
||||
|
||||
def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
|
||||
@@ -192,6 +192,7 @@ class remoteTransferUtilities:
|
||||
writeToFile.close()
|
||||
break
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
pass
|
||||
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
|
||||
@@ -1011,7 +1011,7 @@ app.controller('emailForwarding', function($scope,$http) {
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteForwarding = function(destination){
|
||||
$scope.deleteForwarding = function(source, destination){
|
||||
|
||||
$scope.creationBox = true;
|
||||
$scope.emailDetails = true;
|
||||
@@ -1025,7 +1025,8 @@ app.controller('emailForwarding', function($scope,$http) {
|
||||
|
||||
|
||||
var data = {
|
||||
destination:destination
|
||||
destination:destination,
|
||||
source: source
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
||||
@@ -48,7 +48,7 @@ def siteState(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.suspendWebsite(request, userID)
|
||||
return wm.siteState(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user