capacity

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GPU

func GPU(p *PCI) bool

GPU Filter only devices with GPU capabilities NOTE: we only also now white list NVIDIA and AMD we skip integrated GPU normally on slots `0000:00:XX.X` and allow only discrete ones normally on slot `0000:XX:YY.ZZ`

func GetDevice

func GetDevice(vendor uint16, device uint16) (v Vendor, d Device, ok bool)

GetDevice looks up the devices db to given Vendor and Device IDs

func IsSecureBoot

func IsSecureBoot() (bool, error)

func PCIBridge

func PCIBridge(p *PCI) bool

PCIBridge returns true if p is a PCI bridge

Types

type Capacity

type Capacity struct {
	CRU uint64 `json:"cru"`
	MRU uint64 `json:"mru"`
	SRU uint64 `json:"sru"`
	HRU uint64 `json:"hru"`
}

Capacity hold the amount of resource unit of a node

type Device

type Device struct {
	// ID is device id according to PCI database
	ID uint16
	// Name is device name according to PCI database
	Name string
	// Subdevices is a slice of all subdevices according to PCI database
	Subdevices []Subdevice
}

Device is a PCI device

type Disks

type Disks struct {
	Tool        string          `json:"tool"`
	Environment string          `json:"environment"`
	Aggregator  string          `json:"aggregator"`
	Devices     []smartctl.Info `json:"devices"`
}

Disks contains the hardware information about the disk of a node

type Filter

type Filter func(pci *PCI) bool

Filter over the PCI for listing

func Not

func Not(f Filter) Filter

Not negates a filter

type PCI

type PCI struct {
	// Slot is the PCI device slot
	Slot string
	// Vendor of the device
	Vendor uint16
	// Device id
	Device uint16
	// Class of the device
	Class uint32
	// Subsystem Vendor of the device
	SubsystemVendor uint16
	// Subsystem ID of the device
	SubsystemDevice uint16
}

PCI device

func IoMMUGroup

func IoMMUGroup(pci PCI, filter ...Filter) ([]PCI, error)

IoMMUGroup given a pci device, return all devices in the same iommu group

func ListPCI

func ListPCI(filter ...Filter) ([]PCI, error)

ListPCI lists all PCI devices attached to the machine, applying provided filters

func (*PCI) Flag

func (p *PCI) Flag(name string) (uint64, error)

Flag read a custom flag on PCI device as uint64

func (*PCI) GetDevice

func (p *PCI) GetDevice() (Vendor, Device, bool)

GetDevice gets the attached PCI device information (vendor and device)

func (*PCI) GetSubdevice

func (p *PCI) GetSubdevice() (Subdevice, bool)

GetSubdevice gets the attached PCI subdevice information

func (*PCI) ShortID

func (p *PCI) ShortID() string

ShortID returns a short identification string for the device in the format `slot/vendor/device`

func (PCI) String

func (p PCI) String() string

type ResourceOracle

type ResourceOracle struct {
	// contains filtered or unexported fields
}

ResourceOracle is the structure responsible for capacity tracking

func NewResourceOracle

func NewResourceOracle(s *stubs.StorageModuleStub) *ResourceOracle

NewResourceOracle creates a new ResourceOracle

func (*ResourceOracle) DMI

func (r *ResourceOracle) DMI() (*dmi.DMI, error)

DMI run and parse dmidecode commands

func (*ResourceOracle) Disks

func (r *ResourceOracle) Disks() (d Disks, err error)

Disks list and parse the hardware information using smartctl

func (*ResourceOracle) GPUs

func (r *ResourceOracle) GPUs() ([]PCI, error)

GPUs returns the list of available GPUs as PCI devices

func (*ResourceOracle) GetHypervisor

func (r *ResourceOracle) GetHypervisor() (string, error)

GetHypervisor gets the name of the hypervisor used on the node

func (*ResourceOracle) Total

func (r *ResourceOracle) Total() (c gridtypes.Capacity, err error)

Total returns the total amount of resource units of the node

func (*ResourceOracle) Uptime

func (r *ResourceOracle) Uptime() (uint64, error)

Uptime returns the uptime of the node

type Subdevice

type Subdevice struct {
	// SubsystemVendorID is device subsystem vendor ID according to PCI database
	SubsystemVendorID uint16
	// SubsystemVendorID is device subsystem ID according to PCI database
	SubsystemDeviceID uint16
	// Name is subdevice name according to PCI database
	Name string
}

Subdevice is subdevice information to a PCI device

func GetSubdevice

func GetSubdevice(vendor uint16, device uint16, subsystemVendorID uint16, subsystemDeviceID uint16) (Subdevice, bool)

GetSubdevice looks up the subdevice using devices db

type Vendor

type Vendor struct {
	// ID of the vendor according to PCI database
	ID uint16
	// Name of the vendor
	Name string
	// All known devices by this vendor
	Devices map[uint16]Device
}

Vendor is Vendor information

func GetVendor

func GetVendor(vendor uint16) (Vendor, bool)

GetVendor gets a vendor object given Vendor ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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