myxce/src/frontend/apiserver/models/hosts.go

134 lines
3.1 KiB
Go

package models
const (
HOST_OPEN = 1
HOST_CLOSE = 2
HOST_TAG = 3
HOST_UNTAG = 4
)
var SupportedHostActions = []string{"open", "close"}
var HOSTSTAT = map[string]int{
"UNAVAIL": 0x00010000,
"LOCKEDU": 0x00020000,
"LOCKEDW": 0x00040000,
"BUSY": 0x00080000,
"CLOSED": 0x00100000,
}
func HostStateStr(state int) string {
if (state & HOSTSTAT["UNAVAIL"]) != 0 {
return "UNAVAIL"
} else if (state & HOSTSTAT["CLOSED"]) != 0 {
return "CLOSED"
} else if (state & HOSTSTAT["BUSY"]) != 0 {
return "BUSY"
} else if (state & HOSTSTAT["LOCKEDU"]) != 0 {
return "LOCKU"
} else if (state & HOSTSTAT["LOCKEDW"]) != 0 {
return "LOCKW"
}
return "OK"
}
// JSONBFields contains the list of fields that are in JSONB format
var JSONBHFields = []string{"topology", "sched_stop", "real_load", "dispt_window"}
var HOST_DEFAULT_COLUMN = []string{
"host_name",
//"ip_addr", // not supported yet
"host_status",
"host_model",
"host_type",
"host_group",
"flag",
"cpu_factor",
"num_cpus",
"num_cores",
"num_threads",
"dispt_window",
"max_slot",
"max_mem",
"max_swap",
"max_tmp",
"num_disk",
"num_run",
"num_ssusp",
"num_ususp",
//"num_rsv",
"num_done",
"topology",
"sched_stop",
//"real_load",
}
type HostInfo struct {
HostID int64 `json:"host_id"`
HostName string `json:"host_name"`
HostStatus int `json:"host_status"`
HostModel string `json:"host_model"`
HostType string `json:"host_type"`
HostGroup string `json:"host_group"`
Flag int `json:"flag"`
CPUFactor float64 `json:"cpu_factor"`
DisptWindow string `json:"dispt_window"`
NumCPUs int `json:"num_cpus"`
NumCores int `json:"num_cores"`
NumThreads int `json:"num_threads"`
MaxSlot int `json:"max_slot"`
MaxMem int `json:"max_mem"`
MaxSwap int `json:"max_swap"`
MaxTmp int `json:"max_tmp"`
NumDisk int `json:"num_disk"`
NumRun int `json:"num_run"`
NumSSusp int `json:"num_ssusp"`
NumUSusp int `json:"num_ususp"`
//NumRsv int `json:"num_rsv"`
NumDone int `json:"num_done"`
Topology string `json:"topology"` // JSONB
SchedStop string `json:"sched_stop"` // JSONB
//RealLoad string `json:"real_load"` // JSONB
}
// host info query supported filter
var HOST_SUPPORT_FILTERS = []string{
"host_name",
"host_model",
"host_type",
"host_group",
"flag",
"cpu_factor",
"num_cpus",
"max_slot",
"max_mem",
"max_swap",
"max_tmp",
"num_disk",
"num_run",
"num_ssusp",
"num_ususp",
//"num_rsv",
"num_done",
}
var HOST_SUPPORT_SORT = []string{
"host_name",
}
type HostControlRequest struct {
ControlAction string `json:"action" binding:"required"`
Hostname []string `json:"host_name" binding:"required"`
Comment string `json:"comment"`
}
type ResReqSelectRequest struct {
Select string `json:"select" binding:"required"`
Order string `json:"order,omitempty"`
Limit int `json:"limit,omitempty"`
Pagetoken string `json:"page_token,omitempty"`
}
type HostControlEvent struct {
Hostname string `json:"host_name" binding:"required"`
Comment string `json:"comment,omitempty"`
}