mirror of https://github.com/jumpserver/jumpserver
perf: 自动化任务按优先级默认排序
parent
dce68cd011
commit
f592f19b08
|
@ -7,6 +7,7 @@ type:
|
|||
- all
|
||||
method: change_secret
|
||||
protocol: ssh
|
||||
priority: 50
|
||||
params:
|
||||
- name: commands
|
||||
type: list
|
||||
|
|
|
@ -5,6 +5,7 @@ method: change_secret
|
|||
category: host
|
||||
type:
|
||||
- windows
|
||||
priority: 49
|
||||
params:
|
||||
- name: groups
|
||||
type: str
|
||||
|
|
|
@ -5,6 +5,7 @@ method: push_account
|
|||
category: host
|
||||
type:
|
||||
- windows
|
||||
priority: 49
|
||||
params:
|
||||
- name: groups
|
||||
type: str
|
||||
|
|
|
@ -6,6 +6,7 @@ type:
|
|||
- windows
|
||||
method: verify_account
|
||||
protocol: rdp
|
||||
priority: 1
|
||||
|
||||
i18n:
|
||||
Windows rdp account verify:
|
||||
|
|
|
@ -7,6 +7,7 @@ type:
|
|||
- all
|
||||
method: verify_account
|
||||
protocol: ssh
|
||||
priority: 50
|
||||
|
||||
i18n:
|
||||
SSH account verify:
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
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
|
||||
|
||||
|
||||
def sorted_methods(methods):
|
||||
return sorted(methods, key=lambda x: x.get('priority', 10))
|
||||
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
platform_automation_methods = get_platform_automation_methods(BASE_DIR)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ type:
|
|||
- windows
|
||||
method: ping
|
||||
protocol: rdp
|
||||
priority: 1
|
||||
|
||||
i18n:
|
||||
Ping by pyfreerdp:
|
||||
|
|
|
@ -7,6 +7,7 @@ type:
|
|||
- all
|
||||
method: ping
|
||||
protocol: ssh
|
||||
priority: 50
|
||||
|
||||
i18n:
|
||||
Ping by paramiko:
|
||||
|
|
|
@ -90,7 +90,7 @@ class AllTypes(ChoicesMixin):
|
|||
|
||||
@classmethod
|
||||
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_methods = {}
|
||||
platform_automation_methods = cls.get_automation_methods()
|
||||
|
@ -101,6 +101,7 @@ class AllTypes(ChoicesMixin):
|
|||
methods = filter_platform_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]
|
||||
automation_methods[item_name + '_methods'] = methods
|
||||
automation.update(automation_methods)
|
||||
|
|
Loading…
Reference in New Issue