block

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 25

Documentation

Index

Constants

View Source
const (
	// DEPRECATED: Please use DriveTypeUnknown
	DRIVE_TYPE_UNKNOWN = DriveTypeUnknown
	// DEPRECATED: Please use DriveTypeHDD
	DRIVE_TYPE_HDD = DriveTypeHDD
	// DEPRECATED: Please use DriveTypeFDD
	DRIVE_TYPE_FDD = DriveTypeFDD
	// DEPRECATED: Please use DriveTypeODD
	DRIVE_TYPE_ODD = DriveTypeODD
	// DEPRECATED: Please use DriveTypeSSD
	DRIVE_TYPE_SSD = DriveTypeSSD
	// DEPRECATED: Please use DriveTypeVirtual
	DRIVE_TYPE_VIRTUAL = DriveTypeVirtual
)
View Source
const (
	// DEPRECATED: Please use StorageControllerUnknown
	STORAGE_CONTROLLER_UNKNOWN = StorageControllerUnknown
	// DEPRECATED: Please use StorageControllerIDE
	STORAGE_CONTROLLER_IDE = StorageControllerIDE
	// DEPRECATED: Please use StorageControllerSCSI
	STORAGE_CONTROLLER_SCSI = StorageControllerSCSI
	// DEPRECATED: Please use StorageControllerNVMe
	STORAGE_CONTROLLER_NVME = StorageControllerNVMe
	// DEPRECATED: Please use StorageControllerVirtIO
	STORAGE_CONTROLLER_VIRTIO = StorageControllerVirtIO
	// DEPRECATED: Please use StorageControllerMMC
	STORAGE_CONTROLLER_MMC = StorageControllerMMC
	// DEPRECATED: Please use StorageControllerLoop
	STORAGE_CONTROLLER_LOOP = StorageControllerLoop
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Disk

type Disk struct {
	// Name contains a short name for the disk, e.g. `sda`
	Name string `json:"name"`
	// SizeBytes contains the total amount of storage, in bytes, for this disk
	SizeBytes uint64 `json:"size_bytes"`
	// PhysicalBlockSizeBytes is the size, in bytes, of the physical blocks in
	// this disk. This is typically the minimum amount of data that can be
	// written to a disk in a single write operation.
	PhysicalBlockSizeBytes uint64 `json:"physical_block_size_bytes"`
	// DriveType is the category of disk drive for this disk.
	DriveType DriveType `json:"drive_type"`
	// IsRemovable indicates if the disk drive is removable.
	IsRemovable bool `json:"removable"`
	// StorageController is the category of storage controller used by the
	// disk.
	StorageController StorageController `json:"storage_controller"`
	// BusPath is the filepath to the bus for this disk.
	BusPath string `json:"bus_path"`
	// NUMANodeID contains the numeric index (0-based) of the NUMA Node this
	// disk is affined to, or -1 if the host system is non-NUMA.
	// TODO(jaypipes): Convert this to a TopologyNode struct pointer and then
	// add to serialized output as "numa_node,omitempty"
	NUMANodeID int `json:"-"`
	// Vendor is the manufacturer of the disk.
	Vendor string `json:"vendor"`
	// Model is the model number of the disk.
	Model string `json:"model"`
	// SerialNumber is the serial number of the disk.
	SerialNumber string `json:"serial_number"`
	// WWN is the World-wide Name of the disk.
	// See: https://en.wikipedia.org/wiki/World_Wide_Name
	WWN string `json:"wwn"`
	// WWNNoExtension is the World-wide Name of the disk with any vendor
	// extensions excluded.
	// See: https://en.wikipedia.org/wiki/World_Wide_Name
	WWNNoExtension string `json:"wwnNoExtension"`
	// Partitions contains an array of pointers to `Partition` structs, one for
	// each partition on the disk.
	Partitions []*Partition `json:"partitions"`
}

Disk describes a single disk drive on the host system. Disk drives provide raw block storage resources.

func (*Disk) String

func (d *Disk) String() string

String returns a short string indicating important information about the disk.

type DriveType

type DriveType int

DriveType describes the general category of drive device

const (
	// DriveTypeUnknown means we could not determine the drive type of the disk
	DriveTypeUnknown DriveType = iota
	// DriveTypeHDD indicates a hard disk drive
	DriveTypeHDD
	// DriveTypeFDD indicates a floppy disk drive
	DriveTypeFDD
	// DriveTypeODD indicates an optical disk drive
	DriveTypeODD
	// DriveTypeSSD indicates a solid-state drive
	DriveTypeSSD
	// DriveTypeVirtual indicates a virtual drive i.e. loop devices
	DriveTypeVirtual
)

func (DriveType) MarshalJSON

func (dt DriveType) MarshalJSON() ([]byte, error)

NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output

func (DriveType) String

func (dt DriveType) String() string

func (*DriveType) UnmarshalJSON added in v0.9.0

func (dt *DriveType) UnmarshalJSON(b []byte) error

type Info

type Info struct {

	// TotalSizeBytes contains the total amount of storage, in bytes, on the
	// host system.
	TotalSizeBytes uint64 `json:"total_size_bytes"`
	// DEPRECATED: Please use TotalSizeBytes
	TotalPhysicalBytes uint64 `json:"-"`
	// Disks contains an array of pointers to `Disk` structs, one for each disk
	// drive on the host system.
	Disks []*Disk `json:"disks"`
	// Partitions contains an array of pointers to `Partition` structs, one for
	// each partition on any disk drive on the host system.
	Partitions []*Partition `json:"-"`
	// contains filtered or unexported fields
}

Info describes all disk drives and partitions in the host system.

func New

func New(opts ...*option.Option) (*Info, error)

New returns a pointer to an Info struct that describes the block storage resources of the host system.

func (*Info) JSONString

func (i *Info) JSONString(indent bool) string

JSONString returns a string with the block information formatted as JSON under a top-level "block:" key

func (*Info) String

func (i *Info) String() string

String returns a short string indicating important information about the block storage on the host system.

func (*Info) YAMLString

func (i *Info) YAMLString() string

YAMLString returns a string with the block information formatted as YAML under a top-level "block:" key

type Partition

type Partition struct {
	// Disk is a pointer to the `Disk` struct that houses this partition.
	Disk *Disk `json:"-"`
	// Name is the system name given to the partition, e.g. "sda1".
	Name string `json:"name"`
	// Label is the human-readable label given to the partition. On Linux, this
	// is derived from the `ID_PART_ENTRY_NAME` udev entry.
	Label string `json:"label"`
	// MountPoint is the path where this partition is mounted.
	MountPoint string `json:"mount_point"`
	// SizeBytes contains the total amount of storage, in bytes, this partition
	// can consume.
	SizeBytes uint64 `json:"size_bytes"`
	// Type contains the type of the partition.
	Type string `json:"type"`
	// IsReadOnly indicates if the partition is marked read-only.
	IsReadOnly bool `json:"read_only"`
	// UUID is the universally-unique identifier (UUID) for the partition.
	// This will be volume UUID on Darwin, PartUUID on linux, empty on Windows.
	UUID string `json:"uuid"`
	// FilesystemLabel is the label of the filesystem contained on the
	// partition. On Linux, this is derived from the `ID_FS_NAME` udev entry.
	FilesystemLabel string `json:"filesystem_label"`
}

Partition describes a logical division of a Disk.

func (*Partition) String

func (p *Partition) String() string

String returns a short string indicating important information about the partition.

type StorageController

type StorageController int

StorageController is a category of block storage controller/driver. It represents more of the physical hardware interface than the storage protocol, which represents more of the software interface.

See discussion on https://github.com/jaypipes/ghw/issues/117

const (
	// StorageControllerUnknown indicates we could not determine the storage
	// controller for the disk
	StorageControllerUnknown StorageController = iota
	// StorageControllerIDE indicates a Integrated Drive Electronics (IDE)
	// controller
	StorageControllerIDE
	// StorageControllerSCSI indicates a  Small computer system interface
	// (SCSI) controller
	StorageControllerSCSI
	// StorageControllerNVMe indicates a Non-volatile Memory Express (NVMe)
	// controller
	StorageControllerNVMe
	// StorageControllerVirtIO indicates a virtualized storage
	// controller/driver
	StorageControllerVirtIO
	// StorageControllerMMC indicates a Multi-media controller (used for mobile
	// phone storage devices)
	StorageControllerMMC
	// StorageControllerLoop indicates a loopback storage controller
	StorageControllerLoop
)

func (StorageController) MarshalJSON

func (sc StorageController) MarshalJSON() ([]byte, error)

NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output

func (StorageController) String

func (sc StorageController) String() string

func (*StorageController) UnmarshalJSON added in v0.9.0

func (sc *StorageController) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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