mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-09 19:17:38 +02:00
Update to 7.7.0
Since version 7.7.0, we recommend yours update python to 3.12. [+] Using nginx technology to load static files improves access speed [+] Refactor homepage, website, FTP, and database using vue3 [+] Table loading changed to skeleton screen [+] Add Website statistics-v2 professional plug-in [+] Add Home page - top 5 resource occupancy [+] Add protection for Files management (requires Tamper-proof for Enterprise 3.7) [+] Website, FTP, Databases page add program status [+] Add FTP log analysis (only supports Centos) [+] Add password-free login to phpMyAdmin [+] Add Proxy Project in Website (Supported when web service uses Nginx) [+] Add WP Toolkit (Pro version only) [+] Redesigned Docker module [+] Add WP Toolkit Protection [+] Add WP Toolkit Backup and Restore [+] Add WP Toolkit Migrated [+] Add WP Toolkit Clone site (supports new domain and subdomain) [+] Add WP Toolkit Create site from backup of other panel [+] Add WP Toolkit support for Cron automatic backup (only save Local disk) [+] Add WP Toolkit operation log [+] Add Integrity check for WP Toolkit [+] Add WP Toolkit plug-in management and themes management [*] Optimize phpMyAdmin formula access method [*] Optimize Home page PHP display problem [*] Optimize jump to the login interface after the login expires [*] Optimize automatic renewal of SSL at some times [*] Optimize Let's Encrypt to increase application success rate [-] Fix Logs Audit cannot be opened [-] Fix apache URL rewrite issue [-] Fix phpmyadmin installation problem [-] Fix the problem that some servers cannot install software [-] Fix upload file error [-] Fix left menu hiding problem [-] Fix aaPanel Mobile QR code display problem [-] Fix problem that third-party plug-ins are not displayed in the App Store [-] Fix issue where the menu bar is blank when opening new tabs [-] Fixed panel not being accessible in some cases [-] Fix the issue where Curl warning caused the inability to apply for SSL [-] Fix Quota issues for Website, FTP, Databases [-] Fix file interface display problem on mobile terminal
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
# coding: utf-8
|
||||
# -------------------------------------------------------------------
|
||||
# aaPanel
|
||||
# -------------------------------------------------------------------
|
||||
# Copyright (c) 2015-2099 aaPanel(www.aapanel.com) All rights reserved.
|
||||
# -------------------------------------------------------------------
|
||||
# Author: wzz <wzz@aapanel.com>
|
||||
# -------------------------------------------------------------------
|
||||
import gettext
|
||||
_ = gettext.gettext
|
||||
|
||||
# ------------------------------
|
||||
# Docker模型
|
||||
# ------------------------------
|
||||
import docker.errors
|
||||
import public
|
||||
from btdockerModelV2 import dk_public as dp
|
||||
from btdockerModelV2.dockerBase import dockerBase
|
||||
from public.validate import Param
|
||||
|
||||
class main(dockerBase):
|
||||
|
||||
def docker_client(self, url):
|
||||
return dp.docker_client(url)
|
||||
|
||||
def get_volume_container_name(self, volume_detail, container_list):
|
||||
'''
|
||||
拼接对应的容器名与卷名
|
||||
@param volume_detail: 卷字典
|
||||
@param container_list: 容器详情列表
|
||||
@return:
|
||||
'''
|
||||
try:
|
||||
for container in container_list:
|
||||
if not container['Mounts']:
|
||||
continue
|
||||
for mount in container['Mounts']:
|
||||
if "Name" not in mount:
|
||||
continue
|
||||
if volume_detail['Name'] == mount['Name']:
|
||||
volume_detail['container'] = container['Names'][0].replace("/", "")
|
||||
if 'container' not in volume_detail:
|
||||
volume_detail['container'] = ''
|
||||
except:
|
||||
volume_detail['container'] = ''
|
||||
|
||||
return volume_detail
|
||||
|
||||
def get_volume_list(self, args):
|
||||
"""
|
||||
:param self._url: 链接docker的URL
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
data = list()
|
||||
from btdockerModelV2.dockerSock import volume
|
||||
sk_volume = volume.dockerVolume()
|
||||
volume_list = sk_volume.get_volumes()
|
||||
|
||||
from btdockerModelV2.dockerSock import container
|
||||
sk_container = container.dockerContainer()
|
||||
container_list = sk_container.get_container()
|
||||
|
||||
if "Volumes" in volume_list and type(volume_list["Volumes"]) == list:
|
||||
for v in volume_list["Volumes"]:
|
||||
data.append(self.get_volume_container_name(v, container_list))
|
||||
|
||||
return public.return_message(0, 0, sorted(data, key=lambda x: x['CreatedAt'], reverse=True))
|
||||
else:
|
||||
return public.return_message(0, 0, [])
|
||||
except Exception as e:
|
||||
return public.return_message(-1, 0, [])
|
||||
|
||||
def add(self, args):
|
||||
"""
|
||||
添加一个卷
|
||||
:param name
|
||||
:param driver local
|
||||
:param driver_opts (dict) – Driver options as a key-value dictionary
|
||||
:param labels str
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
args.driver_opts = args.get("driver_opts", "")
|
||||
args.labels = args.get("labels", "")
|
||||
if args.driver_opts != "":
|
||||
args.driver_opts = dp.set_kv(args.driver_opts)
|
||||
if args.labels != "":
|
||||
args.labels = dp.set_kv(args.labels)
|
||||
|
||||
if len(args.name) < 2:
|
||||
return public.return_message(-1, 0, _( "Volume names can be no less than 2 characters long!"))
|
||||
|
||||
self.docker_client(self._url).volumes.create(
|
||||
name=args.name,
|
||||
driver=args.driver,
|
||||
driver_opts=args.driver_opts if args.driver_opts else None,
|
||||
labels=args.labels if args.labels != "" else None
|
||||
)
|
||||
dp.write_log("Add storage volume [{}] success!".format(args.name))
|
||||
return public.return_message(0, 0, _( "successfully added!"))
|
||||
except docker.errors.APIError as e:
|
||||
if "volume name is too short, names should be at least two alphanumeric characters" in str(e):
|
||||
return public.return_message(-1, 0, _( "Volume names can be no less than 2 characters long!"))
|
||||
if "volume name" in str(e):
|
||||
return public.return_message(-1, 0, _( "Volume name already exists!"))
|
||||
return public.return_message(-1, 0, _( "addition failed {}".format(e)))
|
||||
|
||||
except Exception as e:
|
||||
if "driver_opts must be a dictionary" in str(e):
|
||||
return public.return_message(-1, 0, _( "Driver option tags must be dictionary/key-value pairs!"))
|
||||
return public.return_message(-1, 0, _( "Add failed! {}".format(e)))
|
||||
|
||||
def remove(self, args):
|
||||
"""
|
||||
删除一个卷
|
||||
:param name volume name
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
|
||||
# 校验参数
|
||||
try:
|
||||
args.validate([
|
||||
Param('name').Require().String(),
|
||||
], [
|
||||
public.validate.trim_filter(),
|
||||
])
|
||||
except Exception as ex:
|
||||
public.print_log("error info: {}".format(ex))
|
||||
return public.return_message(-1, 0, str(ex))
|
||||
try:
|
||||
obj = self.docker_client(self._url).volumes.get(args.name)
|
||||
obj.remove()
|
||||
dp.write_log("Delete volume [{}] successful!".format(args.name))
|
||||
return public.return_message(0, 0, _( "successfully delete"))
|
||||
|
||||
except docker.errors.APIError as e:
|
||||
if "volume is in use" in str(e):
|
||||
return public.return_message(-1, 0, _( "The storage volume is in use and cannot be deleted!"))
|
||||
if "no such volume" in str(e):
|
||||
return public.return_message(-1, 0, _( "The storage volume does not exist!"))
|
||||
return public.return_message(-1, 0, _( "Delete failed! {}".format(e)))
|
||||
|
||||
def prune(self, args):
|
||||
"""
|
||||
删除无用的卷
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
res = self.docker_client(self._url).volumes.prune()
|
||||
if not res['VolumesDeleted']:
|
||||
return public.return_message(-1, 0, _( "No useless storage volumes!"))
|
||||
|
||||
dp.write_log("Delete useless storage volume successfully!")
|
||||
return public.return_message(0, 0, _( "successfully delete!"))
|
||||
except docker.errors.APIError as e:
|
||||
return public.return_message(-1, 0, _( "Delete failed! {}".format(e)))
|
||||
Reference in New Issue
Block a user