Documentation
¶
Index ¶
- func DefaultCloudInit() (string, error)
- func EnsureVolume(instanceName string, vol project.Volume, progress io.Writer) (bool, error)
- func Exists(name string) bool
- func InstanceDir(name string) (string, error)
- func RemoveVolume(fullName string, force bool) error
- func RetainedVolumeSummary(instanceName string) string
- func RunPrebootHooks(p *project.Project, instanceName, cloudInitPath string, progress io.Writer) error
- func ValidateCloudInit(content string) (string, error)
- func VolumeCloudInit(blocks []project.Volume, networks []project.Volume, newVolumes map[string]bool) string
- func VolumeDisksForStart(instanceName string, blocks []project.Volume, networks []project.Volume) (diskArgs []string, fsArgs []string, err error)
- func VolumeLabel(volumeName string) string
- func VolumePath(instanceName, volumeName string) (string, error)
- func VolumesDir() (string, error)
- type Instance
- type VolumeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCloudInit ¶
DefaultCloudInit generates a minimal cloud-init config that creates a user matching the current user. SSH key injection is handled by the user-ssh preboot layer rather than being baked into cloud-init at init time.
func EnsureVolume ¶
EnsureVolume creates a volume's qcow2 file if it doesn't already exist. Returns true if the volume was newly created (needs formatting), false if it already existed.
func InstanceDir ¶
InstanceDir returns the directory for an instance.
func RemoveVolume ¶
RemoveVolume deletes a volume by its full name (instance-volumename). If force is false, it refuses to delete a volume attached to a running instance.
func RetainedVolumeSummary ¶
RetainedVolumeSummary returns a human-readable summary of volumes that were preserved during a destroy operation.
func RunPrebootHooks ¶
func RunPrebootHooks(p *project.Project, instanceName, cloudInitPath string, progress io.Writer) error
RunPrebootHooks executes preboot hooks for all layers that have them. The cloudInitPath is a writable file that hooks can edit in place. Returns the final cloud-init content after all hooks have run.
func ValidateCloudInit ¶ added in v0.2.4
ValidateCloudInit checks that cloud-init content is well-formed. It ensures the #cloud-config header is present (prepending it if missing) and that the body looks like valid YAML key-value pairs.
func VolumeCloudInit ¶
func VolumeCloudInit(blocks []project.Volume, networks []project.Volume, newVolumes map[string]bool) string
VolumeCloudInit generates cloud-init YAML stanzas for disk_setup, fs_setup, and mounts for the given block volumes. Only newly created volumes get disk_setup and fs_setup entries (to format them). All block volumes get mount entries. Network mounts also get mount entries.
func VolumeDisksForStart ¶
func VolumeDisksForStart(instanceName string, blocks []project.Volume, networks []project.Volume) (diskArgs []string, fsArgs []string, err error)
VolumeDisksForStart returns the virt-install --disk arguments for block volumes and --filesystem arguments for virtiofs/9p mounts.
func VolumeLabel ¶
VolumeLabel returns the filesystem label for a volume.
func VolumePath ¶
VolumePath returns the path for a volume's qcow2 file.
func VolumesDir ¶
VolumesDir returns the directory where volumes are stored.
Types ¶
type Instance ¶
type Instance struct {
Name string // Instance name (default: project directory name)
Dir string // Instance directory path
DiskPath string // Path to COW overlay disk
ISOPath string // Path to cloud-init ISO
Domain string // libvirt domain name (tank-<name>)
}
Instance represents a running or stopped VM instance.
func (*Instance) Destroy ¶
Destroy forcefully stops and undefines the VM, then removes instance files.
func (*Instance) IPAddress ¶
IPAddress returns the VM's IPv4 address via virsh domifaddr. Returns empty string if no address is found (e.g., VM still booting).
type VolumeInfo ¶
type VolumeInfo struct {
Name string // full name: instance-volumename
InstanceName string // instance name
VolumeName string // volume name (without instance prefix)
Path string // full path to qcow2
Size int64 // file size on disk
}
VolumeInfo holds information about an existing volume on disk.
func ListVolumes ¶
func ListVolumes(instanceFilter string) ([]VolumeInfo, error)
ListVolumes lists all volumes in the volumes directory. If instanceFilter is non-empty, only volumes for that instance are returned and volume names are parsed by stripping the instance prefix. If instanceFilter is empty, all volumes are returned. Instance names are resolved by matching against known instances first, then falling back to splitting on the last dash.