From 32b6a1f1a419e86aa0cf6c64dbcdc264f5804db5 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Thu, 22 Sep 2022 19:09:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/applications/utils/__init__.py | 1 - apps/locale/ja/LC_MESSAGES/django.mo | 4 +- apps/locale/ja/LC_MESSAGES/django.po | 70 +++++++++++---------------- apps/locale/zh/LC_MESSAGES/django.mo | 4 +- apps/locale/zh/LC_MESSAGES/django.po | 69 +++++++++++--------------- apps/terminal/models/endpoint.py | 1 - apps/terminal/utils/db_port_mapper.py | 20 +++++--- 7 files changed, 74 insertions(+), 95 deletions(-) diff --git a/apps/applications/utils/__init__.py b/apps/applications/utils/__init__.py index de3a7cd10..5efec40b2 100644 --- a/apps/applications/utils/__init__.py +++ b/apps/applications/utils/__init__.py @@ -2,4 +2,3 @@ # from .kubernetes_util import * -from .db_port_mapper import * diff --git a/apps/locale/ja/LC_MESSAGES/django.mo b/apps/locale/ja/LC_MESSAGES/django.mo index 447ad1294..2be8bf9ac 100644 --- a/apps/locale/ja/LC_MESSAGES/django.mo +++ b/apps/locale/ja/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac618645a3defe4a3cd217dac34b95e6edd10ec30fc2273cd13f8da1c00f9fcf -size 132101 +oid sha256:529cf82721ab8594a7ee8e4e1bff1f80fb702d3bfcbb5fb6e7bfb8b897d4920b +size 132560 diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 11caa1be4..9a11dd47b 100644 --- a/apps/locale/ja/LC_MESSAGES/django.po +++ b/apps/locale/ja/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-22 17:23+0800\n" +"POT-Creation-Date: 2022-09-22 19:01+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,7 +29,7 @@ msgstr "Acls" #: assets/models/group.py:20 assets/models/label.py:18 ops/mixin.py:24 #: orgs/models.py:70 perms/models/base.py:83 rbac/models/role.py:29 #: settings/models.py:33 settings/serializers/sms.py:6 -#: terminal/models/endpoint.py:13 terminal/models/endpoint.py:90 +#: terminal/models/endpoint.py:14 terminal/models/endpoint.py:87 #: terminal/models/storage.py:26 terminal/models/task.py:16 #: terminal/models/terminal.py:100 users/forms/profile.py:33 #: users/models/group.py:15 users/models/user.py:669 @@ -38,12 +38,12 @@ msgid "Name" msgstr "名前" #: acls/models/base.py:27 assets/models/cmd_filter.py:84 -#: assets/models/user.py:251 terminal/models/endpoint.py:93 +#: assets/models/user.py:251 terminal/models/endpoint.py:90 msgid "Priority" msgstr "優先順位" #: acls/models/base.py:28 assets/models/cmd_filter.py:84 -#: assets/models/user.py:251 terminal/models/endpoint.py:94 +#: assets/models/user.py:251 terminal/models/endpoint.py:91 msgid "1-100, the lower the value will be match first" msgstr "1-100、低い値は最初に一致します" @@ -61,7 +61,7 @@ msgstr "アクティブ" #: assets/models/domain.py:65 assets/models/group.py:23 #: assets/models/label.py:23 ops/models/adhoc.py:38 orgs/models.py:73 #: perms/models/base.py:93 rbac/models/role.py:37 settings/models.py:38 -#: terminal/models/endpoint.py:21 terminal/models/endpoint.py:100 +#: terminal/models/endpoint.py:22 terminal/models/endpoint.py:97 #: terminal/models/storage.py:29 terminal/models/terminal.py:114 #: tickets/models/comment.py:32 tickets/models/ticket/general.py:288 #: users/models/group.py:16 users/models/user.py:706 @@ -185,7 +185,7 @@ msgstr "" #: authentication/templates/authentication/_msg_oauth_bind.html:12 #: authentication/templates/authentication/_msg_rest_password_success.html:8 #: authentication/templates/authentication/_msg_rest_public_key_success.html:8 -#: settings/serializers/terminal.py:8 terminal/serializers/endpoint.py:53 +#: settings/serializers/terminal.py:8 terminal/serializers/endpoint.py:54 msgid "IP" msgstr "IP" @@ -388,7 +388,7 @@ msgstr "クラスター" #: applications/serializers/attrs/application_category/db.py:11 #: ops/models/adhoc.py:157 settings/serializers/auth/radius.py:14 -#: settings/serializers/auth/sms.py:65 terminal/models/endpoint.py:14 +#: settings/serializers/auth/sms.py:65 terminal/models/endpoint.py:15 #: xpack/plugins/cloud/serializers/account_attrs.py:72 msgid "Host" msgstr "ホスト" @@ -4951,34 +4951,34 @@ msgstr "ストレージが無効です" msgid "Command record" msgstr "コマンドレコード" -#: terminal/models/endpoint.py:16 +#: terminal/models/endpoint.py:17 msgid "HTTPS Port" msgstr "HTTPS ポート" -#: terminal/models/endpoint.py:17 terminal/models/terminal.py:107 +#: terminal/models/endpoint.py:18 terminal/models/terminal.py:107 msgid "HTTP Port" msgstr "HTTP ポート" -#: terminal/models/endpoint.py:18 terminal/models/terminal.py:106 +#: terminal/models/endpoint.py:19 terminal/models/terminal.py:106 msgid "SSH Port" msgstr "SSH ポート" -#: terminal/models/endpoint.py:19 +#: terminal/models/endpoint.py:20 msgid "RDP Port" msgstr "RDP ポート" -#: terminal/models/endpoint.py:26 terminal/models/endpoint.py:98 -#: terminal/serializers/endpoint.py:56 terminal/serializers/storage.py:38 +#: terminal/models/endpoint.py:27 terminal/models/endpoint.py:95 +#: terminal/serializers/endpoint.py:57 terminal/serializers/storage.py:38 #: terminal/serializers/storage.py:50 terminal/serializers/storage.py:80 #: terminal/serializers/storage.py:90 terminal/serializers/storage.py:98 msgid "Endpoint" msgstr "エンドポイント" -#: terminal/models/endpoint.py:91 +#: terminal/models/endpoint.py:88 msgid "IP group" msgstr "IP グループ" -#: terminal/models/endpoint.py:103 +#: terminal/models/endpoint.py:100 msgid "Endpoint rule" msgstr "エンドポイントルール" @@ -5159,21 +5159,21 @@ msgstr "レベル" msgid "Batch danger command alert" msgstr "一括危険コマンド警告" -#: terminal/serializers/endpoint.py:13 +#: terminal/serializers/endpoint.py:14 msgid "Magnus listen db port" msgstr "Magnus がリッスンするデータベース ポート" -#: terminal/serializers/endpoint.py:16 +#: terminal/serializers/endpoint.py:17 msgid "Magnus Listen port range" msgstr "Magnus がリッスンするポート範囲" -#: terminal/serializers/endpoint.py:18 +#: terminal/serializers/endpoint.py:19 msgid "" "The range of ports that Magnus listens on is modified in the configuration " "file" msgstr "Magnus がリッスンするポート範囲を構成ファイルで変更してください" -#: terminal/serializers/endpoint.py:50 +#: terminal/serializers/endpoint.py:51 msgid "" "If asset IP addresses under different endpoints conflict, use asset labels" msgstr "" @@ -5302,6 +5302,16 @@ msgstr "見つかりません" msgid "view" msgstr "表示" +#: terminal/utils/db_port_mapper.py:77 +msgid "" +"No ports can be used, check and modify the limit on the number of ports that " +"Magnus listens on in the configuration file." +msgstr "使用できるポートがありません。設定ファイルで Magnus がリッスンするポート数の制限を確認して変更してください. " + +#: terminal/utils/db_port_mapper.py:79 +msgid "All available port count: {}, Already use port count: {}" +msgstr "使用可能なすべてのポート数: {}、すでに使用しているポート数: {}" + #: tickets/apps.py:7 msgid "Tickets" msgstr "チケット" @@ -6996,25 +7006,3 @@ msgstr "究極のエディション" #: xpack/plugins/license/models.py:77 msgid "Community edition" msgstr "コミュニティ版" - -#~ msgid "Magnus currently supports only 11g and 12c connections" -#~ msgstr "" -#~ "現在、Magnusは11gおよび12cバージョンへの接続のみをサポートしています" - -#~ msgid "MySQL Port" -#~ msgstr "MySQL ポート" - -#~ msgid "MariaDB Port" -#~ msgstr "MariaDB ポート" - -#~ msgid "PostgreSQL Port" -#~ msgstr "PostgreSQL ポート" - -#~ msgid "Redis Port" -#~ msgstr "Redis ポート" - -#~ msgid "Oracle 11g Port" -#~ msgstr "Oracle 11g ポート" - -#~ msgid "Oracle 12c Port" -#~ msgstr "Oracle 12c ポート" diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 99fd77b14..a804b70c8 100644 --- a/apps/locale/zh/LC_MESSAGES/django.mo +++ b/apps/locale/zh/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc9d0fe73352de035ee77c477e143d6209a18ba533e232f0a39f8c7440379f04 -size 108810 +oid sha256:a346a8166af782cbc41eac33475b4cfac2e3713b26f84ddf6fa532742133b89d +size 109216 diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index dcb0f325f..f307cbb71 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-22 17:23+0800\n" +"POT-Creation-Date: 2022-09-22 19:01+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -28,7 +28,7 @@ msgstr "访问控制" #: assets/models/group.py:20 assets/models/label.py:18 ops/mixin.py:24 #: orgs/models.py:70 perms/models/base.py:83 rbac/models/role.py:29 #: settings/models.py:33 settings/serializers/sms.py:6 -#: terminal/models/endpoint.py:13 terminal/models/endpoint.py:90 +#: terminal/models/endpoint.py:14 terminal/models/endpoint.py:87 #: terminal/models/storage.py:26 terminal/models/task.py:16 #: terminal/models/terminal.py:100 users/forms/profile.py:33 #: users/models/group.py:15 users/models/user.py:669 @@ -37,12 +37,12 @@ msgid "Name" msgstr "名称" #: acls/models/base.py:27 assets/models/cmd_filter.py:84 -#: assets/models/user.py:251 terminal/models/endpoint.py:93 +#: assets/models/user.py:251 terminal/models/endpoint.py:90 msgid "Priority" msgstr "优先级" #: acls/models/base.py:28 assets/models/cmd_filter.py:84 -#: assets/models/user.py:251 terminal/models/endpoint.py:94 +#: assets/models/user.py:251 terminal/models/endpoint.py:91 msgid "1-100, the lower the value will be match first" msgstr "优先级可选范围为 1-100 (数值越小越优先)" @@ -60,7 +60,7 @@ msgstr "激活中" #: assets/models/domain.py:65 assets/models/group.py:23 #: assets/models/label.py:23 ops/models/adhoc.py:38 orgs/models.py:73 #: perms/models/base.py:93 rbac/models/role.py:37 settings/models.py:38 -#: terminal/models/endpoint.py:21 terminal/models/endpoint.py:100 +#: terminal/models/endpoint.py:22 terminal/models/endpoint.py:97 #: terminal/models/storage.py:29 terminal/models/terminal.py:114 #: tickets/models/comment.py:32 tickets/models/ticket/general.py:288 #: users/models/group.py:16 users/models/user.py:706 @@ -183,7 +183,7 @@ msgstr "" #: authentication/templates/authentication/_msg_oauth_bind.html:12 #: authentication/templates/authentication/_msg_rest_password_success.html:8 #: authentication/templates/authentication/_msg_rest_public_key_success.html:8 -#: settings/serializers/terminal.py:8 terminal/serializers/endpoint.py:53 +#: settings/serializers/terminal.py:8 terminal/serializers/endpoint.py:54 msgid "IP" msgstr "IP" @@ -383,7 +383,7 @@ msgstr "集群" #: applications/serializers/attrs/application_category/db.py:11 #: ops/models/adhoc.py:157 settings/serializers/auth/radius.py:14 -#: settings/serializers/auth/sms.py:65 terminal/models/endpoint.py:14 +#: settings/serializers/auth/sms.py:65 terminal/models/endpoint.py:15 #: xpack/plugins/cloud/serializers/account_attrs.py:72 msgid "Host" msgstr "主机" @@ -4874,34 +4874,34 @@ msgstr "存储无效" msgid "Command record" msgstr "命令记录" -#: terminal/models/endpoint.py:16 +#: terminal/models/endpoint.py:17 msgid "HTTPS Port" msgstr "HTTPS 端口" -#: terminal/models/endpoint.py:17 terminal/models/terminal.py:107 +#: terminal/models/endpoint.py:18 terminal/models/terminal.py:107 msgid "HTTP Port" msgstr "HTTP 端口" -#: terminal/models/endpoint.py:18 terminal/models/terminal.py:106 +#: terminal/models/endpoint.py:19 terminal/models/terminal.py:106 msgid "SSH Port" msgstr "SSH 端口" -#: terminal/models/endpoint.py:19 +#: terminal/models/endpoint.py:20 msgid "RDP Port" msgstr "RDP 端口" -#: terminal/models/endpoint.py:26 terminal/models/endpoint.py:98 -#: terminal/serializers/endpoint.py:56 terminal/serializers/storage.py:38 +#: terminal/models/endpoint.py:27 terminal/models/endpoint.py:95 +#: terminal/serializers/endpoint.py:57 terminal/serializers/storage.py:38 #: terminal/serializers/storage.py:50 terminal/serializers/storage.py:80 #: terminal/serializers/storage.py:90 terminal/serializers/storage.py:98 msgid "Endpoint" msgstr "端点" -#: terminal/models/endpoint.py:91 +#: terminal/models/endpoint.py:88 msgid "IP group" msgstr "IP 组" -#: terminal/models/endpoint.py:103 +#: terminal/models/endpoint.py:100 msgid "Endpoint rule" msgstr "端点规则" @@ -5082,21 +5082,21 @@ msgstr "级别" msgid "Batch danger command alert" msgstr "批量危险命令告警" -#: terminal/serializers/endpoint.py:13 +#: terminal/serializers/endpoint.py:14 msgid "Magnus listen db port" msgstr "Magnus 监听的数据库端口" -#: terminal/serializers/endpoint.py:16 +#: terminal/serializers/endpoint.py:17 msgid "Magnus Listen port range" msgstr "Magnus 监听的端口范围" -#: terminal/serializers/endpoint.py:18 +#: terminal/serializers/endpoint.py:19 msgid "" "The range of ports that Magnus listens on is modified in the configuration " "file" msgstr "请在配置文件中修改 Magnus 监听的端口范围" -#: terminal/serializers/endpoint.py:50 +#: terminal/serializers/endpoint.py:51 msgid "" "If asset IP addresses under different endpoints conflict, use asset labels" msgstr "如果不同端点下的资产 IP 有冲突,使用资产标签实现" @@ -5223,6 +5223,16 @@ msgstr "没有发现" msgid "view" msgstr "查看" +#: terminal/utils/db_port_mapper.py:77 +msgid "" +"No ports can be used, check and modify the limit on the number of ports that " +"Magnus listens on in the configuration file." +msgstr "没有端口可以使用,检查并修改配置文件中 Magnus 监听的端口数量限制。" + +#: terminal/utils/db_port_mapper.py:79 +msgid "All available port count: {}, Already use port count: {}" +msgstr "所有可用端口数量:{},已使用端口数量:{}" + #: tickets/apps.py:7 msgid "Tickets" msgstr "工单管理" @@ -6897,24 +6907,3 @@ msgstr "旗舰版" #: xpack/plugins/license/models.py:77 msgid "Community edition" msgstr "社区版" - -#~ msgid "Magnus currently supports only 11g and 12c connections" -#~ msgstr "目前 Magnus 只支持连接 11g、12c 版本" - -#~ msgid "MySQL Port" -#~ msgstr "MySQL 端口" - -#~ msgid "MariaDB Port" -#~ msgstr "MariaDB 端口" - -#~ msgid "PostgreSQL Port" -#~ msgstr "PostgreSQL 端口" - -#~ msgid "Redis Port" -#~ msgstr "Redis 端口" - -#~ msgid "Oracle 11g Port" -#~ msgstr "Oracle 11g 端口" - -#~ msgid "Oracle 12c Port" -#~ msgstr "Oracle 12c 端口" diff --git a/apps/terminal/models/endpoint.py b/apps/terminal/models/endpoint.py index 9d65fa271..fec3a1282 100644 --- a/apps/terminal/models/endpoint.py +++ b/apps/terminal/models/endpoint.py @@ -6,7 +6,6 @@ from ..utils import db_port_manager, DBPortManager from common.db.models import JMSModel from common.db.fields import PortField from common.utils.ip import contains_ip -from common.exceptions import JMSException db_port_manager: DBPortManager diff --git a/apps/terminal/utils/db_port_mapper.py b/apps/terminal/utils/db_port_mapper.py index 2ca84cc0e..d485aaf81 100644 --- a/apps/terminal/utils/db_port_mapper.py +++ b/apps/terminal/utils/db_port_mapper.py @@ -1,12 +1,13 @@ -from common.decorator import Singleton +from django.utils.translation import ugettext_lazy as _ from django.core.cache import cache from django.conf import settings + +from common.decorator import Singleton +from common.utils import get_logger, get_object_or_none +from common.exceptions import JMSException from applications.const import AppCategory from applications.models import Application -from common.utils import get_logger -from common.utils import get_object_or_none from orgs.utils import tmp_to_root_org -from common.exceptions import JMSException logger = get_logger(__file__) @@ -23,7 +24,7 @@ class DBPortManager(object): self.port_limit = settings.MAGNUS_DB_PORTS_LIMIT_COUNT self.port_end = self.port_start + self.port_limit # 可以使用的端口列表 - self.all_available_ports = list(range(self.port_start, self.port_end + 1)) + self.all_available_ports = list(range(self.port_start, self.port_end)) @property def magnus_listen_port_range(self): @@ -73,10 +74,13 @@ class DBPortManager(object): already_use_ports = self.get_already_use_ports() available_ports = sorted(list(set(self.all_available_ports) - set(already_use_ports))) if len(available_ports) <= 0: - raise JMSException( - 'No port is available, All available port count: {}, Already use port count: {}' - ''.format(len(self.all_available_ports), len(already_use_ports)) + msg = _('No ports can be used, check and modify the limit on the number ' + 'of ports that Magnus listens on in the configuration file.') + tips = _('All available port count: {}, Already use port count: {}').format( + len(self.all_available_ports), len(already_use_ports) ) + error = msg + tips + raise JMSException(error) port = available_ports[0] logger.debug('Get next available port: {}'.format(port)) return port