manager

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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"`
}

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"`
}

DiskInfo

func (DiskInfo) GenerateUUID

func (disk DiskInfo) GenerateUUID() string

GenerateUUID

type DiskParser

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

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,
) *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 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)
}

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
}

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

Jump to

Keyboard shortcuts

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