Documentation ¶
Overview ¶
Package database acts as storage backend for amtgo's webserver.
Index ¶
- Constants
- Variables
- func CloseDB()
- func DeleteHost(id int) (string, bool)
- func DeleteJob(id int) (string, bool)
- func DeleteOptionset(id int) (string, bool)
- func DeleteOu(id int) (string, bool)
- func DeleteUser(id int) (string, bool)
- func GetHostJSON(id int) string
- func GetHostNamesByID(ids []string) (hostnames []string)
- func GetHostsJSON() string
- func GetJobJSON(id int) string
- func GetJobsJSON() string
- func GetLaststateJSON(id int) string
- func GetLogdaysJSON() string
- func GetNotificationJSON(id int) string
- func GetNotificationsJSON() string
- func GetOptionset(id int) (o amt.Optionset)
- func GetOptionsetJSON(id int) string
- func GetOptionsets() (optionsets []amt.Optionset)
- func GetOptionsetsJSON() string
- func GetOuJSON(id int) string
- func GetOusJSON() string
- func GetStatelogsJSON(ouid int, unixtime int) []byte
- func GetUserJSON(id int) string
- func GetUsersJSON() string
- func InitDB()
- func InitDBMysql()
- func InitDBSQlite()
- func InsertHost(body io.ReadCloser) string
- func InsertJob(j Job) string
- func InsertNotification(ntype string, message string)
- func InsertOptionset(body io.ReadCloser) string
- func InsertOu(body io.ReadCloser) string
- func InsertStatelog(hostid int, http int, amt int, port int)
- func InsertUser(u User)
- func OpenDB()
- func OpenDBMySQL()
- func OpenDBSQlite()
- func UpdateJob(j Job) string
- func UpdateOptionset(id int, body io.ReadCloser) string
- func UpdateOu(id int, body io.ReadCloser) string
- type Host
- type Hosts
- type Job
- type Jobs
- type Notification
- type Notifications
- type Ou
- type Ous
- type Statelog
- type Statelogs
- type User
- type Users
Constants ¶
const ( // NotificationTypeUser maps to user symbol NotificationTypeUser = "user" // NotificationTypePowerOff maps to power-off symbol NotificationTypePowerOff = "toggle-off" // NotificationTypePowerOn maps to power-on symbol NotificationTypePowerOn = "toggle-on" // NotificationTypeWarning maps to warning symbol NotificationTypeWarning = "warning" // NotificationTypeComment maps to comment bubble symbol NotificationTypeComment = "comment" )
Variables ¶
var ( // DbDriver selects driver to use: sqlite3 | mysql DbDriver string // DbFile points a SQLite database file DbFile string // DbUser etc. below are MySQL only DbUser string // DbPassword for MySQL DbPassword string // DbName for MySQL DbName string // DbHost for MySQL DbHost string // DbPort for MySQL DbPort string )
Functions ¶
func DeleteOptionset ¶
DeleteOptionset deletes a single host
func GetHostNamesByID ¶
GetHostNamesByID gets hostnames for hosts with given IDs
func GetLaststateJSON ¶
GetLaststateJSON get laststate entry -- UNUSED
func GetNotificationJSON ¶
GetNotificationJSON gets a single notification
func GetNotificationsJSON ¶
func GetNotificationsJSON() string
GetNotificationsJSON gets all notifications
func GetOptionset ¶
GetOptionset gets a single optionset
func GetOptionsetJSON ¶
GetOptionsetJSON gets a single optionset
func GetOptionsets ¶
GetOptionsets gets all optionsets
func GetStatelogsJSON ¶
GetStatelogsJSON gets all statelogs for one ou at specific day
func InsertNotification ¶
InsertNotification inserts a user record
func InsertOptionset ¶
func InsertOptionset(body io.ReadCloser) string
InsertOptionset creates an Optionset
func InsertStatelog ¶
InsertStatelog adds a record in statelog table
func UpdateOptionset ¶
func UpdateOptionset(id int, body io.ReadCloser) string
UpdateOptionset updates an Optionset
Types ¶
type Host ¶
type Host struct { ID int `json:"id"` OuID int `json:"ou_id" db:"ou_id"` Hostname string `json:"hostname"` Enabled int `json:"enabled"` }
Host is a AMT enabled client to be controlled.
type Job ¶
type Job struct { ID int `json:"id"` JobType int `json:"job_type" db:"job_type"` JobStatus int `json:"job_status" db:"job_status"` UserID int `json:"user_id" db:"user_id"` AmtcCmd *string `json:"amtc_cmd" db:"amtc_cmd"` AmtcDelay *float64 `json:"amtc_delay" db:"amtc_delay"` AmtcBootdevice *string `json:"amtc_bootdevice" db:"amtc_bootdevice"` AmtcHosts *string `json:"amtc_hosts" db:"amtc_hosts"` OuID *int `json:"ou_id" db:"ou_id"` StartTime int `json:"start_time" db:"start_time"` RepeatInterval *int `json:"repeat_interval" db:"repeat_interval"` RepeatDays *int `json:"repeat_days" db:"repeat_days"` LastStarted *int `json:"last_started" db:"last_started"` LastDone *int `json:"last_done" db:"last_done"` ProcPid *int `json:"proc_pid" db:"proc_pid"` Description *string `json:"description"` }
Job is a scheduled job
func GetScheduledJobs ¶
GetScheduledJobs gets all scheduled jobs for a given weekday and minute of day.
type Notification ¶
type Notification struct { ID int `json:"id"` Tstamp int `json:"tstamp"` UserID int `json:"user_id" db:"user_id"` Ntype string `json:"ntype"` Message string `json:"message"` }
Notification is a GUI notification (e.g. job started, completed...)
type Notifications ¶
type Notifications struct {
Notifications []Notification `json:"notifications"`
}
Notifications array for ember
type Ou ¶
type Ou struct { ID int `json:"id"` ParentID *int `json:"parent_id" db:"parent_id"` OptionsetID *int `json:"optionset_id" db:"optionset_id"` Name string `json:"name"` Description string `json:"description"` IdlePower float32 `json:"idle_power" db:"idle_power"` Logging int `json:"logging"` }
Ou describes an organizational unit (e.g. room)
type Statelog ¶
type Statelog struct { HostID int `json:"host_id" db:"host_id"` StateBegin int `json:"state_begin" db:"state_begin"` OpenPort int `json:"open_port" db:"open_port"` StateAMT int `json:"state_amt" db:"state_amt"` StateHTTP int `json:"state_http" db:"state_http"` }
Statelog -- unused?
type Statelogs ¶
type Statelogs struct {
Statelogs []Statelog `json:"statelogs"`
}
Statelogs wraps statelogs for json/emberjs
type User ¶
type User struct { ID int `json:"id"` OuID int `json:"ou_id" db:"ou_id"` IsEnabled int `json:"is_enabled" db:"is_enabled"` IsAdmin int `json:"is_admin" db:"is_admin"` CanControl int `json:"can_control" db:"can_control"` Name string `json:"name"` Fullname string `json:"fullname"` Password string `json:"-"` Passsalt string `json:"-"` }
User represents a GUI user