drivers

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNone      = "NONE"
	StatusAllocated = "ALLOCATED"
)

Variables

View Source
var DriversList []ResourceDriver

Functions

This section is empty.

Types

type Disk

type Disk struct {
	Type  string `json:"type"`  // Type of the filesystem to create
	Label string `json:"label"` // Volume name will be given to the disk, empty will use the disk key
	Size  uint   `json:"size"`  // Amount of disk space in GB
	Reuse bool   `json:"reuse"` // Do not remove the disk and reuse it for the next resource run
	Clone string `json:"clone"` // Clone the snapshot of existing disk instead of creating the new one
}

type Requirements

type Requirements struct {
	Cpu     uint            `json:"cpu"`     // Number of CPU cores to use
	Ram     uint            `json:"ram"`     // Amount of memory in GB
	Disks   map[string]Disk `json:"disks"`   // Disks to create and connect
	Network string          `json:"network"` // Which network configuration to use for VM
}

Resource requirements

func (*Requirements) Validate

func (r *Requirements) Validate(disk_types []string, check_net bool) error

type ResourceDriver

type ResourceDriver interface {
	// Name of the driver
	Name() string

	// Give driver configs and check if it's ok
	// -> config - driver configuration in json format
	Prepare(config []byte) error

	// Make sure the allocate definition is appropriate
	// -> definition - describes the driver options to allocate the required resource
	ValidateDefinition(definition string) error

	// Allocate the resource by definition and returns hw address
	// -> definition - describes the driver options to allocate the required resource
	// -> metadata - user metadata to use during resource allocation
	// <- hwaddr - mandatory, needed to identify the resource. If it's a MAC address - it is used to auth in Meta API
	// <- ipaddr - optional, if driver can provide the assigned IP address of the instance
	Allocate(definition string, metadata map[string]interface{}) (hwaddr, ipaddr string, err error)

	// Get the status of the resource with given hw address
	Status(hwaddr string) string

	// Makes environment snapshot of the resource with given hw address
	// -> hwaddr - driver identifier of the resource
	// -> full - will try it's best to make the complete snapshot of the environment, else just non-image data (attached disks)
	// <- info - where to find the snapshots
	Snapshot(hwaddr string, full bool) (info string, err error)

	// Deallocate resource with provided hw addr
	// -> hwaddr - driver identifier of the resource
	Deallocate(hwaddr string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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