agent history enum, remove unused model field
This commit is contained in:
@@ -18,6 +18,7 @@ from logs.models import AuditLog, PendingAction
|
||||
from scripts.models import Script
|
||||
from software.models import InstalledSoftware
|
||||
from tacticalrmm.constants import (
|
||||
AgentHistoryType,
|
||||
AgentMonType,
|
||||
AgentPlat,
|
||||
CheckStatus,
|
||||
@@ -377,7 +378,7 @@ class Command(BaseCommand):
|
||||
# agent histories
|
||||
hist = AgentHistory()
|
||||
hist.agent = agent
|
||||
hist.type = "cmd_run"
|
||||
hist.type = AgentHistoryType.CMD_RUN
|
||||
hist.command = "ping google.com"
|
||||
hist.username = "demo"
|
||||
hist.results = ping_success_output
|
||||
@@ -385,7 +386,7 @@ class Command(BaseCommand):
|
||||
|
||||
hist1 = AgentHistory()
|
||||
hist1.agent = agent
|
||||
hist1.type = "script_run"
|
||||
hist1.type = AgentHistoryType.SCRIPT_RUN
|
||||
hist1.script = clear_spool
|
||||
hist1.script_results = {
|
||||
"id": 1,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.0.4 on 2022-05-18 06:10
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('agents', '0052_alter_agent_monitoring_type'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='agenthistory',
|
||||
name='status',
|
||||
),
|
||||
]
|
||||
@@ -24,6 +24,7 @@ from tacticalrmm.constants import (
|
||||
AGENT_STATUS_ONLINE,
|
||||
AGENT_STATUS_OVERDUE,
|
||||
ONLINE_AGENTS,
|
||||
AgentHistoryType,
|
||||
AgentMonType,
|
||||
AgentPlat,
|
||||
CheckStatus,
|
||||
@@ -987,15 +988,6 @@ class AgentCustomField(models.Model):
|
||||
self.save()
|
||||
|
||||
|
||||
AGENT_HISTORY_TYPES = (
|
||||
("task_run", "Task Run"),
|
||||
("script_run", "Script Run"),
|
||||
("cmd_run", "CMD Run"),
|
||||
)
|
||||
|
||||
AGENT_HISTORY_STATUS = (("success", "Success"), ("failure", "Failure"))
|
||||
|
||||
|
||||
class AgentHistory(models.Model):
|
||||
objects = PermissionQuerySet.as_manager()
|
||||
|
||||
@@ -1006,12 +998,11 @@ class AgentHistory(models.Model):
|
||||
)
|
||||
time = models.DateTimeField(auto_now_add=True)
|
||||
type = models.CharField(
|
||||
max_length=50, choices=AGENT_HISTORY_TYPES, default="cmd_run"
|
||||
max_length=50,
|
||||
choices=AgentHistoryType.choices,
|
||||
default=AgentHistoryType.CMD_RUN,
|
||||
)
|
||||
command = models.TextField(null=True, blank=True, default="")
|
||||
status = models.CharField(
|
||||
max_length=50, choices=AGENT_HISTORY_STATUS, default="success"
|
||||
)
|
||||
username = models.CharField(max_length=255, default="system")
|
||||
results = models.TextField(null=True, blank=True)
|
||||
script = models.ForeignKey(
|
||||
|
||||
@@ -27,6 +27,7 @@ from tacticalrmm.constants import (
|
||||
AGENT_DEFER,
|
||||
AGENT_STATUS_OFFLINE,
|
||||
AGENT_STATUS_ONLINE,
|
||||
AgentHistoryType,
|
||||
AgentMonType,
|
||||
AgentPlat,
|
||||
EvtLogNames,
|
||||
@@ -400,7 +401,7 @@ def send_raw_cmd(request, agent_id):
|
||||
|
||||
hist = AgentHistory.objects.create(
|
||||
agent=agent,
|
||||
type="cmd_run",
|
||||
type=AgentHistoryType.CMD_RUN,
|
||||
command=request.data["cmd"],
|
||||
username=request.user.username[:50],
|
||||
)
|
||||
@@ -687,7 +688,7 @@ def run_script(request, agent_id):
|
||||
|
||||
hist = AgentHistory.objects.create(
|
||||
agent=agent,
|
||||
type="script_run",
|
||||
type=AgentHistoryType.SCRIPT_RUN,
|
||||
script=script,
|
||||
username=request.user.username[:50],
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@ from typing import List
|
||||
from agents.models import Agent, AgentHistory
|
||||
from scripts.models import Script
|
||||
from tacticalrmm.celery import app
|
||||
from tacticalrmm.constants import AgentHistoryType
|
||||
|
||||
|
||||
@app.task
|
||||
@@ -21,7 +22,7 @@ def handle_bulk_command_task(
|
||||
for agent in Agent.objects.filter(pk__in=agentpks):
|
||||
hist = AgentHistory.objects.create(
|
||||
agent=agent,
|
||||
type="cmd_run",
|
||||
type=AgentHistoryType.CMD_RUN,
|
||||
command=cmd,
|
||||
username=username,
|
||||
)
|
||||
@@ -38,7 +39,7 @@ def handle_bulk_script_task(
|
||||
for agent in Agent.objects.filter(pk__in=agentpks):
|
||||
hist = AgentHistory.objects.create(
|
||||
agent=agent,
|
||||
type="script_run",
|
||||
type=AgentHistoryType.SCRIPT_RUN,
|
||||
script=script,
|
||||
username=username,
|
||||
)
|
||||
|
||||
@@ -23,6 +23,12 @@ AGENT_STATUS_OFFLINE = "offline"
|
||||
AGENT_STATUS_OVERDUE = "overdue"
|
||||
|
||||
|
||||
class AgentHistoryType(models.TextChoices):
|
||||
TASK_RUN = "task_run", "Task Run"
|
||||
SCRIPT_RUN = "script_run", "Script Run"
|
||||
CMD_RUN = "cmd_run", "CMD Run"
|
||||
|
||||
|
||||
class AgentMonType(models.TextChoices):
|
||||
SERVER = "server", "Server"
|
||||
WORKSTATION = "workstation", "Workstation"
|
||||
|
||||
Reference in New Issue
Block a user