db

package
v0.0.0-...-d6c8189 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func DeleteHost

func DeleteHost(id int) error

func DeleteHostRole

func DeleteHostRole(id int) error

func DeleteHostType

func DeleteHostType(id int) error

func InitDB

func InitDB(config config.Config) *gorm.DB

func InsertHistory

func InsertHistory(history History) error

func InsertHost

func InsertHost(hostInfo HostInfo) error

func InsertHostRole

func InsertHostRole(hostRole HostRole) error

func InsertHostType

func InsertHostType(hostType HostType) error

func IsExistHost

func IsExistHost(id int) bool

func IsExistHostRole

func IsExistHostRole(id int) bool

func IsExistHostType

func IsExistHostType(id int) bool

func UpdateHost

func UpdateHost(hostInfo HostInfo) error

func UpdateSetting

func UpdateSetting(setting Setting) error

Types

type History

type History struct {
	gorm.Model
	HostInfoID uint `json:"host"`
	HostInfo   HostInfo
	IsUP       bool `json:"is_up"`
}

History はHostの死活ステータスの履歴を持つ

func GetHistories

func GetHistories(limit int) (histories []History)

type HostInfo

type HostInfo struct {
	gorm.Model
	Active     bool   `json:"active" gorm:"DEFAULT:false"`
	HostName   string `json:"hostname"`
	IPAddress  string `json:"ipaddress"`
	OS         string `json:"os"`
	Core       int    `json:"core"`
	RAM        int    `json:"ram"`
	Disk       int    `json:"disk"`
	HostTypeID uint   `json:"type"`
	HostType   HostType
	HostRoleID uint `json:"role"`
	HostRole   HostRole
	Online     bool      `json:"online" gorm:"DEFAULT:false"`
	OnlineAt   time.Time `json:"online_at"`
	Note       string    `json:"note"`
}

HostInfo はホストの基本的な情報を持つ

func GetHostById

func GetHostById(id int) (hostInfo HostInfo, isNotFound bool)

func GetHosts

func GetHosts() (allHostInfo []HostInfo, isNotFound bool)

type HostRole

type HostRole struct {
	gorm.Model
	Role string `json:"role"`
}

HostRole はホストの役割の情報

func GetHostRoles

func GetHostRoles() (allHostRole []HostRole, isNotFound bool)

type HostType

type HostType struct {
	gorm.Model
	Type string `json:"hosttype"`
}

HostType はホストの形式の情報

func GetHostTypes

func GetHostTypes() (allHostType []HostType, isNotFound bool)

type Setting

type Setting struct {
	gorm.Model
	Timeout int `json:"timeout" gorm:"DEFAULT:10"`
}

Setting はアプリケーションの設定情報を持つ

func GetSetting

func GetSetting() (setting Setting, isNotFound bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL