cloud

package
v0.0.0-...-70673ff Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package cloud contains CloudStack related functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound       = errors.New("not found")
	ErrTooManyResults = errors.New("too many results")
	ErrAlreadyExists  = errors.New("already exists")
)

Specific errors.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIURL    string
	APIKey    string
	SecretKey string
	VerifySSL bool
	ProjectID string
}

Config holds CloudStack connection configuration.

func ReadConfig

func ReadConfig(configFilePath string) (*Config, error)

ReadConfig reads a config file with a format defined by CloudStack Cloud Controller Manager, and returns a CloudStackConfig.

type Interface

type Interface interface {
	GetNodeInfo(ctx context.Context, vmName string) (*VM, error)
	GetVMByID(ctx context.Context, vmID string) (*VM, error)

	ListZonesID(ctx context.Context) ([]string, error)

	GetVolumeByID(ctx context.Context, volumeID string) (*Volume, error)
	GetVolumeByName(ctx context.Context, name string) (*Volume, error)
	CreateVolume(ctx context.Context, diskOfferingID, zoneID, name string, sizeInGB int64) (string, error)
	DeleteVolume(ctx context.Context, id string) error
	AttachVolume(ctx context.Context, volumeID, vmID string) (string, error)
	DetachVolume(ctx context.Context, volumeID string) error
	ExpandVolume(ctx context.Context, volumeID string, newSizeInGB int64) error

	CreateVolumeFromSnapshot(ctx context.Context, zoneID, name, projectID, snapshotID string, sizeInGB int64) (*Volume, error)
	GetSnapshotByID(ctx context.Context, snapshotID string) (*Snapshot, error)
	GetSnapshotByName(ctx context.Context, name string) (*Snapshot, error)
	CreateSnapshot(ctx context.Context, volumeID, name string) (*Snapshot, error)
	DeleteSnapshot(ctx context.Context, snapshotID string) error
	ListSnapshots(ctx context.Context, volumeID, snapshotID string) ([]*Snapshot, error)
}

func New

func New(config *Config) Interface

New creates a new cloud connector, given its configuration.

type Snapshot

type Snapshot struct {
	ID   string
	Name string
	Size int64

	DomainID  string
	ProjectID string
	ZoneID    string

	VolumeID  string
	CreatedAt string
}

type VM

type VM struct {
	ID     string
	ZoneID string
}

VM represents a CloudStack Virtual Machine.

type Volume

type Volume struct {
	ID   string
	Name string

	// Size in Bytes
	Size int64

	DiskOfferingID string
	DomainID       string
	ProjectID      string
	ZoneID         string

	VirtualMachineID string
	DeviceID         string
}

Volume represents a CloudStack volume.

Directories

Path Synopsis
Package fake provides a fake implementation of the cloud connector interface, to be used in tests.
Package fake provides a fake implementation of the cloud connector interface, to be used in tests.

Jump to

Keyboard shortcuts

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