storage

package
v0.0.2-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PoolTypeDirectory = "directory"
	PoolTypeCeph      = "ceph"

	BusTypeVirtio = "virtio"
	BusTypeIde    = "ide"
	BusTypeScsi   = "scsi"
	BusTypeSata   = "sata"

	DiskFormatIso   = "iso"
	DiskFormatQcow2 = "qcow2"
	DiskFormatRaw   = "raw"

	DiskKindDisk  = "disk"
	DiskKindLun   = "lun"
	DiskKindCdrom = "cdrom"
)

Variables

This section is empty.

Functions

func ConfigSpec

func ConfigSpec() *hclspec.Spec

ConfigSpec returns the hcl spec for the storage pools configuration

Types

type Authentication

type Authentication struct {
	Username string `codec:"username"`
	Secret   string `codec:"secret"`
}

Authentication provides credentials

type Ceph

type Ceph struct {
	Pool           string         `codec:"pool"`           // Name of the ceph storage pool
	Hosts          []string       `codec:"hosts"`          // List of ceph hosts
	Authentication Authentication `codec:"authentication"` // Autentication for ceph connection
}

Ceph provides configuration for ceph rbd storage pools

func (Ceph) Validate

func (c Ceph) Validate() error

Validate validates the ceph pool configuration.

type Config

type Config struct {
	// Default is the name of the storage pool that is the default
	Default string `codec:"default"`
	// Directory provides directory storage pool configuration
	Directory map[string]Directory `codec:"directory"`
	// Ceph provides ceph storage pool configuration
	Ceph map[string]Ceph `codec:"ceph"`
}

Config provides configuration for storage pools

func NewConfig

func NewConfig() *Config

NewConfig returns a new initialized config.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the storage configuration.

type Directory

type Directory struct {
	Path string `codec:"path"` // Local path of the storage pool
}

Directory provides configuration for local directory storage pools

func (Directory) Validate

func (d Directory) Validate() error

Validate validates the directory pool configuration.

type Options

type Options struct {
	Chained bool   // Volume is chained to a parent volume
	Sparse  bool   // Volume should be sparse (full capacity not allocated)
	Size    uint64 // Size of the volume in bytes
	Source  Source // Describes the source of the volume
	Target  Target // Options for the target to be created
}

Options are supported options for AddVolume

type Pool

type Pool interface {
	// AddVolume adds a new volume to the storage pool.
	AddVolume(name string, opts Options) (*Volume, error)
	// GetVolume retrieves a volume from the storage pool if it exists.
	GetVolume(name string) (*Volume, error)
	// DeleteVolume deletes a volume from the storage pool.
	DeleteVolume(name string) error
	// ListVolumes returns the name of the volumes in the pool.
	ListVolumes() ([]string, error)
	// Name returns the name of the storage pool.
	Name() string
	// Type returns the type of the storage pool.
	Type() string
	// DefaultImageFormat returns the default image format for the pool.
	DefaultImageFormat() string
}

Pool defines the required interface for supporting storage pools.

type Source

type Source struct {
	Path   string // Path to a source image file
	Volume string // Volume to clone
}

Source describes the source of the volume to create

type Storage

type Storage interface {
	// DefaultPool returns the default storage pool
	DefaultPool() (Pool, error)
	// GetPool returns the requested storage pool by name
	GetPool(name string) (Pool, error)
	// ListPools returns a list of available storage pool names
	ListPools() []string
	// ImageHandler returns an image handler
	ImageHandler() image_tools.ImageHandler
	// DefaultDiskDriver provides the name of the default disk driver
	DefaultDiskDriver() string
	// GenerateDeviceName generates a new device name for a disk
	GenerateDeviceName(busType string, existingDevices []string) string
	// Fingerprint adds fingerprint information for available storage pools
	Fingerprint(attrs map[string]*structs.Attribute)
}

Storage defines the required interface for support storage

type Target

type Target struct {
	Format string // Format of the created volume ("raw", "qcow2", etc.)
}

Target includes options for volume creation

type Volume

type Volume struct {
	Pool       string // Name of the pool containing volume
	Name       string // Name of the volume
	Kind       string // Kind of attachment (disk, cdrom, etc)
	Driver     string // Driver for attachment
	Format     string // Format of the image
	DeviceName string // Device name of the attachment
	BusType    string // Bus type used by the attachment (ide, sata, scsi, etc)
	Primary    bool   // Primary disk for booting
	Block      string // Block device to pass through as attachment
	Size       uint64 // Size of the volume
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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