Skip to content

Commit

Permalink
Merge branch 'v2.3.5-dev' of github.com:usmannasir/cyberpanel into v2…
Browse files Browse the repository at this point in the history
….3.5-dev
  • Loading branch information
usmannasir committed Dec 27, 2023
2 parents 2b3e8ce + d626ab4 commit ac838ba
Show file tree
Hide file tree
Showing 6 changed files with 1,220 additions and 77 deletions.
134 changes: 134 additions & 0 deletions dockerManager/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import os.path
import sys
import django

from plogical.DockerSites import Docker_Sites

sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup()
Expand Down Expand Up @@ -1076,4 +1079,135 @@ def getTags(self, userID=None, data=None):
except BaseException as msg:
data_ret = {'getTagsStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)


def getDockersiteList(self, userID=None, data=None):
try:
admin = Administrator.objects.get(pk=userID)

if admin.acl.adminStatus != 1:
return ACLManager.loadError()


name = data['name']

passdata = {}
passdata["JobID"] = None
passdata['name'] = name
da = Docker_Sites(None, passdata)
retdata = da.ListContainers()


data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

except BaseException as msg:
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

# Internal function for recreating containers

def getContainerAppinfo(self, userID=None, data=None):
try:
admin = Administrator.objects.get(pk=userID)

if admin.acl.adminStatus != 1:
return ACLManager.loadError()


name = data['name']
containerID = data['id']

passdata = {}
passdata["JobID"] = None
passdata['name'] = name
passdata['containerID'] = containerID
da = Docker_Sites(None, passdata)
retdata = da.ContainerInfo()


data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

except BaseException as msg:
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

def getContainerApplog(self, userID=None, data=None):
try:
admin = Administrator.objects.get(pk=userID)

if admin.acl.adminStatus != 1:
return ACLManager.loadError()


name = data['name']
containerID = data['id']

passdata = {}
passdata["JobID"] = None
passdata['name'] = name
passdata['containerID'] = containerID
passdata['numberOfLines'] = 50
da = Docker_Sites(None, passdata)
retdata = da.ContainerLogs()


data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

except BaseException as msg:
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

def recreateappcontainer(self, userID=None, data=None):
try:
from websiteFunctions.models import DockerSites
admin = Administrator.objects.get(pk=userID)

if admin.acl.adminStatus != 1:
return ACLManager.loadError()


name = data['name']
WPusername = data['WPusername']
WPemail = data['WPemail']
WPpasswd = data['WPpasswd']

dockersite = DockerSites.objects.get(SiteName=name)

passdata ={}
data['JobID'] = ''
data['Domain'] = dockersite.admin.domain
data['domain'] = dockersite.admin.domain
data['WPemal'] = WPemail
data['Owner'] = dockersite.admin.admin.userName
data['userID'] = userID
data['MysqlCPU'] = dockersite.CPUsMySQL
data['MYsqlRam'] = dockersite.MemoryMySQL
data['SiteCPU'] = dockersite.CPUsSite
data['SiteRam'] = dockersite.MemorySite
data['sitename'] = dockersite.SiteName
data['WPusername'] = WPusername
data['WPpasswd'] = WPpasswd
data['externalApp'] = dockersite.admin.externalApp

da = Docker_Sites(None, passdata)
da.RebuildApp()


data_ret = {'status': 1, 'error_message': 'None',}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

except BaseException as msg:
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
4 changes: 4 additions & 0 deletions dockerManager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
url(r'^view/(?P<name>(.*))$', views.viewContainer, name='viewContainer'),

path('manage/<int:dockerapp>/app', Dockersitehome, name='Dockersitehome'),
path('getDockersiteList', views.getDockersiteList, name='getDockersiteList'),
path('getContainerAppinfo', views.getContainerAppinfo, name='getContainerAppinfo'),
path('getContainerApplog', views.getContainerApplog, name='getContainerApplog'),
path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'),
]
Loading

0 comments on commit ac838ba

Please sign in to comment.