sledc

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: 20 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func DBRead(key string) ([]byte, error)

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

func FindMacAddress(iface string) (mac string, err error)

FindMacAddress returns all mac addresses for interfaces.

func GetBlockDeviceSize

func GetBlockDeviceSize(device string) (int64, error)

GetBlockDeviceSize get the size (to wipe) for each block.

func GetBlockDevices

func GetBlockDevices() ([]string, error)

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

func GetInterface(server string, port int) (string, *net.Interface, error)

GetInterface returns an interface that is capable of resolving and connecting to the destination server.

func HTTPGrab added in v0.4.0

func HTTPGrab(server, image, dst string) (string, error)

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

func Kexec(kernel, append, initrd string) error

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

func MacPrefixList(mac string) []string

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

func ReadUptime() (time.Duration, string, error)

ReadUptime reads the proc uptime file and returns how long the daemon has been online for.

func RequestDNSIface added in v0.5.1

func RequestDNSIface(iface net.Interface, server string, port int) (string, error)

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

func SendLLDP(iface *net.Interface, hostname string)

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 Wipe

func Wipe(device string, size int64) error

Wipe implements the wiping of the disk called by WipeBlock.

func WipeBlock

func WipeBlock(device string) error

WipeBlock will write 0s across the block device.

func WipeFilesystem added in v0.8.0

func WipeFilesystem(device string) error

WipeFilesystem removes the filesystem signature (wipefs). It is currently implemented for only ext4 filesystems.

func WriteCommunicator

func WriteCommunicator(server string, images map[string]string) error

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

func WriteImageStatus(dbi *DBItem) error

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

func GetImageStatus(key string) (*DBItem, error)

GetImageStatus returns the image that has been already written while in daemon mode.

func (*DBItem) FromJSON added in v0.6.0

func (dbi *DBItem) FromJSON(data []byte) error

FromJSON transforms json into DBItem.

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.

Jump to

Keyboard shortcuts

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