Updates
This commit is contained in:
149
ETB-API/automation_orchestration/admin.py
Normal file
149
ETB-API/automation_orchestration/admin.py
Normal file
@@ -0,0 +1,149 @@
|
||||
"""
|
||||
Admin configuration for automation_orchestration app
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from .models import (
|
||||
Runbook,
|
||||
RunbookExecution,
|
||||
Integration,
|
||||
ChatOpsIntegration,
|
||||
ChatOpsCommand,
|
||||
AutoRemediation,
|
||||
AutoRemediationExecution,
|
||||
MaintenanceWindow,
|
||||
WorkflowTemplate,
|
||||
WorkflowExecution,
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Runbook)
|
||||
class RunbookAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'version', 'trigger_type', 'status', 'category',
|
||||
'execution_count', 'success_rate', 'is_public', 'created_by', 'created_at'
|
||||
]
|
||||
list_filter = ['status', 'trigger_type', 'category', 'is_public', 'created_at']
|
||||
search_fields = ['name', 'description', 'category']
|
||||
readonly_fields = ['id', 'execution_count', 'success_rate', 'created_at', 'updated_at', 'last_executed_at']
|
||||
fieldsets = (
|
||||
('Basic Information', {
|
||||
'fields': ('id', 'name', 'description', 'version', 'category', 'tags')
|
||||
}),
|
||||
('Trigger Configuration', {
|
||||
'fields': ('trigger_type', 'trigger_conditions')
|
||||
}),
|
||||
('Content', {
|
||||
'fields': ('steps', 'estimated_duration')
|
||||
}),
|
||||
('Status & Permissions', {
|
||||
'fields': ('status', 'is_public')
|
||||
}),
|
||||
('Metadata', {
|
||||
'fields': ('created_by', 'last_modified_by', 'created_at', 'updated_at', 'last_executed_at'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Statistics', {
|
||||
'fields': ('execution_count', 'success_rate'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(RunbookExecution)
|
||||
class RunbookExecutionAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'runbook', 'triggered_by', 'trigger_type', 'status',
|
||||
'current_step', 'total_steps', 'started_at', 'duration'
|
||||
]
|
||||
list_filter = ['status', 'trigger_type', 'started_at']
|
||||
search_fields = ['runbook__name', 'triggered_by__username', 'incident__title']
|
||||
readonly_fields = ['id', 'started_at', 'completed_at', 'duration']
|
||||
|
||||
|
||||
@admin.register(Integration)
|
||||
class IntegrationAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'integration_type', 'status', 'health_status',
|
||||
'request_count', 'last_used_at', 'created_by'
|
||||
]
|
||||
list_filter = ['integration_type', 'status', 'health_status', 'created_at']
|
||||
search_fields = ['name', 'description']
|
||||
readonly_fields = ['id', 'request_count', 'last_used_at', 'created_at', 'updated_at', 'last_health_check']
|
||||
|
||||
|
||||
@admin.register(ChatOpsIntegration)
|
||||
class ChatOpsIntegrationAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'platform', 'is_active', 'last_activity', 'created_by'
|
||||
]
|
||||
list_filter = ['platform', 'is_active', 'created_at']
|
||||
search_fields = ['name']
|
||||
readonly_fields = ['id', 'last_activity', 'created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(ChatOpsCommand)
|
||||
class ChatOpsCommandAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'command', 'chatops_integration', 'user_id', 'status',
|
||||
'executed_at', 'completed_at'
|
||||
]
|
||||
list_filter = ['status', 'chatops_integration__platform', 'executed_at']
|
||||
search_fields = ['command', 'user_id', 'channel_id']
|
||||
readonly_fields = ['id', 'executed_at', 'completed_at']
|
||||
|
||||
|
||||
@admin.register(AutoRemediation)
|
||||
class AutoRemediationAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'remediation_type', 'trigger_condition_type',
|
||||
'is_active', 'requires_approval', 'execution_count', 'success_count'
|
||||
]
|
||||
list_filter = ['remediation_type', 'trigger_condition_type', 'is_active', 'requires_approval']
|
||||
search_fields = ['name', 'description']
|
||||
readonly_fields = ['id', 'execution_count', 'success_count', 'last_executed_at', 'created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(AutoRemediationExecution)
|
||||
class AutoRemediationExecutionAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'auto_remediation', 'incident', 'status', 'triggered_at',
|
||||
'approved_by', 'completed_at'
|
||||
]
|
||||
list_filter = ['status', 'triggered_at', 'auto_remediation__remediation_type']
|
||||
search_fields = ['auto_remediation__name', 'incident__title', 'approved_by__username']
|
||||
readonly_fields = ['id', 'triggered_at', 'started_at', 'completed_at', 'duration']
|
||||
|
||||
|
||||
@admin.register(MaintenanceWindow)
|
||||
class MaintenanceWindowAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'start_time', 'end_time', 'status',
|
||||
'incidents_suppressed', 'notifications_suppressed', 'created_by'
|
||||
]
|
||||
list_filter = ['status', 'start_time', 'end_time']
|
||||
search_fields = ['name', 'description']
|
||||
readonly_fields = ['id', 'incidents_suppressed', 'notifications_suppressed', 'created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(WorkflowTemplate)
|
||||
class WorkflowTemplateAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'template_type', 'usage_count', 'is_public', 'created_by'
|
||||
]
|
||||
list_filter = ['template_type', 'is_public', 'created_at']
|
||||
search_fields = ['name', 'description']
|
||||
readonly_fields = ['id', 'usage_count', 'created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(WorkflowExecution)
|
||||
class WorkflowExecutionAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name', 'workflow_template', 'triggered_by', 'status',
|
||||
'current_step', 'total_steps', 'started_at', 'duration'
|
||||
]
|
||||
list_filter = ['status', 'trigger_type', 'started_at']
|
||||
search_fields = ['name', 'workflow_template__name', 'triggered_by__username']
|
||||
readonly_fields = ['id', 'started_at', 'completed_at', 'duration']
|
||||
Reference in New Issue
Block a user