mirror of https://github.com/jumpserver/jumpserver
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
from django.db.models import TextChoices
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
string_punctuation = '!#$%&()*+,-.:;<=>?@[]^_~'
|
|
DEFAULT_PASSWORD_LENGTH = 30
|
|
DEFAULT_PASSWORD_RULES = {
|
|
'length': DEFAULT_PASSWORD_LENGTH,
|
|
'symbol_set': string_punctuation
|
|
}
|
|
|
|
|
|
class AutomationTypes(TextChoices):
|
|
ping = 'ping', _('Ping')
|
|
gather_facts = 'gather_facts', _('Gather facts')
|
|
push_account = 'push_account', _('Create account')
|
|
change_secret = 'change_secret', _('Change secret')
|
|
verify_account = 'verify_account', _('Verify account')
|
|
gather_accounts = 'gather_accounts', _('Gather accounts')
|
|
|
|
@classmethod
|
|
def get_type_model(cls, tp):
|
|
from assets.models import (
|
|
PingAutomation, GatherFactsAutomation, PushAccountAutomation,
|
|
ChangeSecretAutomation, VerifyAccountAutomation, GatherAccountsAutomation,
|
|
)
|
|
type_model_dict = {
|
|
cls.ping: PingAutomation,
|
|
cls.gather_facts: GatherFactsAutomation,
|
|
cls.push_account: PushAccountAutomation,
|
|
cls.change_secret: ChangeSecretAutomation,
|
|
cls.verify_account: VerifyAccountAutomation,
|
|
cls.gather_accounts: GatherAccountsAutomation,
|
|
}
|
|
return type_model_dict.get(tp)
|
|
|
|
|
|
class SecretStrategy(TextChoices):
|
|
custom = 'specific', _('Specific')
|
|
random_one = 'random_one', _('All assets use the same random password')
|
|
random_all = 'random_all', _('All assets use different random password')
|
|
|
|
|
|
class SSHKeyStrategy(TextChoices):
|
|
add = 'add', _('Append SSH KEY')
|
|
set = 'set', _('Empty and append SSH KEY')
|
|
set_jms = 'set_jms', _('Replace (The key generated by JumpServer) ')
|