Documentation
¶
Index ¶
- Constants
- Variables
- func DBRead(key string) ([]byte, error)
- func FindMacAddress(iface string) (mac string, err error)
- func GetBlockDeviceSize(device string) (int64, error)
- func GetBlockDevices() ([]string, error)
- func GetDaemonStatus() (*sled.DaemonStatus, error)
- func GetInterface(server string, port int) (string, *net.Interface, error)
- func HTTPGrab(server, image, dst string) (string, error)
- func InitClient(server string, port int) (*grpc.ClientConn, sled.SledctodProtocolClient)
- func Kexec(kernel, append, initrd string) error
- func MacPrefixList(mac string) []string
- func ReadUptime() (time.Duration, string, error)
- func RequestDNSIface(iface net.Interface, server string, port int) (string, error)
- func SendLLDP(iface *net.Interface, hostname string)
- func Wipe(device string, size int64) error
- func WipeBlock(device string) error
- func WipeFilesystem(device string) error
- func WriteCommunicator(server string, images map[string]string) error
- func WriteDaemonStatus(ds sled.EnumStatus) error
- func WriteImageStatus(dbi *DBItem) error
- type DBItem
Constants ¶
const ( //BufferSize = 16 Mb BufferSize = 1024 * 1024 * 128 // KernelKey key for map/bitcask KernelKey = "kernel" // InitrdKey key for map/bitcask InitrdKey = "initrd" // DeviceKey key for map/bitcask DeviceKey = "device" // ImageKey key for map/bitcask ImageKey = "image" // TimeStampKey key for map/bitcask TimeStampKey = "timestamp" // StatusKey key for map/bitcask StatusKey = "status" Timeout = 10 * time.Second LLDPRetryTimer = 1 * time.Minute LLDPMessageLife = 2 * time.Minute )
Variables ¶
var ( // SledServerIPs is a cache for resolving ips of sled-server SledServerIPs = []net.IP{} // nolint:gochecknoglobals // Test variable is used for dry-running write, wipe, and kexec functionality. Test = false // nolint:gochecknoglobals )
Functions ¶
func DBRead ¶ added in v0.6.0
DBRead reads key from bitcask (in-memory) datastore. Sledc stores history information, as well as what images have been written, in order for sledapi to inquire about the current state of the daemon.
func FindMacAddress ¶ added in v0.5.1
FindMacAddress returns all mac addresses for interfaces.
func GetBlockDeviceSize ¶
GetBlockDeviceSize get the size (to wipe) for each block.
func GetBlockDevices ¶
GetBlockDevices helper function to retrieve blocks on client.
func GetDaemonStatus ¶ added in v0.6.0
func GetDaemonStatus() (*sled.DaemonStatus, error)
GetDaemonStatus returns the status of sledc daemon from bitcaskdb.
func GetInterface ¶ added in v0.5.1
GetInterface returns an interface that is capable of resolving and connecting to the destination server.
func HTTPGrab ¶ added in v0.4.0
HTTPGrab function grabs an image from a server and writes it to a local destination. Intended to be used to download kernel, initramfs, and filesystem.
func InitClient ¶ added in v0.5.1
func InitClient(server string, port int) (*grpc.ClientConn, sled.SledctodProtocolClient)
InitClient creates the grpc connection to sledd's grpc server. These connections are used for sledc to communicate back up to sledapi and the calling functions on sledc's status.
func Kexec ¶
Kexec (-l load, -c cmd, -i initrd) kernel can be grub, therefore, append and initrd are optional for kexec to load now that this can occur in daemon mode, we dont fatal, we just fail that way there is a potential to try again from the sledd side.
func MacPrefixList ¶ added in v0.5.1
MacPrefixList returns an ordered (longest to shortest) mac prefix list that enables searching on a mac address by prefix.
func ReadUptime ¶ added in v0.6.0
ReadUptime reads the proc uptime file and returns how long the daemon has been online for.
func RequestDNSIface ¶ added in v0.5.1
RequestDNSIface will attempt to dial a remote host, because this this host is either dns or ip, the connect indicates that the iface can reach that host, and we should use that interface's mac address for future requests.
func SendLLDP ¶ added in v0.6.0
SendLLDP is a responsible for sending out lldp packets to neighbors. It is a background process that is launched even when not in daemon mode.
func WipeFilesystem ¶ added in v0.8.0
WipeFilesystem removes the filesystem signature (wipefs). It is currently implemented for only ext4 filesystems.
func WriteCommunicator ¶
WriteCommunicator takes a server, and set of images to download from the server. It mainly handles the parsing on what type of image is being downloaded, and how to save it. Images are saved to disk, while kernel and initramfs are written to /tmp.
func WriteDaemonStatus ¶ added in v0.6.0
func WriteDaemonStatus(ds sled.EnumStatus) error
WriteDaemonStatus writes the status of sledc daemon to bitcaskdb.
func WriteImageStatus ¶ added in v0.6.0
WriteImageStatus writes the image status to bitcaskdb.
Types ¶
type DBItem ¶ added in v0.6.0
type DBItem struct {
Server string // ip of sled-server
Name string // name of the item
Item string // item type
Timestamp time.Duration // when it was downloaded (relative uptime)
}
DBItem is a tuple for the db, which contains which server the image was fetched from.
func GetImageStatus ¶ added in v0.6.0
GetImageStatus returns the image that has been already written while in daemon mode.
func (*DBItem) ToProtobuf ¶ added in v0.6.0
func (dbi *DBItem) ToProtobuf(cur time.Duration) *sled.WriteStats
ToProtobuf transforms the database items into sled write stats to be returned to sledapi.