loopbackmgr

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package loopbackmgr contains DriveManager for test purposes based on loop devices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultDriveCount int     `yaml:"defaultDrivePerNodeCount"`
	DefaultDriveSize  string  `yaml:"defaultDriveSize"`
	Nodes             []*Node `yaml:"nodes"`
}

Config struct is the configuration for LoopBackManager. It contains default settings and settings for each node

type LoopBackDevice

type LoopBackDevice struct {
	VendorID     string `yaml:"vid"`
	ProductID    string `yaml:"pid"`
	SerialNumber string `yaml:"serialNumber"`
	Size         string `yaml:"size"`
	Removed      bool   `yaml:"removed"`
	Health       string `yaml:"health"`
	DriveType    string `yaml:"driveType"`
	LED          int    `yaml:"led"`
	// contains filtered or unexported fields
}

LoopBackDevice struct contains fields to describe a loop device bound with a file

func (*LoopBackDevice) Equals

func (d *LoopBackDevice) Equals(device *LoopBackDevice) bool

Equals checks if device is equal to provided one. Equals doesn't compare fileName and devicePath fields and compares only drive specification of devices. Receives *LoopBackDevice to check equality

type LoopBackManager

type LoopBackManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LoopBackManager is created for testing purposes only! It allows to deploy CSI driver on your laptop with minikube or kind. Developer can simulate different number of drives, their type (HDD, SSD, NVMe, etc.), health, size, topology (accessibility), etc.

func NewLoopBackManager

func NewLoopBackManager(exec command.CmdExecutor, nodeID, nodeName string, logger *logrus.Logger) *LoopBackManager

NewLoopBackManager is the constructor for LoopBackManager Receives CmdExecutor to execute os commands such as 'losetup' and logrus logger Returns an instance of LoopBackManager

func (*LoopBackManager) CleanupLoopDevices

func (mgr *LoopBackManager) CleanupLoopDevices()

CleanupLoopDevices detaches loop devices that are occupied by LoopBackManager

func (*LoopBackManager) GetBackFileToLoopMap

func (mgr *LoopBackManager) GetBackFileToLoopMap() (map[string][]string, error)

GetBackFileToLoopMap return mapping between backing file and loopback devices Multiple loopback devices can be created from on backing file.

func (*LoopBackManager) GetDrivesList

func (mgr *LoopBackManager) GetDrivesList() ([]*api.Drive, error)

GetDrivesList returns list of loopback devices as *api.Drive slice Returns *api.Drive slice or error if something went wrong

func (*LoopBackManager) Init

func (mgr *LoopBackManager) Init()

Init creates files and register them as loopback devices Returns error if something went wrong

func (*LoopBackManager) Locate

func (mgr *LoopBackManager) Locate(serialNumber string, action int32) (int32, error)

Locate implements Locate method of DriveManager interface

func (*LoopBackManager) LocateNode

func (mgr *LoopBackManager) LocateNode(action int32) error

LocateNode implements LocateNode method of DriveManager interface

func (*LoopBackManager) UpdateOnConfigChange

func (mgr *LoopBackManager) UpdateOnConfigChange(watcher *fsnotify.Watcher)

UpdateOnConfigChange triggers update configuration and init of devices.

type Node

type Node struct {
	NodeID     string            `yaml:"nodeID"`
	DriveCount int               `yaml:"driveCount"`
	Drives     []*LoopBackDevice `yaml:"drives"`
}

Node struct represents particular configuration of LoopBackManager for specified node

Jump to

Keyboard shortcuts

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