fix: 修复工单数据库命令复合bug (#8511)

Co-authored-by: feng626 <1304903146@qq.com>
pull/8512/head
fit2bot 2 years ago committed by GitHub
parent 05826abf9d
commit 067a90ff9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -171,7 +171,7 @@ class CommandFilterRule(OrgModelMixin):
'type': TicketType.command_confirm,
'applicant': session.user_obj,
'apply_run_user_id': session.user_id,
'apply_run_asset_id': session.asset_id,
'apply_run_asset': str(session.asset),
'apply_run_system_user_id': session.system_user_id,
'apply_run_command': run_command[:4090],
'apply_from_session_id': str(session.id),

@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-
#
from django.db.models import TextChoices
from django.utils.translation import ugettext_lazy as _

@ -69,6 +69,11 @@ exclude_permissions = (
('tickets', 'ticket', 'add,delete,change', 'ticket'),
('tickets', 'ticketstep', '*', '*'),
('tickets', 'approvalrule', '*', '*'),
('tickets', 'applyloginticket', '*', '*'),
('tickets', 'applyloginassetticket', '*', '*'),
('tickets', 'applycommandticket', '*', '*'),
('tickets', 'applyassetticket', '*', '*'),
('tickets', 'applyapplicationticket', '*', '*'),
('tickets', 'superticket', 'delete', 'superticket'),
('tickets', 'ticketsession', 'view,delete', 'ticketsession'),
('xpack', 'interface', '*', '*'),

@ -59,7 +59,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='ticket',
name='state',
field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'),
field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'),
('closed', 'Cancel'), ('reopen', 'Reopen')], default='pending',
max_length=16, verbose_name='State'),
),
@ -72,14 +72,14 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='ticketassignee',
name='state',
field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'),
field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'),
('closed', 'Cancel'), ('reopen', 'Reopen')], default='pending',
max_length=64),
),
migrations.AlterField(
model_name='ticketstep',
name='state',
field=models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'),
field=models.CharField(choices=[('pending', 'Open'), ('approved', 'Approved'), ('rejected', 'Rejected'),
('closed', 'Closed')], default='pending', max_length=64,
verbose_name='State'),
),
@ -111,6 +111,7 @@ class Migration(migrations.Migration):
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True,
primary_key=True, serialize=False, to='tickets.ticket')),
('apply_run_command', models.CharField(max_length=4096, verbose_name='Run command')),
('apply_run_asset', models.CharField(max_length=128, verbose_name='Run asset')),
('apply_from_cmd_filter',
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.commandfilter',
verbose_name='From cmd filter')),
@ -120,9 +121,6 @@ class Migration(migrations.Migration):
('apply_from_session',
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='terminal.session',
verbose_name='Session')),
('apply_run_asset',
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.asset',
verbose_name='Run asset')),
('apply_run_system_user',
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='assets.systemuser',
verbose_name='Run system user')),

@ -263,11 +263,6 @@ def command_confirm_migrate(apps, *args):
name=name_username[0], username=name_username[1]
).first() if name_username else None
hostname_ip = analysis_instance_name(meta.get('apply_run_asset'))
apply_run_asset = asset_model.objects.filter(
org_id=instance.org_id, hostname=hostname_ip[0], ip=hostname_ip[1]
).first() if hostname_ip else None
name_username = analysis_instance_name(meta.get('apply_run_system_user'))
apply_run_system_user = system_user_model.objects.filter(
org_id=instance.org_id, name=name_username[0], username=name_username[1]
@ -287,7 +282,7 @@ def command_confirm_migrate(apps, *args):
data = {
'ticket_ptr_id': instance.pk,
'apply_run_user': apply_run_user,
'apply_run_asset': apply_run_asset,
'apply_run_asset': meta.get('apply_run_asset', ''),
'apply_run_system_user': apply_run_system_user,
'apply_run_command': meta.get('apply_run_command', '')[:4090],
'apply_from_session_id': apply_from_session_id,

@ -9,10 +9,7 @@ class ApplyCommandTicket(Ticket):
'users.User', on_delete=models.SET_NULL,
null=True, verbose_name=_('Run user')
)
apply_run_asset = models.ForeignKey(
'assets.Asset', on_delete=models.SET_NULL,
null=True, verbose_name=_('Run asset')
)
apply_run_asset = models.CharField(max_length=128, verbose_name=_('Run asset'), default='')
apply_run_system_user = models.ForeignKey(
'assets.SystemUser', on_delete=models.SET_NULL,
null=True, verbose_name=_('Run system user')
@ -30,4 +27,3 @@ class ApplyCommandTicket(Ticket):
'assets.CommandFilterRule', on_delete=models.SET_NULL,
null=True, verbose_name=_('From cmd filter rule')
)

Loading…
Cancel
Save