mirror of https://github.com/jumpserver/jumpserver
perf: 修改平台和资产
parent
706488d293
commit
25bded69ab
|
@ -92,7 +92,7 @@ class HostTypes(PlatformMixin, ChoicesMixin, models.TextChoices):
|
||||||
def platform_constraints(cls):
|
def platform_constraints(cls):
|
||||||
return {
|
return {
|
||||||
cls.LINUX: {
|
cls.LINUX: {
|
||||||
'_protocols': ['ssh', 'sftp', 'rdp', 'vnc', 'telnet']
|
'_protocols': ['ssh', 'rdp', 'vnc', 'telnet']
|
||||||
},
|
},
|
||||||
cls.WINDOWS: {
|
cls.WINDOWS: {
|
||||||
'_protocols': ['ssh', 'rdp', 'vnc'],
|
'_protocols': ['ssh', 'rdp', 'vnc'],
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Generated by Django 3.2.14 on 2022-09-08 11:58
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0110_auto_20220901_1542'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='platform',
|
||||||
|
name='domain_enabled',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Domain enalbed'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='account',
|
||||||
|
name='asset',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accounts', to='assets.asset', verbose_name='Asset'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='asset',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=128, verbose_name='Name'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -31,6 +31,7 @@ class Platform(models.Model):
|
||||||
comment = models.TextField(blank=True, null=True, verbose_name=_("Comment"))
|
comment = models.TextField(blank=True, null=True, verbose_name=_("Comment"))
|
||||||
# 资产有关的
|
# 资产有关的
|
||||||
charset = models.CharField(default='utf8', choices=CHARSET_CHOICES, max_length=8, verbose_name=_("Charset"))
|
charset = models.CharField(default='utf8', choices=CHARSET_CHOICES, max_length=8, verbose_name=_("Charset"))
|
||||||
|
domain_enabled = models.BooleanField(default=True, verbose_name=_("Domain enalbed"))
|
||||||
protocols_enabled = models.BooleanField(default=True, verbose_name=_("Protocols enabled"))
|
protocols_enabled = models.BooleanField(default=True, verbose_name=_("Protocols enabled"))
|
||||||
protocols = models.ManyToManyField(PlatformProtocol, blank=True, verbose_name=_("Protocols"))
|
protocols = models.ManyToManyField(PlatformProtocol, blank=True, verbose_name=_("Protocols"))
|
||||||
gather_facts_enabled = models.BooleanField(default=False, verbose_name=_("Gather facts enabled"))
|
gather_facts_enabled = models.BooleanField(default=False, verbose_name=_("Gather facts enabled"))
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
{% for account in accounts %}
|
|
||||||
- hosts: {{ account.asset.name }}
|
- hosts: {{ account.asset.name }}
|
||||||
vars:
|
vars:
|
||||||
account:
|
account:
|
||||||
|
@ -7,4 +6,3 @@
|
||||||
public_key: {{ account.public_key }}
|
public_key: {{ account.public_key }}
|
||||||
roles:
|
roles:
|
||||||
- change_password
|
- change_password
|
||||||
{% endfor %}
|
|
||||||
|
|
|
@ -17,14 +17,13 @@ class ProtocolSettingSerializer(serializers.Serializer):
|
||||||
('tls', 'TLS'),
|
('tls', 'TLS'),
|
||||||
('nla', 'NLA'),
|
('nla', 'NLA'),
|
||||||
]
|
]
|
||||||
# Common
|
|
||||||
required = serializers.BooleanField(required=True, initial=False, label=_("Required"))
|
|
||||||
|
|
||||||
# RDP
|
# RDP
|
||||||
console = serializers.BooleanField(required=False)
|
console = serializers.BooleanField(required=False)
|
||||||
security = serializers.ChoiceField(choices=SECURITY_CHOICES, default='any', required=False)
|
security = serializers.ChoiceField(choices=SECURITY_CHOICES, default='any')
|
||||||
|
|
||||||
# SFTP
|
# SFTP
|
||||||
sftp_home = serializers.CharField(default='/tmp', required=False)
|
sftp_enabled = serializers.BooleanField(default=True, label=_("SFTP enabled"))
|
||||||
|
sftp_home = serializers.CharField(default='/tmp', label=_("SFTP home"))
|
||||||
|
|
||||||
|
|
||||||
class PlatformProtocolsSerializer(serializers.ModelSerializer):
|
class PlatformProtocolsSerializer(serializers.ModelSerializer):
|
||||||
|
@ -39,7 +38,6 @@ class PlatformSerializer(JMSWritableNestedModelSerializer):
|
||||||
type = LabeledChoiceField(choices=AllTypes.choices, label=_("Type"))
|
type = LabeledChoiceField(choices=AllTypes.choices, label=_("Type"))
|
||||||
category = LabeledChoiceField(choices=Category.choices, label=_("Category"))
|
category = LabeledChoiceField(choices=Category.choices, label=_("Category"))
|
||||||
protocols = PlatformProtocolsSerializer(label=_('Protocols'), many=True, required=False)
|
protocols = PlatformProtocolsSerializer(label=_('Protocols'), many=True, required=False)
|
||||||
type_constraints = serializers.ReadOnlyField(required=False, read_only=True)
|
|
||||||
su_method = LabeledChoiceField(
|
su_method = LabeledChoiceField(
|
||||||
choices=[('sudo', 'sudo su -'), ('su', 'su - ')],
|
choices=[('sudo', 'sudo su -'), ('su', 'su - ')],
|
||||||
label='切换方式', required=False, default='sudo'
|
label='切换方式', required=False, default='sudo'
|
||||||
|
@ -49,17 +47,17 @@ class PlatformSerializer(JMSWritableNestedModelSerializer):
|
||||||
model = Platform
|
model = Platform
|
||||||
fields_mini = ['id', 'name', 'internal']
|
fields_mini = ['id', 'name', 'internal']
|
||||||
fields_small = fields_mini + [
|
fields_small = fields_mini + [
|
||||||
'category', 'type',
|
'category', 'type', 'charset',
|
||||||
]
|
]
|
||||||
fields = fields_small + [
|
fields = fields_small + [
|
||||||
'protocols_enabled', 'protocols',
|
'protocols_enabled', 'protocols', 'domain_enabled',
|
||||||
'gather_facts_enabled', 'gather_facts_method',
|
'gather_facts_enabled', 'gather_facts_method',
|
||||||
'su_enabled', 'su_method',
|
'su_enabled', 'su_method',
|
||||||
'gather_accounts_enabled', 'gather_accounts_method',
|
'gather_accounts_enabled', 'gather_accounts_method',
|
||||||
'create_account_enabled', 'create_account_method',
|
'create_account_enabled', 'create_account_method',
|
||||||
'verify_account_enabled', 'verify_account_method',
|
'verify_account_enabled', 'verify_account_method',
|
||||||
'change_password_enabled', 'change_password_method',
|
'change_password_enabled', 'change_password_method',
|
||||||
'type_constraints', 'comment', 'charset',
|
'comment',
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'su_enabled': {'label': '启用切换账号'},
|
'su_enabled': {'label': '启用切换账号'},
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
# Generated by Django 3.2.14 on 2022-09-08 11:58
|
||||||
|
|
||||||
|
import common.db.fields
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('assets', '0111_auto_20220908_1958'),
|
||||||
|
('ops', '0022_auto_20220817_1346'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AutomationStrategy',
|
||||||
|
fields=[
|
||||||
|
('org_id', models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
|
||||||
|
('created_by', models.CharField(blank=True, max_length=32, null=True, verbose_name='Created by')),
|
||||||
|
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
||||||
|
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
||||||
|
('name', models.CharField(max_length=128, verbose_name='Name')),
|
||||||
|
('is_periodic', models.BooleanField(default=False)),
|
||||||
|
('interval', models.IntegerField(blank=True, default=24, null=True, verbose_name='Cycle perform')),
|
||||||
|
('crontab', models.CharField(blank=True, max_length=128, null=True, verbose_name='Regularly perform')),
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
|
('accounts', models.JSONField(default=list, verbose_name='Accounts')),
|
||||||
|
('comment', models.TextField(blank=True, verbose_name='Comment')),
|
||||||
|
('assets', models.ManyToManyField(blank=True, related_name='automation_strategy', to='assets.Asset', verbose_name='Assets')),
|
||||||
|
('nodes', models.ManyToManyField(blank=True, related_name='automation_strategy', to='assets.Node', verbose_name='Nodes')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Automation plan',
|
||||||
|
'unique_together': {('org_id', 'name')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AutomationStrategyExecution',
|
||||||
|
fields=[
|
||||||
|
('org_id', models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
|
('date_created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('timedelta', models.FloatField(default=0.0, null=True, verbose_name='Time')),
|
||||||
|
('date_start', models.DateTimeField(auto_now_add=True, verbose_name='Date start')),
|
||||||
|
('snapshot', common.db.fields.EncryptJsonDictTextField(blank=True, default=dict, null=True, verbose_name='Automation snapshot')),
|
||||||
|
('trigger', models.CharField(choices=[('manual', 'Manual trigger'), ('timing', 'Timing trigger')], default='manual', max_length=128, verbose_name='Trigger mode')),
|
||||||
|
('strategy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='execution', to='ops.automationstrategy', verbose_name='Automation strategy')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Automation strategy execution',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CollectStrategy',
|
||||||
|
fields=[
|
||||||
|
('automationstrategy_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ops.automationstrategy')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Collect strategy',
|
||||||
|
},
|
||||||
|
bases=('ops.automationstrategy',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PushStrategy',
|
||||||
|
fields=[
|
||||||
|
('automationstrategy_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ops.automationstrategy')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Push strategy',
|
||||||
|
},
|
||||||
|
bases=('ops.automationstrategy',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VerifyStrategy',
|
||||||
|
fields=[
|
||||||
|
('automationstrategy_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ops.automationstrategy')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Verify strategy',
|
||||||
|
},
|
||||||
|
bases=('ops.automationstrategy',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AutomationStrategyTask',
|
||||||
|
fields=[
|
||||||
|
('org_id', models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
|
('is_success', models.BooleanField(default=False, verbose_name='Is success')),
|
||||||
|
('timedelta', models.FloatField(default=0.0, null=True, verbose_name='Time')),
|
||||||
|
('date_start', models.DateTimeField(auto_now_add=True, verbose_name='Date start')),
|
||||||
|
('reason', models.CharField(blank=True, max_length=1024, null=True, verbose_name='Reason')),
|
||||||
|
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.account', verbose_name='Account')),
|
||||||
|
('asset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.asset', verbose_name='Asset')),
|
||||||
|
('execution', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='task', to='ops.automationstrategyexecution', verbose_name='Automation strategy execution')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Automation strategy task',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ChangeAuthStrategy',
|
||||||
|
fields=[
|
||||||
|
('automationstrategy_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ops.automationstrategy')),
|
||||||
|
('is_password', models.BooleanField(default=True)),
|
||||||
|
('password_strategy', models.CharField(blank=True, choices=[('custom', 'Custom password'), ('random_one', 'All assets use the same random password'), ('random_all', 'All assets use different random password')], max_length=128, null=True, verbose_name='Password strategy')),
|
||||||
|
('password_rules', common.db.fields.JsonDictCharField(blank=True, max_length=2048, null=True, verbose_name='Password rules')),
|
||||||
|
('password', common.db.fields.EncryptCharField(blank=True, max_length=256, null=True, verbose_name='Password')),
|
||||||
|
('is_ssh_key', models.BooleanField(default=False)),
|
||||||
|
('ssh_key_strategy', models.CharField(blank=True, choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (The key generated by JumpServer) ')], max_length=128, null=True, verbose_name='SSH Key strategy')),
|
||||||
|
('private_key', common.db.fields.EncryptTextField(blank=True, max_length=4096, null=True, verbose_name='SSH private key')),
|
||||||
|
('public_key', common.db.fields.EncryptTextField(blank=True, max_length=4096, null=True, verbose_name='SSH public key')),
|
||||||
|
('recipients', models.ManyToManyField(blank=True, related_name='recipients_change_auth_strategy', to=settings.AUTH_USER_MODEL, verbose_name='Recipient')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Change auth strategy',
|
||||||
|
},
|
||||||
|
bases=('ops.automationstrategy',),
|
||||||
|
),
|
||||||
|
]
|
Loading…
Reference in New Issue