mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-17 08:21:38 +00:00
perf: 自动化任务按优先级默认排序
This commit is contained in:
parent
dce68cd011
commit
f592f19b08
@ -7,6 +7,7 @@ type:
|
|||||||
- all
|
- all
|
||||||
method: change_secret
|
method: change_secret
|
||||||
protocol: ssh
|
protocol: ssh
|
||||||
|
priority: 50
|
||||||
params:
|
params:
|
||||||
- name: commands
|
- name: commands
|
||||||
type: list
|
type: list
|
||||||
|
@ -5,6 +5,7 @@ method: change_secret
|
|||||||
category: host
|
category: host
|
||||||
type:
|
type:
|
||||||
- windows
|
- windows
|
||||||
|
priority: 49
|
||||||
params:
|
params:
|
||||||
- name: groups
|
- name: groups
|
||||||
type: str
|
type: str
|
||||||
|
@ -5,6 +5,7 @@ method: push_account
|
|||||||
category: host
|
category: host
|
||||||
type:
|
type:
|
||||||
- windows
|
- windows
|
||||||
|
priority: 49
|
||||||
params:
|
params:
|
||||||
- name: groups
|
- name: groups
|
||||||
type: str
|
type: str
|
||||||
|
@ -6,6 +6,7 @@ type:
|
|||||||
- windows
|
- windows
|
||||||
method: verify_account
|
method: verify_account
|
||||||
protocol: rdp
|
protocol: rdp
|
||||||
|
priority: 1
|
||||||
|
|
||||||
i18n:
|
i18n:
|
||||||
Windows rdp account verify:
|
Windows rdp account verify:
|
||||||
|
@ -7,6 +7,7 @@ type:
|
|||||||
- all
|
- all
|
||||||
method: verify_account
|
method: verify_account
|
||||||
protocol: ssh
|
protocol: ssh
|
||||||
|
priority: 50
|
||||||
|
|
||||||
i18n:
|
i18n:
|
||||||
SSH account verify:
|
SSH account verify:
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
from .endpoint import ExecutionManager
|
from .endpoint import ExecutionManager
|
||||||
from .methods import platform_automation_methods, filter_platform_methods
|
from .methods import platform_automation_methods, filter_platform_methods, sorted_methods
|
||||||
|
@ -68,6 +68,10 @@ def filter_platform_methods(category, tp_name, method=None, methods=None):
|
|||||||
return methods
|
return methods
|
||||||
|
|
||||||
|
|
||||||
|
def sorted_methods(methods):
|
||||||
|
return sorted(methods, key=lambda x: x.get('priority', 10))
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
platform_automation_methods = get_platform_automation_methods(BASE_DIR)
|
platform_automation_methods = get_platform_automation_methods(BASE_DIR)
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ type:
|
|||||||
- windows
|
- windows
|
||||||
method: ping
|
method: ping
|
||||||
protocol: rdp
|
protocol: rdp
|
||||||
|
priority: 1
|
||||||
|
|
||||||
i18n:
|
i18n:
|
||||||
Ping by pyfreerdp:
|
Ping by pyfreerdp:
|
||||||
|
@ -7,6 +7,7 @@ type:
|
|||||||
- all
|
- all
|
||||||
method: ping
|
method: ping
|
||||||
protocol: ssh
|
protocol: ssh
|
||||||
|
priority: 50
|
||||||
|
|
||||||
i18n:
|
i18n:
|
||||||
Ping by paramiko:
|
Ping by paramiko:
|
||||||
|
@ -90,7 +90,7 @@ class AllTypes(ChoicesMixin):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_automation_methods(cls, category, tp_name, constraints):
|
def set_automation_methods(cls, category, tp_name, constraints):
|
||||||
from assets.automations import filter_platform_methods
|
from assets.automations import filter_platform_methods, sorted_methods
|
||||||
automation = constraints.get('automation', {})
|
automation = constraints.get('automation', {})
|
||||||
automation_methods = {}
|
automation_methods = {}
|
||||||
platform_automation_methods = cls.get_automation_methods()
|
platform_automation_methods = cls.get_automation_methods()
|
||||||
@ -101,6 +101,7 @@ class AllTypes(ChoicesMixin):
|
|||||||
methods = filter_platform_methods(
|
methods = filter_platform_methods(
|
||||||
category, tp_name, item_name, methods=platform_automation_methods
|
category, tp_name, item_name, methods=platform_automation_methods
|
||||||
)
|
)
|
||||||
|
methods = sorted_methods(methods)
|
||||||
methods = [{'name': m['name'], 'id': m['id']} for m in methods]
|
methods = [{'name': m['name'], 'id': m['id']} for m in methods]
|
||||||
automation_methods[item_name + '_methods'] = methods
|
automation_methods[item_name + '_methods'] = methods
|
||||||
automation.update(automation_methods)
|
automation.update(automation_methods)
|
||||||
|
Loading…
Reference in New Issue
Block a user