mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-11 12:07:39 +02:00
Update to v7.55.0
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# coding: utf-8
|
||||
# -------------------------------------------------------------------
|
||||
# 宝塔Linux面板
|
||||
# aaPanel
|
||||
# -------------------------------------------------------------------
|
||||
# Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
|
||||
# Copyright (c) 2015-2099 aaPanel(www.aapanel.com) All rights reserved.
|
||||
# -------------------------------------------------------------------
|
||||
# Author: wzz <wzz@bt.cn>
|
||||
# -------------------------------------------------------------------
|
||||
@@ -21,13 +21,18 @@ os.chdir("/www/server/panel")
|
||||
import public
|
||||
|
||||
from mod.project.docker.app.appManageMod import AppManage
|
||||
# from mod.project.docker.runtime.runtimeManage import RuntimeManage
|
||||
# from mod.project.docker.sites.sitesManage import SitesManage
|
||||
from mod.project.docker.app.sub_app.ollamaMod import OllamaMod
|
||||
from mod.project.docker.apphub.apphubManage import AppHub
|
||||
from btdockerModelV2 import dk_public as dp
|
||||
|
||||
|
||||
class main(AppManage):
|
||||
class main(AppManage, OllamaMod):
|
||||
|
||||
def __init__(self):
|
||||
super(main, self).__init__()
|
||||
OllamaMod.__init__(self)
|
||||
|
||||
# 2024/6/26 下午5:49 获取所有已部署的项目列表
|
||||
def get_project_list(self, get):
|
||||
@@ -119,7 +124,7 @@ class main(AppManage):
|
||||
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
return public.returnResult(False, str(e))
|
||||
return public.return_message(-1, 0, str(e))
|
||||
|
||||
# 2024/6/26 下午8:55 获取指定compose.yml的docker-compose ps
|
||||
def get_project_ps(self, get):
|
||||
@@ -163,7 +168,21 @@ class main(AppManage):
|
||||
continue
|
||||
|
||||
l["Ports"] += "{}:{}->{}/{},".format(p["URL"], p["PublishedPort"], p["TargetPort"], p["Protocol"])
|
||||
|
||||
#构造容器详情所需的ports 实现参考了containerModel.struct_container_ports
|
||||
ports_data = dict()
|
||||
for port in l["Publishers"]:
|
||||
key = str(port["TargetPort"]) + "/" + port["Protocol"]
|
||||
if key not in ports_data.keys():
|
||||
ports_data[str(port["TargetPort"]) + "/" + port["Protocol"]] = [{
|
||||
"HostIp": port["URL"],
|
||||
"HostPort": str(port["PublishedPort"])
|
||||
}] if port["URL"] != "" else None
|
||||
else:
|
||||
ports_data[str(port["TargetPort"]) + "/" + port["Protocol"]].append({
|
||||
"HostIp": port["URL"],
|
||||
"HostPort": str(port["PublishedPort"])
|
||||
})
|
||||
l["ports"] =ports_data
|
||||
if hasattr(get, '_ws'):
|
||||
setattr(get._ws, 'btws_get_project_ps_{}'.format(get.path), True)
|
||||
get._ws.send(json.dumps(self.wsResult(
|
||||
@@ -173,7 +192,158 @@ class main(AppManage):
|
||||
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
return public.returnResult(False, str(e))
|
||||
return public.return_message(-1, 0, str(e))
|
||||
|
||||
# 2024/11/11 14:34 获取所有正在运行的容器信息和已安装的应用信息
|
||||
def get_some_info(self, get):
|
||||
'''
|
||||
@name 获取所有正在运行的容器信息和已安装的应用信息
|
||||
'''
|
||||
get.type = get.get("type", "container")
|
||||
if not get.type in ("container", "app"):
|
||||
return public.return_message(-1, 0, public.lang("Only container and app types are supported"))
|
||||
|
||||
if get.type == "container":
|
||||
from btdockerModelV2.dockerSock import container
|
||||
sk_container = container.dockerContainer()
|
||||
sk_container_list = sk_container.get_container()
|
||||
|
||||
data = []
|
||||
for container in sk_container_list:
|
||||
if not "running" in container["State"]: continue
|
||||
|
||||
port_list = []
|
||||
for p in container["Ports"]:
|
||||
if not "PublicPort" in p: continue
|
||||
if not p["PublicPort"] in port_list:
|
||||
port_list.append(p["PublicPort"])
|
||||
|
||||
data.append({
|
||||
"id": container["Id"],
|
||||
"name": container["Names"][0].replace("/", ""),
|
||||
"status": container["State"],
|
||||
"image": container["Image"],
|
||||
"created_time": container["Created"],
|
||||
"ports": port_list,
|
||||
})
|
||||
|
||||
return public.return_message(0, 0, data)
|
||||
else:
|
||||
get.row = 10000
|
||||
installed_apps = self.get_installed_apps(get)['message']
|
||||
not_allow_category = ("Database", "System")
|
||||
if installed_apps and installed_apps.get('data', []):
|
||||
for app in installed_apps["data"]:
|
||||
if not "running" in app["status"]:
|
||||
installed_apps["data"].remove(app)
|
||||
if app["apptype"] in not_allow_category:
|
||||
installed_apps["data"].remove(app) if app in installed_apps["data"] else None
|
||||
|
||||
# return public.returnResult(status=installed_apps["status"], data=installed_apps["data"])
|
||||
return public.return_message(0, 0, installed_apps)
|
||||
|
||||
def generate_apphub(self, get):
|
||||
'''
|
||||
@name 解析外部应用列表
|
||||
@author csj <2025/7/9>
|
||||
@return dict{"status":True/False,"msg":"提示信息"}
|
||||
'''
|
||||
return AppHub().generate_apphub(get)
|
||||
|
||||
def create_app(self,get):
|
||||
'''
|
||||
@name 创建应用
|
||||
@author csj <2025/7/9>
|
||||
@return dict{"status":True/False,"msg":"提示信息"}
|
||||
'''
|
||||
if get.get("appid","0") == "-1": # 从apphub创建应用
|
||||
self.templates_path = os.path.join(AppHub.hub_home_path, "templates")
|
||||
self.apps_json_file = os.path.join(AppHub.hub_home_path, "apps.json")
|
||||
|
||||
version = get.get("version","latest")
|
||||
app_name = get.get("app_name","")
|
||||
|
||||
if not os.path.exists(self.templates_path):
|
||||
os.makedirs(self.templates_path)
|
||||
|
||||
#/www/dk_project/dk_app/apphub/apphub/templates/app_name/version
|
||||
app_version_path = os.path.join(AppHub.hub_home_path, app_name, version)
|
||||
if not os.path.exists(app_version_path):
|
||||
return public.return_message(-1, 0, public.lang("Version {} for applying {} does not exist", (version, app_name)))
|
||||
|
||||
# /www/dk_project/dk_app/apphub/apphub/templates/app_name
|
||||
app_template_path = os.path.join(self.templates_path, app_name)
|
||||
|
||||
public.ExecShell("\cp -r {} {}".format(app_version_path,app_template_path))
|
||||
|
||||
return super().create_app(get)
|
||||
|
||||
def get_apphub_config(self, get):
|
||||
'''
|
||||
@name 获取apphub配置
|
||||
@author csj <2025/7/9>
|
||||
@return dict{"status":True/False,"data":{}}
|
||||
'''
|
||||
return public.return_message(0, 0, AppHub.get_config())
|
||||
|
||||
def set_apphub_git(self,get):
|
||||
'''
|
||||
@name 设置外部应用的git地址
|
||||
@author csj <2025/7/9>
|
||||
@param get: git_url, git_branch, user, password
|
||||
'''
|
||||
if not hasattr(get, 'git_url') or not get.git_url:
|
||||
return public.return_message(-1, 0, public.lang("GIT ADDRESS IS NOT SET"))
|
||||
if not hasattr(get, 'git_branch') or not get.git_branch:
|
||||
return public.return_message(-1, 0, public.lang("The branch name is not set"))
|
||||
|
||||
return AppHub().set_apphub_git(get)
|
||||
|
||||
def import_git_apphub(self,get):
|
||||
'''
|
||||
@name 从git导入外部应用
|
||||
@author csj <2025/7/9>
|
||||
'''
|
||||
return AppHub().import_git_apphub(get)
|
||||
|
||||
def install_apphub(self,get):
|
||||
'''
|
||||
@name 安装apphub所需环境
|
||||
@author csj <2025/7/9>
|
||||
'''
|
||||
return AppHub().install_apphub(get)
|
||||
|
||||
def import_zip_apphub(self,get):
|
||||
'''
|
||||
@name 从zip包导入外部应用
|
||||
@author csj <2025/7/9>
|
||||
@param get: sfile: zip文件路径
|
||||
'''
|
||||
if not hasattr(get, 'sfile') or not get.sfile:
|
||||
return public.return_message(-1, 0, public.lang("The zip file path is not set"))
|
||||
|
||||
return AppHub().import_zip_apphub(get)
|
||||
|
||||
def parser_zip_apphub(self,get):
|
||||
'''
|
||||
@name 解析zip包
|
||||
@author csj <2025/7/9>
|
||||
@param get: sfile: zip文件路径
|
||||
@return dict{"status":True/False,"data":[]}
|
||||
'''
|
||||
if not hasattr(get, 'sfile') or not get.sfile:
|
||||
return public.return_message(-1, 0, public.lang("Please select the file path"))
|
||||
|
||||
app_list = []
|
||||
files = get.sfile.split(',')
|
||||
for sfile in files:
|
||||
get.sfile = sfile
|
||||
|
||||
apps = AppHub().parser_zip_apphub(get)
|
||||
app_list.extend(apps)
|
||||
public.print_log(app_list)
|
||||
return public.return_message(0, 0, app_list)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user