mirror of https://github.com/jumpserver/jumpserver
parent
1298cc0a91
commit
fc2d7aafce
|
@ -1,9 +1,9 @@
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from common.utils import get_logger
|
from accounts.automations.methods import platform_automation_methods
|
||||||
from accounts.const import SecretType
|
from accounts.const import SecretType
|
||||||
from assets.automations.base.manager import BasePlaybookManager
|
from assets.automations.base.manager import BasePlaybookManager
|
||||||
from accounts.automations.methods import platform_automation_methods
|
from common.utils import get_logger
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from copy import deepcopy
|
|
||||||
from openpyxl import Workbook
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from openpyxl import Workbook
|
||||||
|
|
||||||
from users.models import User
|
from accounts.const import AutomationTypes, SecretType, SSHKeyStrategy, SecretStrategy
|
||||||
from accounts.models import ChangeSecretRecord
|
from accounts.models import ChangeSecretRecord
|
||||||
from accounts.notifications import ChangeSecretExecutionTaskMsg
|
from accounts.notifications import ChangeSecretExecutionTaskMsg
|
||||||
from accounts.serializers import ChangeSecretRecordBackUpSerializer
|
from accounts.serializers import ChangeSecretRecordBackUpSerializer
|
||||||
from accounts.const import AutomationTypes, SecretType, SSHKeyStrategy, SecretStrategy
|
|
||||||
from common.utils import get_logger, lazyproperty
|
from common.utils import get_logger, lazyproperty
|
||||||
from common.utils.file import encrypt_and_compress_zip_file
|
from common.utils.file import encrypt_and_compress_zip_file
|
||||||
from common.utils.timezone import local_now_display
|
from common.utils.timezone import local_now_display
|
||||||
from ...utils import SecretGenerator
|
from users.models import User
|
||||||
from ..base.manager import AccountBasePlaybookManager
|
from ..base.manager import AccountBasePlaybookManager
|
||||||
|
from ...utils import SecretGenerator
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class ChangeSecretManager(AccountBasePlaybookManager):
|
||||||
recorder.status = 'success'
|
recorder.status = 'success'
|
||||||
recorder.date_finished = timezone.now()
|
recorder.date_finished = timezone.now()
|
||||||
recorder.save()
|
recorder.save()
|
||||||
|
print('recorder.new_secret', recorder.new_secret)
|
||||||
account = recorder.account
|
account = recorder.account
|
||||||
account.secret = recorder.new_secret
|
account.secret = recorder.new_secret
|
||||||
account.save(update_fields=['secret'])
|
account.save(update_fields=['secret'])
|
||||||
|
|
|
@ -2,9 +2,9 @@ from copy import deepcopy
|
||||||
|
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
|
|
||||||
from common.utils import get_logger
|
|
||||||
from accounts.models import Account
|
|
||||||
from accounts.const import AutomationTypes, SecretType
|
from accounts.const import AutomationTypes, SecretType
|
||||||
|
from accounts.models import Account
|
||||||
|
from common.utils import get_logger
|
||||||
from ..base.manager import AccountBasePlaybookManager
|
from ..base.manager import AccountBasePlaybookManager
|
||||||
from ..change_secret.manager import ChangeSecretManager
|
from ..change_secret.manager import ChangeSecretManager
|
||||||
|
|
||||||
|
@ -66,15 +66,15 @@ class PushAccountManager(ChangeSecretManager, AccountBasePlaybookManager):
|
||||||
h['name'] += '_' + account.username
|
h['name'] += '_' + account.username
|
||||||
new_secret = self.get_secret()
|
new_secret = self.get_secret()
|
||||||
|
|
||||||
|
self.name_recorder_mapper[h['name']] = {
|
||||||
|
'account': account, 'new_secret': new_secret,
|
||||||
|
}
|
||||||
|
|
||||||
private_key_path = None
|
private_key_path = None
|
||||||
if self.secret_type == SecretType.SSH_KEY:
|
if self.secret_type == SecretType.SSH_KEY:
|
||||||
private_key_path = self.generate_private_key_path(new_secret, path_dir)
|
private_key_path = self.generate_private_key_path(new_secret, path_dir)
|
||||||
new_secret = self.generate_public_key(new_secret)
|
new_secret = self.generate_public_key(new_secret)
|
||||||
|
|
||||||
self.name_recorder_mapper[h['name']] = {
|
|
||||||
'account': account, 'new_secret': new_secret,
|
|
||||||
}
|
|
||||||
|
|
||||||
h['kwargs'] = self.get_kwargs(account, new_secret)
|
h['kwargs'] = self.get_kwargs(account, new_secret)
|
||||||
h['account'] = {
|
h['account'] = {
|
||||||
'name': account.name,
|
'name': account.name,
|
||||||
|
@ -92,6 +92,7 @@ class PushAccountManager(ChangeSecretManager, AccountBasePlaybookManager):
|
||||||
account_info = self.name_recorder_mapper.get(host)
|
account_info = self.name_recorder_mapper.get(host)
|
||||||
if not account_info:
|
if not account_info:
|
||||||
return
|
return
|
||||||
|
print('account_info', account_info)
|
||||||
account = account_info['account']
|
account = account_info['account']
|
||||||
new_secret = account_info['new_secret']
|
new_secret = account_info['new_secret']
|
||||||
if not account:
|
if not account:
|
||||||
|
|
Loading…
Reference in New Issue