state

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveMachineBlockDevices

func RemoveMachineBlockDevices(ctx context.Context, tx *sqlair.TX, machineUUID string) error

RemoveMachineBlockDevices deletes all the block devices belonging to the specified machine. Exported so that it can be called from [domain.machine.state.DeleteMachine].

Types

type BlockDevice

type BlockDevice struct {
	ID          string `db:"uuid"`
	MachineUUID string `db:"machine_uuid"`

	DeviceName     string `db:"name"`
	Label          string `db:"label,omitempty"`
	DeviceUUID     string `db:"device_uuid"`
	HardwareId     string `db:"hardware_id"`
	WWN            string `db:"wwn"`
	BusAddress     string `db:"bus_address"`
	SizeMiB        uint64 `db:"size_mib"`
	FilesystemType int    `db:"filesystem_type_id"`
	InUse          bool   `db:"in_use"`
	MountPoint     string `db:"mount_point"`
	SerialId       string `db:"serial_id"`
}

type BlockDeviceMachine

type BlockDeviceMachine struct {
	MachineId string `db:"name"`
}

type BlockDevices

type BlockDevices []BlockDevice
type DeviceLink struct {
	ParentUUID string `db:"block_device_uuid"`
	Name       string `db:"name"`
}

type FilesystemType

type FilesystemType struct {
	ID   int    `db:"id"`
	Name string `db:"name"`
}

type State

type State struct {
	*domain.StateBase
}

State represents database interactions dealing with block devices.

func NewState

func NewState(factory coredatabase.TxnRunnerFactory) *State

NewState returns a new block device state based on the input database factory method.

func (*State) BlockDevices

func (st *State) BlockDevices(ctx context.Context, machineId string) ([]blockdevice.BlockDevice, error)

BlockDevices returns the BlockDevices for the specified machine. Returns an error satisfying machinerrors.NotFound if the machine does not exist.

func (*State) MachineBlockDevices

func (st *State) MachineBlockDevices(ctx context.Context) ([]blockdevice.MachineBlockDevice, error)

MachineBlockDevices retrieves block devices for all machines.

func (*State) SetMachineBlockDevices

func (st *State) SetMachineBlockDevices(ctx context.Context, machineId string, devices ...blockdevice.BlockDevice) error

SetMachineBlockDevices sets the block devices visible on the machine. Previously recorded block devices not in the list will be removed. Returns an error satisfying machinerrors.NotFound if the machine does not exist.

func (*State) WatchBlockDevices

func (st *State) WatchBlockDevices(
	ctx context.Context,
	getWatcher func(
		namespace, changeValue string,
		changeMask changestream.ChangeType,
		mapper eventsource.Mapper,
	) (watcher.NotifyWatcher, error),
	machineId string,
) (watcher.NotifyWatcher, error)

WatchBlockDevices returns a new NotifyWatcher watching for changes to block devices associated with the specified machine.

Jump to

Keyboard shortcuts

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