Documentation ¶
Index ¶
- Constants
- func ClearInstance(sinceBefore time.Time, jobId int) (err error)
- func DeleteCommandHistoryById(id int) error
- func DeleteGroupById(id int) error
- func DeleteJobById(id int) error
- func DeletePlayBookById(id int) error
- func DeletePrivateKeyById(id int) error
- func DeleteQuicklyCommandById(id int) error
- func DeleteTagById(id int) error
- func DeleteTunnelById(id int) error
- func ExistedGroup(name string) bool
- func ExistedHost(name string, addr string) bool
- func ExistedPlayBook(name string, steps string) bool
- func ExistedPrivateKey(keyFile string) bool
- func ExistedTag(name string) bool
- func ExistedTunnel(id int) bool
- func GetPaginateQuery[T *TaskInstance | *[]*TaskInstance | *Host | *[]*Host](instance T, pageSize, page int, params map[string]interface{}, preload bool) (int64, error)
- func InitModels(dsn, dbName, user, pass, driver, _dataPath string) error
- func InsertOrUpdateCommandHistory(cmd string) error
- func RefreshJob(job *Job) error
- func RefreshTunnel(tunnel *Tunnel) error
- func UpdateHostStatus(host *Host) error
- func UpdateTaskInstanceLogTrace(instance *TaskInstance, logPath string) error
- type CommandHistory
- type DataBase
- type Group
- type Host
- func DeleteHostById(id int) (*Host, error)
- func GetAllHost() ([]*Host, error)
- func GetAllHostWithOutPreload() ([]*Host, error)
- func GetHostByAddr(addr string) ([]*Host, error)
- func GetHostByGlob(glob string) ([]*Host, error)
- func GetHostById(id int) (*Host, error)
- func GetHostByIdWithPreload(id int) (*Host, error)
- func GetHostByReg(regStr string) ([]*Host, error)
- func GetHostsByGroup(group *Group) ([]*Host, error)
- func GetHostsByTag(tag *Tag) ([]*Host, error)
- func InsertHost(hostname string, user string, addr string, port int, password string, ...) (*Host, error)
- func ParseHostList(pType string, id int) ([]*Host, error)
- func UpdateHost(id int, hostname string, user string, addr string, port int, password string, ...) (*Host, error)
- type HostExport
- type Job
- func GetAllJob() ([]*Job, error)
- func GetJobById(id int) (*Job, error)
- func InsertJob(name, t, spec, cmd string, executeID, cmdId int, executeType, cmdType string) (*Job, error)
- func UpdateJob(id int, name, t, spec, cmd, cmdType string, cmdId, executeId int, ...) (*Job, error)
- func UpdateJobStatus(id int, status string) (*Job, error)
- type PlayBook
- type PrivateKey
- func GetAllPrivateKey() ([]*PrivateKey, error)
- func GetPrivateKeyById(id int) (*PrivateKey, error)
- func GetPrivateKeyByName(name string) (*PrivateKey, error)
- func InsertPrivateKey(name, keyFile, passphrase string) (*PrivateKey, error)
- func UpdatePrivateKey(id int, name, keyFile, passphrase string) (*PrivateKey, error)
- type QuicklyCommand
- type Step
- type StepSlice
- type Tag
- type TaskInstance
- type Tunnel
- func GetAllTunnel() ([]*Tunnel, error)
- func GetTunnelById(id int) (*Tunnel, error)
- func GetTunnelsByHostId(id int) ([]*Tunnel, error)
- func InsertTunnel(mode, src, dest string, host *Host) (*Tunnel, error)
- func UpdateTunnel(id int, mode, src, dest string) (*Tunnel, error)
- func UpdateTunnelStatus(id int, status bool, msg string) (*Tunnel, error)
Constants ¶
View Source
const ( GroupHostMode = 0 GroupOtherMode = 1 )
View Source
const ( InstanceStatusRunning = "running" InstanceStatusDone = "done" )
View Source
const ( DBDriverMysql = "mysql" DBDriverPostgres = "postgres" DBDriverSqlite = "sqlite" )
Variables ¶
This section is empty.
Functions ¶
func DeleteGroupById ¶
func DeleteJobById ¶
func DeletePlayBookById ¶
func DeletePrivateKeyById ¶
func DeleteTagById ¶
func DeleteTunnelById ¶
func ExistedGroup ¶
func ExistedHost ¶
func ExistedPlayBook ¶
func ExistedPrivateKey ¶
func ExistedTag ¶
func ExistedTunnel ¶
func GetPaginateQuery ¶
func GetPaginateQuery[T *TaskInstance | *[]*TaskInstance | *Host | *[]*Host]( instance T, pageSize, page int, params map[string]interface{}, preload bool) (int64, error)
func InitModels ¶
func RefreshTunnel ¶
func UpdateHostStatus ¶
func UpdateTaskInstanceLogTrace ¶
func UpdateTaskInstanceLogTrace(instance *TaskInstance, logPath string) error
Types ¶
type CommandHistory ¶
type CommandHistory struct { Id int `json:"id"` Cmd string `gorm:"not null;index:idx_cmd;unique" json:"cmd"` Times uint32 `gorm:"index:idx_times" json:"times"` }
func SearchCommandHistory ¶
func SearchCommandHistory(keyword string, limit int) ([]*CommandHistory, error)
type Group ¶
type Group struct { Id int `json:"id"` Name string `gorm:"size:256;not null" json:"name"` Mode int `gorm:"default:0;not null" json:"mode"` //0.主机模式, 1.其他匹配模式主机不生效 Host []Host `json:"-"` Params string `json:"params"` }
func GetAllGroup ¶
func GetGroupById ¶
func GetGroupByName ¶
type Host ¶
type Host struct { Id int `json:"id"` Name string `gorm:"size:128;not null" json:"name"` User string `gorm:"size:128;not null" json:"user"` Addr string `gorm:"size:128;not null" json:"addr"` Port int `gorm:"default:22" json:"port"` VNCPort int `gorm:"default:5900" json:"vnc_port"` PassWord string `gorm:"size:128;not null" json:"-"` Status bool `gorm:"default:false" json:"status"` PrivateKey PrivateKey `gorm:"constraint:OnDelete:SET NULL;" json:"-"` PrivateKeyID int `json:"private_key_id"` GroupId int `json:"group_id"` Group Group `gorm:"constraint:OnDelete:SET NULL;" json:"group"` Tags []Tag `gorm:"many2many:host_tag" json:"tags"` Tunnels []Tunnel `gorm:"constraint:OnDelete:CASCADE;" json:"tunnels"` }
Host Struct
func DeleteHostById ¶
func GetAllHost ¶
func GetHostByAddr ¶
func GetHostByGlob ¶
func GetHostById ¶
func GetHostByIdWithPreload ¶
func GetHostByReg ¶
func GetHostsByGroup ¶
func GetHostsByTag ¶
func InsertHost ¶
type HostExport ¶
type HostExport struct { Name string `csv:"name"` User string `csv:"user"` Addr string `csv:"addr"` Port int `csv:"port"` VNCPort int `csv:"vnc_port"` PassWord string `csv:"password"` Group string `csv:"group"` GroupParams string `csv:"group_params"` Tags []string `csv:"tags"` KeyFile string `csv:"key_file"` KeyName string `csv:"key_name"` KeyPhrase string `csv:"key_phrase"` }
type Job ¶
type Job struct { Id int `json:"id"` Name string `gorm:"size:128" json:"name"` Type string `gorm:"size:32;not null" json:"type"` Spec string `gorm:"size:128" json:"spec"` Cmd string `gorm:"size:512" json:"cmd"` CmdId int `json:"cmd_id"` CmdType string `gorm:"size:128" json:"cmd_type"` Status string `gorm:"size:64;default: ready" json:"status"` ExecuteID int `json:"execute_id"` ExecuteType string `gorm:"size:64" json:"execute_type"` Instances []TaskInstance `gorm:"constraint:OnDelete:CASCADE;" json:"instances"` }
func GetJobById ¶
type PlayBook ¶
type PlayBook struct { Id int `json:"id"` Name string `gorm:"size:256" json:"name"` Steps string `gorm:"type:text" json:"-"` StepsObj []*Step `gorm:"-" json:"steps"` }
func GetAllPlayBook ¶
func GetPlayBookById ¶
func InsertPlayBook ¶
func (*PlayBook) GetStepsObj ¶
type PrivateKey ¶
type PrivateKey struct { Id int `json:"id"` Name string `gorm:"size:128;not null" json:"name"` KeyFile string `gorm:"type:text" json:"-"` Passphrase string `json:"-"` }
func GetAllPrivateKey ¶
func GetAllPrivateKey() ([]*PrivateKey, error)
func GetPrivateKeyById ¶
func GetPrivateKeyById(id int) (*PrivateKey, error)
func GetPrivateKeyByName ¶
func GetPrivateKeyByName(name string) (*PrivateKey, error)
func InsertPrivateKey ¶
func InsertPrivateKey(name, keyFile, passphrase string) (*PrivateKey, error)
func UpdatePrivateKey ¶
func UpdatePrivateKey(id int, name, keyFile, passphrase string) (*PrivateKey, error)
type QuicklyCommand ¶
type QuicklyCommand struct { Id int `json:"id"` Name string `gorm:"not null;unique" json:"name"` Cmd string `gorm:"not null;" json:"cmd"` AppendCR bool `json:"append_cr"` // 是否追加CR }
func GetAllQuicklyCommand ¶
func GetAllQuicklyCommand() ([]*QuicklyCommand, error)
func GetQuicklyCommandById ¶
func GetQuicklyCommandById(id int) (*QuicklyCommand, error)
func InsertQuicklyCommand ¶
func InsertQuicklyCommand(name, cmd string, appendCR bool) (*QuicklyCommand, error)
func UpdateQuicklyCommand ¶
func UpdateQuicklyCommand(id int, name, cmd string, appendCR bool) (*QuicklyCommand, error)
type Step ¶
type Tag ¶
type Tag struct { Id int `json:"id"` Name string `gorm:"size:100;not null;unique" json:"name"` Hosts []Host `gorm:"many2many:host_tag;" json:"-"` }
func GetTagById ¶
func GetTagByName ¶
type TaskInstance ¶
type TaskInstance struct { Id int `json:"id"` Uid string `json:"uid"` JobId int `json:"job_id"` Job Job `json:"-"` StartTime time.Time `gorm:"index" json:"start_time"` EndTime time.Time `json:"end_time"` Status string `gorm:"size:64;default: ready" json:"status"` LogPath string `gorm:"size:256" json:"log_path"` LogData string `gorm:"type:text" json:"log_data"` }
func GetTaskInstanceById ¶
func GetTaskInstanceById(id int) (*TaskInstance, error)
func InsertTaskInstance ¶
func InsertTaskInstance(jobId int, start time.Time) (*TaskInstance, error)
func (*TaskInstance) Done ¶
func (ti *TaskInstance) Done() error
func (*TaskInstance) GenerateLogPath ¶
func (ti *TaskInstance) GenerateLogPath(tmpPath string) string
func (*TaskInstance) UpdateStatus ¶
func (ti *TaskInstance) UpdateStatus(status string) error
type Tunnel ¶
type Tunnel struct { Id int `json:"id"` Mode string `gorm:"size:64" json:"mode"` Source string `gorm:"size:128;not null" json:"source"` Destination string `gorm:"size:128;not null" json:"destination"` Status int `gorm:"default:0" json:"status"` ErrorMsg string `gorm:"size:512" json:"error_msg"` HostId int `json:"host_id"` Host Host `json:"-"` }
func GetAllTunnel ¶
func GetTunnelById ¶
func GetTunnelsByHostId ¶
Click to show internal directories.
Click to hide internal directories.