mirror of https://github.com/jumpserver/jumpserver
Merge pull request #9641 from jumpserver/pr@dev@perf_ansible_gateway
fix: 修复 ansible 网关问题pull/9643/head
commit
17a77586f7
|
@ -60,9 +60,7 @@ class AccountSerializerCreateValidateMixin:
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
class AccountSerializerCreateMixin(
|
class AccountSerializerCreateMixin(AccountSerializerCreateValidateMixin, BulkModelSerializer):
|
||||||
AccountSerializerCreateValidateMixin, BulkModelSerializer
|
|
||||||
):
|
|
||||||
template = serializers.BooleanField(
|
template = serializers.BooleanField(
|
||||||
default=False, label=_("Template"), write_only=True
|
default=False, label=_("Template"), write_only=True
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,13 +3,12 @@
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
from accounts.models import AccountBackupAutomation, AccountBackupExecution
|
||||||
from ops.mixin import PeriodTaskSerializerMixin
|
|
||||||
from common.utils import get_logger
|
|
||||||
from common.const.choices import Trigger
|
from common.const.choices import Trigger
|
||||||
from common.serializers.fields import LabeledChoiceField
|
from common.serializers.fields import LabeledChoiceField
|
||||||
|
from common.utils import get_logger
|
||||||
from accounts.models import AccountBackupAutomation, AccountBackupExecution
|
from ops.mixin import PeriodTaskSerializerMixin
|
||||||
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
@ -20,18 +19,21 @@ class AccountBackupSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSer
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AccountBackupAutomation
|
model = AccountBackupAutomation
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'date_created', 'date_updated', 'created_by', 'periodic_display', 'executed_amount'
|
'date_created', 'date_updated', 'created_by',
|
||||||
|
'periodic_display', 'executed_amount'
|
||||||
]
|
]
|
||||||
fields = read_only_fields + [
|
fields = read_only_fields + [
|
||||||
'id', 'name', 'is_periodic', 'interval', 'crontab', 'comment', 'recipients', 'types'
|
'id', 'name', 'is_periodic', 'interval', 'crontab',
|
||||||
|
'comment', 'recipients', 'types'
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'name': {'required': True},
|
'name': {'required': True},
|
||||||
'periodic_display': {'label': _('Periodic perform')},
|
'periodic_display': {'label': _('Periodic perform')},
|
||||||
'executed_amount': {'label': _('Executed amount')},
|
'executed_amount': {'label': _('Executed amount')},
|
||||||
'recipients': {'label': _('Recipient'), 'help_text': _(
|
'recipients': {
|
||||||
'Currently only mail sending is supported'
|
'label': _('Recipient'),
|
||||||
)},
|
'help_text': _('Currently only mail sending is supported')
|
||||||
|
},
|
||||||
'types': {'label': _('Asset type')}
|
'types': {'label': _('Asset type')}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ class AccountBackupPlanExecutionSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AccountBackupExecution
|
model = AccountBackupExecution
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'id', 'date_start', 'timedelta', 'plan_snapshot', 'trigger', 'reason',
|
'id', 'date_start', 'timedelta', 'plan_snapshot',
|
||||||
'is_success', 'org_id', 'recipients'
|
'trigger', 'reason', 'is_success', 'org_id', 'recipients'
|
||||||
]
|
]
|
||||||
fields = read_only_fields + ['plan']
|
fields = read_only_fields + ['plan']
|
||||||
|
|
|
@ -54,7 +54,7 @@ class JMSInventory:
|
||||||
if gateway.private_key:
|
if gateway.private_key:
|
||||||
proxy_command_list.append("-i {}".format(gateway.private_key_path))
|
proxy_command_list.append("-i {}".format(gateway.private_key_path))
|
||||||
|
|
||||||
proxy_command = "'-o ProxyCommand={}'".format(
|
proxy_command = '-o ProxyCommand=\"{}\"'.format(
|
||||||
" ".join(proxy_command_list)
|
" ".join(proxy_command_list)
|
||||||
)
|
)
|
||||||
return {"ansible_ssh_common_args": proxy_command}
|
return {"ansible_ssh_common_args": proxy_command}
|
||||||
|
|
Loading…
Reference in New Issue