manager

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegisterManages = make(chan interface{}, 1)

RegisterManages

Functions

func RegisterManager

func RegisterManager(manager Manager)

RegisterManager

Types

type Attribute

type Attribute struct {
	// DevicePath represents the disk hardware path.
	// The general format is like /sys/devices/pci0000:ae/0000:ae:02.0/0000:b1:00.0/host2/target2:1:0/2:1:0:0/block/sdc/sdc
	DevPath string `json:"devPath,omitempty"`

	// DevName the general format is /dev/sda
	DevName string `json:"devName,omitempty"`

	// DevType such as disk, partition
	DevType string `json:"devType,omitempty"`

	// Major represents drive used by the device
	Major string `json:"major,omitempty"`

	// Minor is used to distinguish different devices
	Minor string `json:"minor,omitempty"`

	// SubSystem identifies the device's system type, such as block
	SubSystem string `json:"subSystem,omitempty"`

	// Bus
	Bus string `json:"id_bus,omitempty"`

	// FS_TYPE
	FSType string `json:"id_fs_type,omitempty"`

	// Model
	Model string `json:"id_model,omitempty"`

	// WWN
	WWN string `json:"id_wwn,omitempty"`

	// PartTableType
	PartTableType string `json:"id_part_table_type,omitempty"`

	// Serial
	Serial string `json:"id_serial,omitempty"`

	// Vendor
	Vendor string `json:"id_vendor,omitempty"`

	// ID_TYPE
	IDType string `json:"id_type"`

	// Capacity of the disk in bytes
	Capacity int64 `json:"capacity,omitempty"`

	// DriverType such as HDD, SSD
	DriverType string `json:"driverType"`

	// DEVLINKS
	DevLinks []string `json:"devLinks"`
}

Attribute for disk details

type AttributeParser

type AttributeParser struct {
	IDiskAttribute
}

AttributeParser

type DiskIdentify

type DiskIdentify struct {
	// DevPath such as /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0/host0/target0:0:1/0:0:1:0/block/sda
	DevPath string `json:"devPath"`

	// DevName such as /dev/sda
	DevName string `json:"devName"`

	// Name such as sda
	Name string `json:"name"`
}

DiskIdentify

func NewDiskIdentify

func NewDiskIdentify(devPath string) *DiskIdentify

NewDiskIdentify

func NewDiskIdentifyWithName

func NewDiskIdentifyWithName(devPath, devName string) *DiskIdentify

func (*DiskIdentify) SetName

func (disk *DiskIdentify) SetName(devName string)

SetName

func (*DiskIdentify) SetPath

func (disk *DiskIdentify) SetPath(devPath string)

SetPath

type DiskInfo

type DiskInfo struct {
	// DiskIdentify
	DiskIdentify `json:"diskIdentify,omitempty"`

	// Attribute
	Attribute Attribute `json:"attribute,omitempty"`

	// Partition
	Partitions []PartitionInfo `json:"partition,omitempty"`

	// Raid
	Raid RaidInfo `json:"raid,omitempty"`

	// Smart
	Smart SmartInfo `json:"smart"`
}

DiskInfo

func (DiskInfo) GenerateUUID

func (disk DiskInfo) GenerateUUID() (uuid string)

GenerateUUID generates a UUID for the disk If the serial number exists, it is used first. If it does not exist, it is generated using by-path path

type DiskParser

type DiskParser struct {
	// DiskIdentify
	*DiskIdentify
	*PartitionParser
	*RaidParser
	*AttributeParser
	*SmartInfoParser
}

DiskParser The information source of the disk may use a variety of methods. For localDisk, it only focuses on the basic information of the disk itself. Therefore, there is no direct binding between the disk attributes and the specific implementation. The parser will be responsible for docking with various tools to output fixed information

func NewDiskParser

func NewDiskParser(
	disk *DiskIdentify,
	partitionParser *PartitionParser,
	raidParser *RaidParser,
	attrParser *AttributeParser,
	smartParser *SmartInfoParser,
) *DiskParser

NewDiskParser

func (*DiskParser) For

func (dp *DiskParser) For(disk DiskIdentify) *DiskParser

For

func (*DiskParser) ParseDisk

func (dp *DiskParser) ParseDisk() DiskInfo

ParseDisk

type Event

type Event struct {
	Type    EventType
	DevPath string
	DevName string
	DevType string
}

Event indicates the type of MountRawBlock event and the properties of the mounted disk

type EventType

type EventType = string

EventType indicates the type of mount event

const (
	ADD     EventType = "add"
	REMOVE  EventType = "remove"
	CHANGE  EventType = "change"
	MOVE    EventType = "move"
	ONLINE  EventType = "online"
	OFFLINE EventType = "offline"
	BIND    EventType = "bind"
	UNBIND  EventType = "unbind"
	EXIST   EventType = "exist"
)

type IDiskAttribute

type IDiskAttribute interface {
	ParseDiskAttr() Attribute
}

IDiskAttribute

type IPartition

type IPartition interface {
	HasPartition() bool

	ParsePartitionInfo() []PartitionInfo
}

IPartition

type IRaid

type IRaid interface {
	HasRaid() bool

	ParseRaidInfo() RaidInfo
}

IRaid

type ISmart added in v0.6.0

type ISmart interface {
	SupportSmart() (bool, error)
	// GetHealthStatus Show device SMART health status
	// true: passed false: not passed
	GetHealthStatus() (bool, error)
	ParseSmartInfo() SmartInfo
}

type Manager

type Manager interface {
	// ListExist list all disks exist on node
	ListExist() []Event

	// Monitor monitor all disk events(e.g. add/remove/offline)
	Monitor(chan Event)

	// StartTimerTrigger periodic trigger event
	StartTimerTrigger(chan Event)
}

Manager for disk monitor

func NewManager

func NewManager() Manager

NewManager

type PartitionInfo

type PartitionInfo struct {
	// Name
	Name string

	// Size
	Size uint64

	// Label
	Label string

	// Filesystem
	Filesystem string

	// Path
	Path string
}

PartitionInfo

type PartitionParser

type PartitionParser struct {

	// IPartition
	IPartition
}

Partition

type RaidInfo

type RaidInfo struct {
	// HasRaid
	HasRaid bool
}

RaidInfo

type RaidParser

type RaidParser struct {
	// DiskIdentify Uniquely identify a disk
	DiskIdentify

	IRaid
}

Raid

type SmartInfo added in v0.6.0

type SmartInfo struct {
	// SupportSmart
	SupportSmart bool

	// OverallHealthPassed
	// true: passed false: not passed
	OverallHealthPassed bool
}

type SmartInfoParser added in v0.6.0

type SmartInfoParser struct {
	ISmart
}

Jump to

Keyboard shortcuts

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