init: EZOps AIOps 智能运维平台
- 前端: React 18 + TypeScript + Vite + Tailwind CSS + shadcn/ui - 后端: Go + Gin + GORM + JWT (golang-jwt/jwt/v5) - 功能: 服务器管理、K8s集群、监控告警、CI/CD、自动化运维、审批流程、审计日志 - 文档: 设计文档(ROADMAP/PDD/架构/模块)
This commit is contained in:
commit
7d6674bddd
156 files changed
+45704
No files matched your search
@@ -0,0 +1,189 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Server 服务器模型
|
||||
type Server struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Hostname string `gorm:"size:128;not null" json:"hostname"`
|
||||
IP string `gorm:"size:64;not null" json:"ip"`
|
||||
PublicIP string `gorm:"size:64" json:"public_ip"`
|
||||
Port int `gorm:"default:22" json:"port"`
|
||||
Username string `gorm:"size:64;default:root" json:"username"`
|
||||
Password string `gorm:"size:255" json:"-"`
|
||||
SSHKey string `gorm:"type:text" json:"-"`
|
||||
AuthType string `gorm:"size:32;default:password" json:"auth_type"` // password, key
|
||||
OS string `gorm:"size:64" json:"os"`
|
||||
OSVersion string `gorm:"size:64" json:"os_version"`
|
||||
Arch string `gorm:"size:32" json:"arch"`
|
||||
CPU int `json:"cpu"`
|
||||
Memory int64 `json:"memory"` // MB
|
||||
Disk int64 `json:"disk"` // GB
|
||||
Status string `gorm:"size:32;default:stopped" json:"status"` // running, stopped, maintenance, error
|
||||
CPUUsage float64 `json:"cpu_usage"`
|
||||
MemoryUsage float64 `json:"memory_usage"`
|
||||
DiskUsage float64 `json:"disk_usage"`
|
||||
Uptime int64 `json:"uptime"` // seconds
|
||||
AgentVersion string `gorm:"size:32" json:"agent_version"`
|
||||
AgentStatus string `gorm:"size:32;default:offline" json:"agent_status"` // online, offline
|
||||
RegionID *uint `json:"region_id"`
|
||||
CloudID *uint `json:"cloud_id"`
|
||||
Tags string `gorm:"type:text" json:"tags"` // JSON
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
LastCheckAt *time.Time `json:"last_check_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
// 关联
|
||||
Region *Region `json:"region,omitempty"`
|
||||
Cloud *Cloud `json:"cloud,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Server) TableName() string {
|
||||
return "servers"
|
||||
}
|
||||
|
||||
// Cloud 云平台模型
|
||||
type Cloud struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;not null" json:"name"`
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
Type string `gorm:"size:32;default:public" json:"type"` // public, private, hybrid
|
||||
Status string `gorm:"size:32;default:active" json:"status"`
|
||||
Website string `gorm:"size:255" json:"website"`
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Cloud) TableName() string {
|
||||
return "clouds"
|
||||
}
|
||||
|
||||
// CloudAccount 云账号模型
|
||||
type CloudAccount struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:128;not null" json:"name"`
|
||||
Provider string `gorm:"size:64;not null" json:"provider"` // aws, aliyun, tencent, huawei, azure
|
||||
AccessKey string `gorm:"size:255;not null" json:"-"`
|
||||
SecretKey string `gorm:"size:255;not null" json:"-"`
|
||||
Status string `gorm:"size:32;default:active" json:"status"` // active, inactive, error
|
||||
RegionCount int `gorm:"default:0" json:"region_count"`
|
||||
ServerCount int `gorm:"default:0" json:"server_count"`
|
||||
LastSyncAt *time.Time `json:"last_sync_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (CloudAccount) TableName() string {
|
||||
return "cloud_accounts"
|
||||
}
|
||||
|
||||
// Region 区域模型
|
||||
type Region struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;not null" json:"name"`
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
Provider string `gorm:"size:64;not null" json:"provider"`
|
||||
Location string `gorm:"size:128" json:"location"`
|
||||
Status string `gorm:"size:32;default:active" json:"status"`
|
||||
Endpoint string `gorm:"size:255" json:"endpoint"`
|
||||
VPCCount int `gorm:"default:0" json:"vpc_count"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Region) TableName() string {
|
||||
return "regions"
|
||||
}
|
||||
|
||||
// Domain 域名模型
|
||||
type Domain struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:255;uniqueIndex;not null" json:"name"`
|
||||
Registrar string `gorm:"size:128" json:"registrar"`
|
||||
Status string `gorm:"size:32;default:active" json:"status"` // active, expired, pending
|
||||
ExpireDate *time.Time `json:"expire_date"`
|
||||
DNSProvider string `gorm:"size:128" json:"dns_provider"`
|
||||
RecordCount int `gorm:"default:0" json:"record_count"`
|
||||
SSLEnabled bool `gorm:"default:false" json:"ssl_enabled"`
|
||||
SSLExpireDate *time.Time `json:"ssl_expire_date"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (Domain) TableName() string {
|
||||
return "domains"
|
||||
}
|
||||
|
||||
// CreateServerRequest 创建服务器请求
|
||||
type CreateServerRequest struct {
|
||||
Hostname string `json:"hostname" binding:"required"`
|
||||
IP string `json:"ip" binding:"required,ip"`
|
||||
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
|
||||
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
SSHKey string `json:"ssh_key"`
|
||||
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
|
||||
OS string `json:"os"`
|
||||
CPU int `json:"cpu"`
|
||||
Memory int64 `json:"memory"`
|
||||
Disk int64 `json:"disk"`
|
||||
RegionID *uint `json:"region_id"`
|
||||
CloudID *uint `json:"cloud_id"`
|
||||
Tags string `json:"tags"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// UpdateServerRequest 更新服务器请求
|
||||
type UpdateServerRequest struct {
|
||||
Hostname string `json:"hostname"`
|
||||
PublicIP string `json:"public_ip" binding:"omitempty,ip"`
|
||||
Port int `json:"port" binding:"omitempty,min=1,max=65535"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
SSHKey string `json:"ssh_key"`
|
||||
AuthType string `json:"auth_type" binding:"omitempty,oneof=password key"`
|
||||
OS string `json:"os"`
|
||||
CPU int `json:"cpu"`
|
||||
Memory int64 `json:"memory"`
|
||||
Disk int64 `json:"disk"`
|
||||
Status string `json:"status" binding:"omitempty,oneof=running stopped maintenance error"`
|
||||
RegionID *uint `json:"region_id"`
|
||||
CloudID *uint `json:"cloud_id"`
|
||||
Tags string `json:"tags"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// ServerListResponse 服务器列表响应
|
||||
type ServerListResponse struct {
|
||||
List []Server `json:"list"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
// ServerStats 服务器统计
|
||||
type ServerStats struct {
|
||||
Total int64 `json:"total"`
|
||||
Running int64 `json:"running"`
|
||||
Stopped int64 `json:"stopped"`
|
||||
Maintenance int64 `json:"maintenance"`
|
||||
Error int64 `json:"error"`
|
||||
AvgCPU float64 `json:"avg_cpu"`
|
||||
AvgMemory float64 `json:"avg_memory"`
|
||||
AvgDisk float64 `json:"avg_disk"`
|
||||
}
|
||||
Reference in new issue
Block a user