sledapi

package
v0.8.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TimeFormat is how time will be stored in etcd
	TimeFormat string = time.RFC1123

	EtcdTimeout = 10 * time.Second
)
View Source
const (
	// ReadyMsg indicates sending the Ready request
	ReadyMsg = "ready"
	// PingMsg indicates sending the Ping request
	PingMsg = "ping"
	// HistoryMsg indicates sending the History request
	HistoryMsg = "history"
	// UptimeMsg indicates sending the Uptime request
	UptimeMsg = "uptime"
	// StatusMsg indicates sending the Status request
	StatusMsg = "status"
	// ProgressMsg indicates sending the Progress request
	ProgressMsg = "progress"
	// UpgradeMsg indicates sending the Upgrade request
	UpgradeMsg = "upgrade"
)

Variables

View Source
var (
	// Namespace is the etcd namespace for each connect
	Namespace = "/sled/" // nolint:gochecknoglobals
	// TaskPrefix is the etcd task prefix for task objects
	TaskPrefix = "task" // nolint:gochecknoglobals
	// CommandPrefix is the etcd command prefix for the command object
	CommandPrefix = "command" // nolint:gochecknoglobals
	// DaemonPrefix is the etcd task prefix for task objects
	DaemonPrefix = "daemon" // nolint:gochecknoglobals
)
View Source
var (
	// DaemonRetryWait is the amount of time to wait on a ready retry failure
	DaemonRetryWait = 3 // nolint:gochecknoglobals
	// DaemonRetries is the number of times to wait on a ready retry failure
	DaemonRetries = 2 // nolint:gochecknoglobals

)
View Source
var (
	// SleddHost is the name or ip for sledapi to connect to
	// a sledd host for sledc daemon communications
	SleddHost string = "sled-server" // nolint:gochecknoglobals
)

Functions

func DaemonToProto

func DaemonToProto(daemon *Daemon) (*sled.DaemonProto, error)

DaemonToProto converts the storage daemon to protobuf.

func DaemonWatcherThread

func DaemonWatcherThread() error

DaemonWatcherThread watches the daemon key space for activity. When a key is found by watch, a message is kicked off through sledd to the sledc client for the update.

func EtcdConnect

func EtcdConnect() (*clientv3.Client, error)

EtcdConnect tries 10 times to return EtcdClient.

func GetAllMacs added in v0.8.0

func GetAllMacs(prefix string) (interface{}, error)

GetAllMacs does an etcd prefix get to retrieve all mac addresses.

func GetCommandStor added in v0.7.0

func GetCommandStor(mac string) (*sled.CommandSet, error)

GetCommandStor returns the commandset struct from storage.

func GetDaemonStor

func GetDaemonStor(mac string) (*sled.DaemonProto, error)

GetDaemonStor returns the daemon struct from storage.

func GetSledcDmesg added in v0.8.1

func GetSledcDmesg(daemon *Daemon) (*sled.Logs, error)

GetSledcDmesg retrieves the sledc logs from the client.

func GetSledcLogs added in v0.8.0

func GetSledcLogs(daemon *Daemon) (*sled.Logs, error)

GetSledcLogs retrieves the sledc logs from the client.

func GetTasks

func GetTasks() ([]*sled.GetStatusResponse, error)

GetTasks returns all tasks with the same prefix, we keep this around for usability, but otherwise it is not needed.

func RunSledShell added in v0.8.1

func RunSledShell(daemon *Daemon, command string) (*sled.Logs, error)

RunSledShell runs a shell command on sledc.

func SendToSledd

func SendToSledd(
	daemon *Daemon, msgType string, data interface{}, retry int,
) error

SendToSledd takes the message from the watcher function and creates the update message to send to sledd and finally onto the sledc client.

func UpdateTaskStatus added in v0.7.0

func UpdateTaskStatus(
	id, cmd, mac string, status *sled.Response, wr *WriteMiscUpdate) (
	*sled.NackResponse, error,
)

UpdateTaskStatus updates the database with the received status if sends a nack back to the client if there is an issue with the status id from what is currently stored in the database.

func UpgradeSledClient added in v0.8.0

func UpgradeSledClient(daemon *Daemon, us *sled.UpgradeSet) (*sled.UpgradeUpdateResponse, error)

UpgradeSledClient is responsible for sending an upgrade request to the client unlike other sledd messages, this message expects a response from the client indicating if the upgrade was completed (to the best of its knowledge).

func WithEtcd

func WithEtcd(f func(*clientv3.Client) error) error

WithEtcd executes a function against an etcd client with a managed connection lifetime.

func WithMinEtcd

func WithMinEtcd(f func(*clientv3.Client) (interface{}, error)) (interface{}, error)

WithMinEtcd executes a function against an etcd client with a managed connection lifetime.

Types

type Command

type Command struct {
	Mac       string
	StatusID  string
	Wipe      *sled.WipeResponse  `yaml:",omitempty"`
	Write     *sled.WriteResponse `yaml:",omitempty"`
	Kexec     *sled.KexecResponse `yaml:",omitempty"`
	Daemon    sled.EnumStatus     `yaml:",omitempty"`
	Timestamp string              `yaml:",omitempty"`
	// contains filtered or unexported fields
}

Command struct is the data structure that contains the sled CommandSet in etcd.

func (*Command) GetVersion

func (x *Command) GetVersion() int64

GetVersion returns the current datastore version of the object.

func (*Command) Key

func (x *Command) Key() string

Key returns the datastore key for this object.

func (*Command) SetVersion

func (x *Command) SetVersion(v int64)

SetVersion sets the current datastore version of the object.

func (*Command) Value

func (x *Command) Value() interface{}

Value returns this object as an interface{}.

type Daemon

type Daemon struct {
	Mac       string
	IP        string          `yaml:",omitempty"`
	Port      string          `yaml:",omitempty"`
	Status    sled.EnumStatus `yaml:",omitempty"`
	Initrd    string          `yaml:",omitempty"`
	Disk      string          `yaml:",omitempty"`
	Kernel    string          `yaml:",omitempty"`
	Timestamp string          `yaml:",omitempty"`
	// contains filtered or unexported fields
}

Daemon struct contains the DaemonProto data structure in etcd.

func ProtoToDaemon

func ProtoToDaemon(daemon *sled.DaemonProto) (*Daemon, error)

ProtoToDaemon converts the storage daemon to protobuf.

func (*Daemon) GetVersion

func (x *Daemon) GetVersion() int64

GetVersion returns the current datastore version of the object.

func (*Daemon) Key

func (x *Daemon) Key() string

Key returns the datastore key for this object.

func (*Daemon) SetVersion

func (x *Daemon) SetVersion(v int64)

SetVersion sets the current datastore version of the object.

func (*Daemon) Value

func (x *Daemon) Value() interface{}

Value returns this object as an interface{}.

type Task

type Task struct {
	ID        string
	Command   string
	Status    sled.Response_Status `yaml:",omitempty"`
	Timestamp string               `yaml:",omitempty"`
	ErrMsg    string               `yaml:",omitempty"`
	Mac       string
	// contains filtered or unexported fields
}

Task struct contains the sled Response data structure in etcd.

func (*Task) GetVersion

func (x *Task) GetVersion() int64

GetVersion returns the current datastore version of the object.

func (*Task) Key

func (x *Task) Key() string

Key returns the datastore key for this object.

func (*Task) SetVersion

func (x *Task) SetVersion(v int64)

SetVersion sets the current datastore version of the object.

func (*Task) Value

func (x *Task) Value() interface{}

Value returns this object as an interface{}.

type WriteMiscUpdate added in v0.7.0

type WriteMiscUpdate struct {
	Daemon bool
	Disk   string
	Kernel string
	Initrd string
}

WriteMiscUpdate contains the other misc fields in a write update.

Jump to

Keyboard shortcuts

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