84 lines
3.6 KiB
Go
84 lines
3.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AnsiblePlaybook Playbook 模型 // Logan.Li
|
|
type AnsiblePlaybook struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Content string `gorm:"type:text;not null" json:"content"` // YAML 内容
|
|
Tags string `gorm:"size:500" json:"tags"` // 逗号分隔
|
|
Category string `gorm:"size:100" json:"category"` // deployment/maintenance/etc
|
|
CreatedBy string `gorm:"size:255" json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsiblePlaybook) TableName() string { return "ops_ansible_playbooks" }
|
|
|
|
// AnsibleJob 执行任务记录 // Logan.Li
|
|
type AnsibleJob struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
PlaybookID uint `gorm:"not null" json:"playbook_id"`
|
|
PlaybookName string `gorm:"size:255" json:"playbook_name"`
|
|
Status string `gorm:"size:20;default:pending" json:"status"` // pending/running/success/failed
|
|
TargetHosts string `gorm:"type:text" json:"target_hosts"` // JSON 数组
|
|
Variables string `gorm:"type:text" json:"variables"` // JSON
|
|
Output string `gorm:"type:text" json:"output"`
|
|
Duration int64 `gorm:"default:0" json:"duration"` // 毫秒
|
|
TriggeredBy string `gorm:"size:255" json:"triggered_by"`
|
|
StartedAt *time.Time `json:"started_at"`
|
|
CompletedAt *time.Time `json:"completed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsibleJob) TableName() string { return "ops_ansible_jobs" }
|
|
|
|
// AnsibleInventory 主机清单 // Logan.Li
|
|
type AnsibleInventory struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Hosts string `gorm:"type:text" json:"hosts"` // JSON 数组 [{name,ip,port,user,os}]
|
|
CreatedBy string `gorm:"size:255" json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (AnsibleInventory) TableName() string { return "ops_ansible_inventories" }
|
|
|
|
// LogSource 日志源 // Logan.Li
|
|
type LogSource struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Type string `gorm:"size:50;not null" json:"type"` // application/syslog/docker/kubernetes
|
|
Status string `gorm:"size:20;default:active" json:"status"`
|
|
Config string `gorm:"type:text" json:"config"` // JSON {path/pattern}
|
|
LogCount int64 `gorm:"default:0" json:"log_count"`
|
|
LastSeen *time.Time `json:"last_seen"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (LogSource) TableName() string { return "sys_log_sources" }
|
|
|
|
// LogEntry 日志条目 // Logan.Li
|
|
type LogEntry struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
SourceID uint `gorm:"index" json:"source_id"`
|
|
Timestamp time.Time `gorm:"index" json:"timestamp"`
|
|
Level string `gorm:"size:20;index" json:"level"` // error/warn/info/debug
|
|
Service string `gorm:"size:255;index" json:"service"`
|
|
Host string `gorm:"size:255;index" json:"host"`
|
|
Message string `gorm:"type:text" json:"message"`
|
|
TraceID string `gorm:"size:100;index" json:"trace_id"`
|
|
Raw string `gorm:"type:text" json:"raw"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (LogEntry) TableName() string { return "sys_log_entries" }
|