server

package
v0.0.0-...-901012e Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientActionPing Ping the host
	ClientActionPing = "ping"

	// ClientActionRunScript Run the script on the host
	ClientActionRunScript = "run_script"

	// ClientActionExitClient Exit the client on the host
	ClientActionExitClient = "exit_client"

	// ClientActionReboot Reboot the host
	ClientActionReboot = "reboot"

	// ClientActionShutdown Power off the host
	ClientActionShutdown = "shutdown"

	// ClientActionUpdatePSK Update the client PSK
	ClientActionUpdatePSK = "update_psk"
)
View Source
const (

	// EventTypeUserLoggedIn UserLoggedIn event
	EventTypeUserLoggedIn = "UserLoggedIn"

	// EventTypeUserIncorrectPassword UserIncorrectPassword event
	EventTypeUserIncorrectPassword = "UserIncorrectPassword"

	// EventTypeUserLoggedOut UserLoggedOut event
	EventTypeUserLoggedOut = "UserLoggedOut"

	// EventTypeUserAdded UserAdded event
	EventTypeUserAdded = "UserAdded"

	// EventTypeUserModified UserModified event
	EventTypeUserModified = "UserModified"

	// EventTypeUserResetPassword UserResetPassword event
	EventTypeUserResetPassword = "UserResetPassword"

	// EventTypeUserResetAPIKey UserResetAPIKey event
	EventTypeUserResetAPIKey = "UserResetAPIKey"

	// EventTypeUserDeleted UserDeleted event
	EventTypeUserDeleted = "UserDeleted"

	// EventTypeHostAdded HostAdded event
	EventTypeHostAdded = "HostAdded"

	// EventTypeHostModified HostModified event
	EventTypeHostModified = "HostModified"

	// EventTypeHostDeleted HostDeleted event
	EventTypeHostDeleted = "HostDeleted"

	// EventTypeHostRegisterSuccess HostRegisterSuccess event
	EventTypeHostRegisterSuccess = "HostRegisterSuccess"

	// EventTypeHostRegisterIncorrectKey HostRegisterIncorrectKey event
	EventTypeHostRegisterIncorrectKey = "HostRegisterIncorrectKey"

	// EventTypeGroupAdded GroupAdded event
	EventTypeGroupAdded = "GroupAdded"

	// EventTypeGroupModified GroupModified event
	EventTypeGroupModified = "GroupModified"

	// EventTypeGroupDeleted GroupDeleted event
	EventTypeGroupDeleted = "GroupDeleted"

	// EventTypeScheduleAdded ScheduleAdded event
	EventTypeScheduleAdded = "ScheduleAdded"

	// EventTypeScheduleModified ScheduleModified event
	EventTypeScheduleModified = "ScheduleModified"

	// EventTypeScheduleDeleted ScheduleDeleted event
	EventTypeScheduleDeleted = "ScheduleDeleted"

	// EventTypeAttachmentAdded AttachmentAdded event
	EventTypeAttachmentAdded = "AttachmentAdded"

	// EventTypeAttachmentModified AttachmentModified event
	EventTypeAttachmentModified = "AttachmentModified"

	// EventTypeAttachmentDeleted AttachmentDeleted event
	EventTypeAttachmentDeleted = "AttachmentDeleted"

	// EventTypeScriptAdded ScriptAdded event
	EventTypeScriptAdded = "ScriptAdded"

	// EventTypeScriptModified ScriptModified event
	EventTypeScriptModified = "ScriptModified"

	// EventTypeScriptDeleted ScriptDeleted event
	EventTypeScriptDeleted = "ScriptDeleted"

	// EventTypeScriptRun ScriptRun event
	EventTypeScriptRun = "ScriptRun"

	// EventTypeServerStarted ServerStarted event
	EventTypeServerStarted = "ServerStarted"

	// EventTypeServerOptionsModified ServerOptionsModified event
	EventTypeServerOptionsModified = "ServerOptionsModified"

	// EventTypeRegisterRuleAdded RegisterRuleAdded event
	EventTypeRegisterRuleAdded = "RegisterRuleAdded"

	// EventTypeRegisterRuleModified RegisterRuleModified event
	EventTypeRegisterRuleModified = "RegisterRuleModified"

	// EventTypeRegisterRuleDeleted RegisterRuleDeleted event
	EventTypeRegisterRuleDeleted = "RegisterRuleDeleted"
)
View Source
const (

	// IPVersionOptionAuto IPv4 or IPv6 as chosen by the system automatically
	IPVersionOptionAuto = "auto"

	// IPVersionOptionIPv4 IPv4 only
	IPVersionOptionIPv4 = "ipv4"

	// IPVersionOptionIPv6 IPv6 only
	IPVersionOptionIPv6 = "ipv6"
)
View Source
const (

	// RegisterRulePropertyHostname Hostname
	RegisterRulePropertyHostname = "hostname"

	// RegisterRulePropertyKernelName Kernel Name
	RegisterRulePropertyKernelName = "kernel_name"

	// RegisterRulePropertyKernelVersion Kernel Version
	RegisterRulePropertyKernelVersion = "kernel_version"

	// RegisterRulePropertyDistributionName Distribution Name
	RegisterRulePropertyDistributionName = "distribution_name"

	// RegisterRulePropertyDistributionVersion Distribution Version
	RegisterRulePropertyDistributionVersion = "distribution_version"
)
View Source
const (

	// ScheduleResultSuccess All hosts executed the script successfully
	ScheduleResultSuccess = 0

	// ScheduleResultPartialSuccess Some hosts did not execute the script successfully
	ScheduleResultPartialSuccess = 1

	// ScheduleResultFail No hosts executed the script successfully
	ScheduleResultFail = 2
)

Variables

AllClientAction all ClientAction values

View Source
var AllEnums = map[string]interface{}{

	"ClientAction": ClientActionSchema,

	"EventType": EventTypeSchema,

	"IPVersionOption": IPVersionOptionSchema,

	"RegisterRuleProperty": RegisterRulePropertySchema,

	"ScheduleResult": ScheduleResultSchema,
}

AllEnums map of all enums

AllEventType all EventType values

AllIPVersionOption all IPVersionOption values

AllRegisterRuleProperty all RegisterRuleProperty values

AllScheduleResult all ScheduleResult values

View Source
var AttachmentStore = attachmentStoreObject{}

AttachmentStore the global attachment store

View Source
var ClientActionMap = map[string]string{

	ClientActionPing: "ping",

	ClientActionRunScript: "run_script",

	ClientActionExitClient: "exit_client",

	ClientActionReboot: "reboot",

	ClientActionShutdown: "shutdown",

	ClientActionUpdatePSK: "update_psk",
}

ClientActionMap map ClientAction keys to values

View Source
var ClientActionNameMap = map[string]string{

	"Ping": "ping",

	"RunScript": "run_script",

	"ExitClient": "exit_client",

	"Reboot": "reboot",

	"Shutdown": "shutdown",

	"UpdatePSK": "update_psk",
}

ClientActionNameMap map ClientAction keys to values

View Source
var ClientActionSchema = []map[string]interface{}{

	{
		"name":        "Ping",
		"description": "Ping the host",
		"value":       "ping",
	},

	{
		"name":        "RunScript",
		"description": "Run the script on the host",
		"value":       "run_script",
	},

	{
		"name":        "ExitClient",
		"description": "Exit the client on the host",
		"value":       "exit_client",
	},

	{
		"name":        "Reboot",
		"description": "Reboot the host",
		"value":       "reboot",
	},

	{
		"name":        "Shutdown",
		"description": "Power off the host",
		"value":       "shutdown",
	},

	{
		"name":        "UpdatePSK",
		"description": "Update the client PSK",
		"value":       "update_psk",
	},
}

ClientActionSchema the ClientAction schema.

View Source
var Directories = apiDirectories{}

Directories absolute paths of API related directires.

View Source
var EventStore = eventStoreObject{}

EventStore the global event store

View Source
var EventTypeMap = map[string]string{

	EventTypeUserLoggedIn: "UserLoggedIn",

	EventTypeUserIncorrectPassword: "UserIncorrectPassword",

	EventTypeUserLoggedOut: "UserLoggedOut",

	EventTypeUserAdded: "UserAdded",

	EventTypeUserModified: "UserModified",

	EventTypeUserResetPassword: "UserResetPassword",

	EventTypeUserResetAPIKey: "UserResetAPIKey",

	EventTypeUserDeleted: "UserDeleted",

	EventTypeHostAdded: "HostAdded",

	EventTypeHostModified: "HostModified",

	EventTypeHostDeleted: "HostDeleted",

	EventTypeHostRegisterSuccess: "HostRegisterSuccess",

	EventTypeHostRegisterIncorrectKey: "HostRegisterIncorrectKey",

	EventTypeGroupAdded: "GroupAdded",

	EventTypeGroupModified: "GroupModified",

	EventTypeGroupDeleted: "GroupDeleted",

	EventTypeScheduleAdded: "ScheduleAdded",

	EventTypeScheduleModified: "ScheduleModified",

	EventTypeScheduleDeleted: "ScheduleDeleted",

	EventTypeAttachmentAdded: "AttachmentAdded",

	EventTypeAttachmentModified: "AttachmentModified",

	EventTypeAttachmentDeleted: "AttachmentDeleted",

	EventTypeScriptAdded: "ScriptAdded",

	EventTypeScriptModified: "ScriptModified",

	EventTypeScriptDeleted: "ScriptDeleted",

	EventTypeScriptRun: "ScriptRun",

	EventTypeServerStarted: "ServerStarted",

	EventTypeServerOptionsModified: "ServerOptionsModified",

	EventTypeRegisterRuleAdded: "RegisterRuleAdded",

	EventTypeRegisterRuleModified: "RegisterRuleModified",

	EventTypeRegisterRuleDeleted: "RegisterRuleDeleted",
}

EventTypeMap map EventType keys to values

View Source
var EventTypeNameMap = map[string]string{

	"UserLoggedIn": "UserLoggedIn",

	"UserIncorrectPassword": "UserIncorrectPassword",

	"UserLoggedOut": "UserLoggedOut",

	"UserAdded": "UserAdded",

	"UserModified": "UserModified",

	"UserResetPassword": "UserResetPassword",

	"UserResetAPIKey": "UserResetAPIKey",

	"UserDeleted": "UserDeleted",

	"HostAdded": "HostAdded",

	"HostModified": "HostModified",

	"HostDeleted": "HostDeleted",

	"HostRegisterSuccess": "HostRegisterSuccess",

	"HostRegisterIncorrectKey": "HostRegisterIncorrectKey",

	"GroupAdded": "GroupAdded",

	"GroupModified": "GroupModified",

	"GroupDeleted": "GroupDeleted",

	"ScheduleAdded": "ScheduleAdded",

	"ScheduleModified": "ScheduleModified",

	"ScheduleDeleted": "ScheduleDeleted",

	"AttachmentAdded": "AttachmentAdded",

	"AttachmentModified": "AttachmentModified",

	"AttachmentDeleted": "AttachmentDeleted",

	"ScriptAdded": "ScriptAdded",

	"ScriptModified": "ScriptModified",

	"ScriptDeleted": "ScriptDeleted",

	"ScriptRun": "ScriptRun",

	"ServerStarted": "ServerStarted",

	"ServerOptionsModified": "ServerOptionsModified",

	"RegisterRuleAdded": "RegisterRuleAdded",

	"RegisterRuleModified": "RegisterRuleModified",

	"RegisterRuleDeleted": "RegisterRuleDeleted",
}

EventTypeNameMap map EventType keys to values

View Source
var EventTypeSchema = []map[string]interface{}{

	{
		"name":        "UserLoggedIn",
		"description": "UserLoggedIn event",
		"value":       "UserLoggedIn",
	},

	{
		"name":        "UserIncorrectPassword",
		"description": "UserIncorrectPassword event",
		"value":       "UserIncorrectPassword",
	},

	{
		"name":        "UserLoggedOut",
		"description": "UserLoggedOut event",
		"value":       "UserLoggedOut",
	},

	{
		"name":        "UserAdded",
		"description": "UserAdded event",
		"value":       "UserAdded",
	},

	{
		"name":        "UserModified",
		"description": "UserModified event",
		"value":       "UserModified",
	},

	{
		"name":        "UserResetPassword",
		"description": "UserResetPassword event",
		"value":       "UserResetPassword",
	},

	{
		"name":        "UserResetAPIKey",
		"description": "UserResetAPIKey event",
		"value":       "UserResetAPIKey",
	},

	{
		"name":        "UserDeleted",
		"description": "UserDeleted event",
		"value":       "UserDeleted",
	},

	{
		"name":        "HostAdded",
		"description": "HostAdded event",
		"value":       "HostAdded",
	},

	{
		"name":        "HostModified",
		"description": "HostModified event",
		"value":       "HostModified",
	},

	{
		"name":        "HostDeleted",
		"description": "HostDeleted event",
		"value":       "HostDeleted",
	},

	{
		"name":        "HostRegisterSuccess",
		"description": "HostRegisterSuccess event",
		"value":       "HostRegisterSuccess",
	},

	{
		"name":        "HostRegisterIncorrectKey",
		"description": "HostRegisterIncorrectKey event",
		"value":       "HostRegisterIncorrectKey",
	},

	{
		"name":        "GroupAdded",
		"description": "GroupAdded event",
		"value":       "GroupAdded",
	},

	{
		"name":        "GroupModified",
		"description": "GroupModified event",
		"value":       "GroupModified",
	},

	{
		"name":        "GroupDeleted",
		"description": "GroupDeleted event",
		"value":       "GroupDeleted",
	},

	{
		"name":        "ScheduleAdded",
		"description": "ScheduleAdded event",
		"value":       "ScheduleAdded",
	},

	{
		"name":        "ScheduleModified",
		"description": "ScheduleModified event",
		"value":       "ScheduleModified",
	},

	{
		"name":        "ScheduleDeleted",
		"description": "ScheduleDeleted event",
		"value":       "ScheduleDeleted",
	},

	{
		"name":        "AttachmentAdded",
		"description": "AttachmentAdded event",
		"value":       "AttachmentAdded",
	},

	{
		"name":        "AttachmentModified",
		"description": "AttachmentModified event",
		"value":       "AttachmentModified",
	},

	{
		"name":        "AttachmentDeleted",
		"description": "AttachmentDeleted event",
		"value":       "AttachmentDeleted",
	},

	{
		"name":        "ScriptAdded",
		"description": "ScriptAdded event",
		"value":       "ScriptAdded",
	},

	{
		"name":        "ScriptModified",
		"description": "ScriptModified event",
		"value":       "ScriptModified",
	},

	{
		"name":        "ScriptDeleted",
		"description": "ScriptDeleted event",
		"value":       "ScriptDeleted",
	},

	{
		"name":        "ScriptRun",
		"description": "ScriptRun event",
		"value":       "ScriptRun",
	},

	{
		"name":        "ServerStarted",
		"description": "ServerStarted event",
		"value":       "ServerStarted",
	},

	{
		"name":        "ServerOptionsModified",
		"description": "ServerOptionsModified event",
		"value":       "ServerOptionsModified",
	},

	{
		"name":        "RegisterRuleAdded",
		"description": "RegisterRuleAdded event",
		"value":       "RegisterRuleAdded",
	},

	{
		"name":        "RegisterRuleModified",
		"description": "RegisterRuleModified event",
		"value":       "RegisterRuleModified",
	},

	{
		"name":        "RegisterRuleDeleted",
		"description": "RegisterRuleDeleted event",
		"value":       "RegisterRuleDeleted",
	},
}

EventTypeSchema the EventType schema.

View Source
var GroupCache = &cacheTypeGroup{lock: &sync.RWMutex{}}

GroupCache the group cache

View Source
var GroupStore = groupStoreObject{}

GroupStore the global group store

View Source
var HostCache = &cacheTypeHost{lock: &sync.RWMutex{}}

HostCache the host cache

View Source
var HostStore = hostStoreObject{}

HostStore the global host store

View Source
var IPVersionOptionMap = map[string]string{

	IPVersionOptionAuto: "auto",

	IPVersionOptionIPv4: "ipv4",

	IPVersionOptionIPv6: "ipv6",
}

IPVersionOptionMap map IPVersionOption keys to values

View Source
var IPVersionOptionNameMap = map[string]string{

	"Auto": "auto",

	"IPv4": "ipv4",

	"IPv6": "ipv6",
}

IPVersionOptionNameMap map IPVersionOption keys to values

View Source
var IPVersionOptionSchema = []map[string]interface{}{

	{
		"name":        "Auto",
		"description": "IPv4 or IPv6 as chosen by the system automatically",
		"value":       "auto",
	},

	{
		"name":        "IPv4",
		"description": "IPv4 only",
		"value":       "ipv4",
	},

	{
		"name":        "IPv6",
		"description": "IPv6 only",
		"value":       "ipv6",
	},
}

IPVersionOptionSchema the IPVersionOption schema.

View Source
var RegisterRulePropertyMap = map[string]string{

	RegisterRulePropertyHostname: "hostname",

	RegisterRulePropertyKernelName: "kernel_name",

	RegisterRulePropertyKernelVersion: "kernel_version",

	RegisterRulePropertyDistributionName: "distribution_name",

	RegisterRulePropertyDistributionVersion: "distribution_version",
}

RegisterRulePropertyMap map RegisterRuleProperty keys to values

View Source
var RegisterRulePropertyNameMap = map[string]string{

	"Hostname": "hostname",

	"KernelName": "kernel_name",

	"KernelVersion": "kernel_version",

	"DistributionName": "distribution_name",

	"DistributionVersion": "distribution_version",
}

RegisterRulePropertyNameMap map RegisterRuleProperty keys to values

View Source
var RegisterRulePropertySchema = []map[string]interface{}{

	{
		"name":        "Hostname",
		"description": "Hostname",
		"value":       "hostname",
	},

	{
		"name":        "KernelName",
		"description": "Kernel Name",
		"value":       "kernel_name",
	},

	{
		"name":        "KernelVersion",
		"description": "Kernel Version",
		"value":       "kernel_version",
	},

	{
		"name":        "DistributionName",
		"description": "Distribution Name",
		"value":       "distribution_name",
	},

	{
		"name":        "DistributionVersion",
		"description": "Distribution Version",
		"value":       "distribution_version",
	},
}

RegisterRulePropertySchema the RegisterRuleProperty schema.

View Source
var RegisterRuleStore = registerruleStoreObject{}

RegisterRuleStore the global registerrule store

View Source
var ScheduleCache = &cacheTypeSchedule{lock: &sync.RWMutex{}}

ScheduleCache the schedule cache

View Source
var ScheduleReportStore = schedulereportStoreObject{}

ScheduleReportStore the global schedulereport store

ScheduleResultMap map ScheduleResult keys to values

View Source
var ScheduleResultNameMap = map[string]int{

	"Success": 0,

	"PartialSuccess": 1,

	"Fail": 2,
}

ScheduleResultNameMap map ScheduleResult keys to values

View Source
var ScheduleResultSchema = []map[string]interface{}{

	{
		"name":        "Success",
		"description": "All hosts executed the script successfully",
		"value":       0,
	},

	{
		"name":        "PartialSuccess",
		"description": "Some hosts did not execute the script successfully",
		"value":       1,
	},

	{
		"name":        "Fail",
		"description": "No hosts executed the script successfully",
		"value":       2,
	},
}

ScheduleResultSchema the ScheduleResult schema.

View Source
var ScheduleStore = scheduleStoreObject{}

ScheduleStore the global schedule store

View Source
var ScriptCache = &cacheTypeScript{lock: &sync.RWMutex{}}

ScriptCache the script cache

View Source
var ScriptStore = scriptStoreObject{}

ScriptStore the global script store

View Source
var ServerVersion = "dev"

ServerVersion the version of server

View Source
var SessionStore = &sessionStoreObject{
	m: map[string]Session{},
	l: &sync.RWMutex{},
}

SessionStore describes the session store

View Source
var ShadowStore = shadowStoreObject{
	Lock: &sync.Mutex{},
}

ShadowStore the global shadow store

View Source
var State *cbgenStateObject

State the global state object

View Source
var UserCache = &cacheTypeUser{lock: &sync.RWMutex{}}

UserCache the user cache

View Source
var UserStore = userStoreObject{}

UserStore the global user store

Functions

func CacheSetup

func CacheSetup()

CacheSetup populate all caches

func CommonSetup

func CommonSetup()

CommonSetup common setup methods

func CronSetup

func CronSetup()

CronSetup start the cron

func DirectoryExists

func DirectoryExists(directoryPath string) bool

DirectoryExists does the given directory exist (and is it a directory)

func FileExists

func FileExists(filePath string) bool

FileExists does the given file exist

func IsClientAction

func IsClientAction(q string) bool

IsClientAction is the provided value a valid ClientAction

func IsEventType

func IsEventType(q string) bool

IsEventType is the provided value a valid EventType

func IsIPVersionOption

func IsIPVersionOption(q string) bool

IsIPVersionOption is the provided value a valid IPVersionOption

func IsRegisterRuleProperty

func IsRegisterRuleProperty(q string) bool

IsRegisterRuleProperty is the provided value a valid RegisterRuleProperty

func IsScheduleResult

func IsScheduleResult(q int) bool

IsScheduleResult is the provided value a valid ScheduleResult

func LoadOptions

func LoadOptions()

LoadOptions load Otto Server options

func MakeDirectoryIfNotExist

func MakeDirectoryIfNotExist(directoryPath string) error

MakeDirectoryIfNotExist make the given directory if it does not exist

func RouterSetup

func RouterSetup()

RouterSetup set up the HTTP router

func Start

func Start()

Start the app

func StartHeartbeatMonitor

func StartHeartbeatMonitor()

StartHeartbeatMonitor starts the heartbeat monitor

func Stop

func Stop()

Stop stop the API service gracefully

Types

type Attachment

type Attachment struct {
	ID       string `ds:"primary"`
	Path     string
	Name     string
	MimeType string
	Owner    RunAs
	Created  time.Time
	Modified time.Time
	Mode     uint32
	Size     uint64
}

Attachment describes a file for a script

func (Attachment) FilePath

func (attachment Attachment) FilePath() string

FilePath returns the absolute path for this attachment

func (Attachment) OttoFile

func (attachment Attachment) OttoFile() (*otto.File, error)

OttoFile return an otto common file

type AuthenticationResult

type AuthenticationResult struct {
	SessionKey         string
	MustChangePassword bool
}

AuthenticationResult describes an authentication result

type Error

type Error struct {
	Server  bool
	Message string
	Error   error
}

Error describes an error object

func ErrorFrom

func ErrorFrom(err error) *Error

ErrorFrom create a new server-side error from the given error

func ErrorServer

func ErrorServer(format string, a ...interface{}) *Error

ErrorServer create a new server-side error

func ErrorUser

func ErrorUser(format string, a ...interface{}) *Error

ErrorUser create a new user-facing error

type Event

type Event struct {
	ID      string `ds:"primary"`
	Event   string `ds:"index"`
	Time    time.Time
	Details map[string]string
}

Event describes an Otto server event

func (Event) Save

func (e Event) Save()

Save save the event

type Group

type Group struct {
	ID          string `ds:"primary"`
	Name        string `ds:"unique" min:"1" max:"140"`
	ScriptIDs   []string
	Environment []environ.Variable
}

Group describes a group object

func (Group) HostIDs

func (g Group) HostIDs() []string

HostIDs return the IDs for each host member of this group

func (Group) Hosts

func (g Group) Hosts() ([]Host, *Error)

Hosts get all hosts for this group

func (Group) Scripts

func (g Group) Scripts() ([]Script, *Error)

Scripts get all scripts for this group

type Heartbeat

type Heartbeat struct {
	Address     string
	IsReachable bool
	LastReply   time.Time
	LastAttempt time.Time
	Version     string
	Properties  map[string]string
}

Heartbeat describes a heartbeat to a host

type Host

type Host struct {
	ID            string `ds:"primary"`
	Name          string `ds:"unique" min:"1" max:"140"`
	Address       string `ds:"unique" min:"1"`
	Port          uint32
	PSK           string `min:"1" max:"512"`
	LastPSKRotate time.Time
	Enabled       bool `ds:"index"`
	GroupIDs      []string
	Environment   []environ.Variable
}

Host describes a otto host

func (*Host) ExitClient

func (host *Host) ExitClient() *Error

ExitClient exit the otto client on the host

func (Host) Groups

func (h Host) Groups() ([]Group, *Error)

Groups return all groups for this host

func (*Host) Ping

func (host *Host) Ping() *Error

Ping ping the host

func (*Host) RotatePSKIfNeeded

func (h *Host) RotatePSKIfNeeded() *Error

func (*Host) RotatePSKNow

func (h *Host) RotatePSKNow() (string, *Error)

func (*Host) RunScript

func (host *Host) RunScript(script *Script, scriptOutput func(stdout, stderr []byte), cancel chan bool) (*ScriptResult, *Error)

RunScript run the script on the host. Error will only ever be populated with internal server errors, such as being unable to read from the database.

func (Host) Scripts

func (h Host) Scripts() []ScriptEnabledGroup

Scripts return all scripts for this host

func (*Host) TriggerAction

func (host *Host) TriggerAction(action otto.MessageTriggerAction, actionOutput func(stdout, stderr []byte), cancel chan bool) (*otto.ScriptResult, *Error)

TriggerAction will trigger the given action on the host

type OptionsAuthentication

type OptionsAuthentication struct {
	MaxAgeMinutes int
	SecureOnly    bool
}

OptionsAuthentication describes the authentication options

type OptionsGeneral

type OptionsGeneral struct {
	ServerURL         string
	GlobalEnvironment []environ.Variable
}

OptionsGeneral describes the general options

type OptionsNetwork

type OptionsNetwork struct {
	ForceIPVersion     string
	Timeout            int64
	HeartbeatFrequency int64
}

OptionsNetwork describes network options for connecting to otto clients

type OptionsPSKRotate

type OptionsPSKRotate struct {
	Enabled       bool
	FrequencyDays uint
}

OptionsPSKRotate describes PSK rotation options

type OptionsRegister

type OptionsRegister struct {
	Enabled              bool
	Key                  string
	DefaultGroupID       string
	RunScriptsOnRegister bool
}

OptionsRegister describes register options

type OptionsSecurity

type OptionsSecurity struct {
	IncludePSKEnv bool
	RotatePSK     OptionsPSKRotate
}

OptionsSecurity describes security options

type OttoOptions

type OttoOptions struct {
	General        OptionsGeneral
	Authentication OptionsAuthentication
	Network        OptionsNetwork
	Register       OptionsRegister
	Security       OptionsSecurity
}

OttoOptions describes options for the otto server

var Options *OttoOptions

Options the global options

func (*OttoOptions) Save

func (o *OttoOptions) Save() (string, bool)

Save save the options to disk. Will panic on any error. Returns true if the options did change

func (*OttoOptions) Validate

func (o *OttoOptions) Validate() error

Validate returns an error if the options is not valid

type RegisterRule

type RegisterRule struct {
	ID      string               `ds:"primary"`
	Name    string               `ds:"unique" min:"1" max:"140"`
	Clauses []RegisterRuleClause `min:"1"`
	GroupID string               `ds:"index"`
}

RegisterRule describes a register rule

func (RegisterRule) Matches

func (rule RegisterRule) Matches(properties otto.RegisterRequestProperties) bool

Matches does this rule match the given set of host properties

type RegisterRuleClause

type RegisterRuleClause struct {
	Property string
	Pattern  string
}

RegisterRuleClause describes a single clause for a register rule

type RunAs

type RunAs struct {
	Inherit bool
	UID     uint32
	GID     uint32
}

RunAs describes the properties of which user runs a script

type Schedule

type Schedule struct {
	ID          string `ds:"primary"`
	Name        string `ds:"unique" min:"1" max:"140"`
	ScriptID    string `ds:"index"`
	Scope       ScheduleScope
	Pattern     string
	Enabled     bool
	LastRunTime time.Time
}

Schedule describes a recurring task

func (Schedule) RunNow

func (s Schedule) RunNow()

RunNow run the schedule now

type ScheduleReport

type ScheduleReport struct {
	ID         string `ds:"primary"`
	ScheduleID string `ds:"index"`
	HostIDs    []string
	Time       ScheduleReportTime
	Result     int
	HostResult map[string]int
}

ScheduleReport describes a report from a schedule

type ScheduleReportTime

type ScheduleReportTime struct {
	Start          time.Time
	Finished       time.Time
	ElapsedSeconds float64
}

ScheduleReportTime describes timing information from a schedule run

type ScheduleScope

type ScheduleScope struct {
	HostIDs  []string
	GroupIDs []string
}

ScheduleScope describes the scope for a schedule

func (ScheduleScope) Groups

func (s ScheduleScope) Groups() ([]Group, *Error)

Groups get the groups for this schedule

func (ScheduleScope) Hosts

func (s ScheduleScope) Hosts() ([]Host, *Error)

Hosts get the hosts for this schedule

type Script

type Script struct {
	ID               string `ds:"primary"`
	Name             string `ds:"unique" min:"1" max:"140"`
	Enabled          bool   `ds:"index"`
	Executable       string `min:"1"`
	Script           string `min:"1"`
	Environment      []environ.Variable
	RunAs            RunAs
	WorkingDirectory string
	AfterExecution   string
	AttachmentIDs    []string
}

Script describes an otto script

func (*Script) Attachments

func (s *Script) Attachments() ([]Attachment, *Error)

Attachments all files for this script

func (*Script) Groups

func (s *Script) Groups() []Group

Groups all groups with this script enabled

func (*Script) Hosts

func (s *Script) Hosts() []ScriptEnabledHost

Hosts all hosts with this script enabled

func (Script) OttoScript

func (s Script) OttoScript() (*otto.Script, *Error)

type ScriptEnabledGroup

type ScriptEnabledGroup struct {
	ScriptID   string
	ScriptName string
	GroupID    string
	GroupName  string
}

ScriptEnabledGroup describes a host where a script is enabled on it by a group

type ScriptEnabledHost

type ScriptEnabledHost struct {
	ScriptID   string
	ScriptName string
	GroupID    string
	GroupName  string
	HostID     string
	HostName   string
}

ScriptEnabledHost describes a host where a script is eanbled on it by a group

type ScriptResult

type ScriptResult struct {
	ScriptID    string
	Duration    time.Duration
	Environment []environ.Variable
	Result      otto.ScriptResult
	RunError    string
}

ScriptResult describes a script result

type Session

type Session struct {
	Key      string
	ShortID  string
	Username string
	Partial  bool
	Expires  time.Time
}

Session describes a user session

func (Session) User

func (s Session) User() *User

User get the user object for this session

type SystemSearchResult

type SystemSearchResult struct {
	Type  string
	Label string
	URL   string
}

SystemSearchResult describes a search result for a system search

func SystemSearch

func SystemSearch(q string) []SystemSearchResult

SystemSearch search the otto system

type User

type User struct {
	Username           string `ds:"primary" max:"32" min:"1"`
	Email              string `ds:"unique" max:"128" min:"1"`
	CanLogIn           bool
	MustChangePassword bool
}

User describes a user object

Directories

Path Synopsis
Package environ is a custom environment variable utilities for otto
Package environ is a custom environment variable utilities for otto

Jump to

Keyboard shortcuts

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