volume

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilesUnknownDeviceType filesDeviceType = ""
	FilesCdDeviceType      filesDeviceType = "cdrom"
	FilesFloppyDeviceType  filesDeviceType = "floppy"
)

Variables

This section is empty.

Functions

func ResetDeviceLetters added in v0.5.0

func ResetDeviceLetters()

Types

type BackingStoreVolumeSource

type BackingStoreVolumeSource struct {
	// Specifies the name of the storage pool (managed by libvirt) where the disk source resides
	Pool string `mapstructure:"pool" required:"false"`
	// Specifies the name of storage volume (managed by libvirt) used as the disk source.
	Volume string `mapstructure:"volume" required:"false"`
	// The file backing the volume. Mutually exclusive with pool and volume args!
	Path string `mapstructure:"path" required:"false"`
}

func (*BackingStoreVolumeSource) FlatMapstructure

func (*BackingStoreVolumeSource) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatBackingStoreVolumeSource. FlatBackingStoreVolumeSource is an auto-generated flat version of BackingStoreVolumeSource. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*BackingStoreVolumeSource) PrepareConfig

func (vs *BackingStoreVolumeSource) PrepareConfig(ctx *interpolate.Context, vol *Volume) (warnings []string, errs []error)

func (*BackingStoreVolumeSource) PrepareVolume

func (*BackingStoreVolumeSource) UpdateDomainDiskXml

func (vs *BackingStoreVolumeSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*BackingStoreVolumeSource) UpdateStorageDefinitionXml

func (vs *BackingStoreVolumeSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

type CloningVolumeSource added in v0.2.0

type CloningVolumeSource struct {
	// Specifies the name of the storage pool (managed by libvirt) where the disk source resides
	Pool string `mapstucture:"pool" required:"false"`
	// Specifies the name of storage volume (managed by libvirt) used as the disk source.
	Volume string `mapstructure:"volume" required:"false"`
}

func (*CloningVolumeSource) FlatMapstructure added in v0.2.0

func (*CloningVolumeSource) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatCloningVolumeSource. FlatCloningVolumeSource is an auto-generated flat version of CloningVolumeSource. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*CloningVolumeSource) PrepareConfig added in v0.2.0

func (vs *CloningVolumeSource) PrepareConfig(ctx *interpolate.Context, vol *Volume) (warnings []string, errs []error)

func (*CloningVolumeSource) PrepareVolume added in v0.2.0

func (*CloningVolumeSource) UpdateDomainDiskXml added in v0.2.0

func (vs *CloningVolumeSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*CloningVolumeSource) UpdateStorageDefinitionXml added in v0.2.0

func (vs *CloningVolumeSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

type CloudInitSource

type CloudInitSource struct {
	// [optional] NoCloud instance metadata as string.
	// If not present, a default one will be generated with the instance-id set to the same value as the domain name
	// If you want to set network config, see the `network_config` attribute
	MetaData *string `mapstructure:"meta_data"`
	// [optional] CloudInit user-data as string.
	// See [cloud-init documentation](https://cloudinit.readthedocs.io/en/latest/topics/format.html) for more
	UserData *string `mapstructure:"user_data"`
	// [optional] Network configuration for cloud-init to be picked up.
	// User-data cannot change an instance’s network configuration.
	// In the absence of network configuration in any sources,
	// Cloud-init will write out a network configuration that will issue a DHCP request on a “first” network interface.
	// Read more about the possible format and features at
	// [cloud-init documentation](https://cloudinit.readthedocs.io/en/latest/topics/network-config.html).
	NetworkConfig *string `mapstructure:"network_config"`
}

func (*CloudInitSource) FlatMapstructure

func (*CloudInitSource) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatCloudInitSource. FlatCloudInitSource is an auto-generated flat version of CloudInitSource. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*CloudInitSource) PrepareConfig

func (vs *CloudInitSource) PrepareConfig(ctx *interpolate.Context, vol *Volume, domainName string) (warnings []string, errs []error)

func (*CloudInitSource) PrepareVolume

func (vs *CloudInitSource) PrepareVolume(pctx *PreparationContext) multistep.StepAction

func (*CloudInitSource) UpdateDomainDiskXml

func (vs *CloudInitSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*CloudInitSource) UpdateStorageDefinitionXml

func (vs *CloudInitSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

type ExternalVolumeSource added in v0.3.0

type ExternalVolumeSource struct {
	// The checksum and the type of the checksum for the download
	Checksum string `mapstructure:"checksum"`
	// A list of URLs from where this volume can be obtained
	Urls []string `mapstructure:"urls"`
}

An external volume source defines a volume source that is external (or remote) to the libvirt hypervisor. This usually means a cloud image or installation media from the web or local machine. It's using go-getter under the hood with support for HTTP, HTTPS, S3, SMB and local files. The files will be cached by Packer.

func (*ExternalVolumeSource) FlatMapstructure added in v0.3.0

func (*ExternalVolumeSource) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatExternalVolumeSource. FlatExternalVolumeSource is an auto-generated flat version of ExternalVolumeSource. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*ExternalVolumeSource) PrepareConfig added in v0.3.0

func (vs *ExternalVolumeSource) PrepareConfig(ctx *interpolate.Context, vol *Volume) (warnings []string, errs []error)

func (*ExternalVolumeSource) PrepareVolume added in v0.3.0

func (*ExternalVolumeSource) UpdateDomainDiskXml added in v0.3.0

func (vs *ExternalVolumeSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*ExternalVolumeSource) UpdateStorageDefinitionXml added in v0.3.0

func (vs *ExternalVolumeSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

type FilesVolumeSource added in v0.5.0

type FilesVolumeSource struct {
	// Files can be either files or directories. An files provided here will
	// be written to the root of the CD or Floppy. Directories will be written to the
	// root of the CD as well, but will retain their subdirectory structure.
	// For a cdrom, the behaviour is the same as `cd_files`. For floppy disks, the behaviour
	// is the same as for `floppy_dirs`!
	Files []string `mapstructure:"files"`
	// Key/Value pairs to add to the CD or Floppy. The keys represent the paths, and the values
	// represent the contents. Can be used together with `files`. If any paths are specified by
	// both, `contents` will take precedence.
	Contents map[string]string `mapstructure:"contents"`
	Label    string            `mapstructure:"label"`
	// contains filtered or unexported fields
}

Create an image with files local to where packer runs and make it available at boot time. Depending on the parent volume's `device` attribute, the result will be a cdrom or a floppy image. Use this volume source scarcely, for example when the files needed as early as boot time. In general, making local files available on the remote machine is better done with the file provisioner. Floppies must not exceed the size 1.44MiB.

func (*FilesVolumeSource) PrepareConfig added in v0.5.0

func (vs *FilesVolumeSource) PrepareConfig(ctx *interpolate.Context, vol *Volume) (warnings []string, errs []error)

func (*FilesVolumeSource) PrepareVolume added in v0.5.0

func (vs *FilesVolumeSource) PrepareVolume(pctx *PreparationContext) multistep.StepAction

func (*FilesVolumeSource) UpdateDomainDiskXml added in v0.5.0

func (vs *FilesVolumeSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*FilesVolumeSource) UpdateStorageDefinitionXml added in v0.5.0

func (vs *FilesVolumeSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

type FlatBackingStoreVolumeSource

type FlatBackingStoreVolumeSource struct {
	Pool   *string `mapstructure:"pool" required:"false" cty:"pool" hcl:"pool"`
	Volume *string `mapstructure:"volume" required:"false" cty:"volume" hcl:"volume"`
	Path   *string `mapstructure:"path" required:"false" cty:"path" hcl:"path"`
}

FlatBackingStoreVolumeSource is an auto-generated flat version of BackingStoreVolumeSource. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatBackingStoreVolumeSource) HCL2Spec

HCL2Spec returns the hcl spec of a BackingStoreVolumeSource. This spec is used by HCL to read the fields of BackingStoreVolumeSource. The decoded values from this spec will then be applied to a FlatBackingStoreVolumeSource.

type FlatCloningVolumeSource added in v0.2.0

type FlatCloningVolumeSource struct {
	Pool   *string `mapstucture:"pool" required:"false" cty:"pool" hcl:"pool"`
	Volume *string `mapstructure:"volume" required:"false" cty:"volume" hcl:"volume"`
}

FlatCloningVolumeSource is an auto-generated flat version of CloningVolumeSource. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatCloningVolumeSource) HCL2Spec added in v0.2.0

func (*FlatCloningVolumeSource) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a CloningVolumeSource. This spec is used by HCL to read the fields of CloningVolumeSource. The decoded values from this spec will then be applied to a FlatCloningVolumeSource.

type FlatCloudInitSource

type FlatCloudInitSource struct {
	MetaData      *string `mapstructure:"meta_data" cty:"meta_data" hcl:"meta_data"`
	UserData      *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"`
	NetworkConfig *string `mapstructure:"network_config" cty:"network_config" hcl:"network_config"`
}

FlatCloudInitSource is an auto-generated flat version of CloudInitSource. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatCloudInitSource) HCL2Spec

func (*FlatCloudInitSource) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a CloudInitSource. This spec is used by HCL to read the fields of CloudInitSource. The decoded values from this spec will then be applied to a FlatCloudInitSource.

type FlatExternalVolumeSource added in v0.3.0

type FlatExternalVolumeSource struct {
	Checksum *string  `mapstructure:"checksum" cty:"checksum" hcl:"checksum"`
	Urls     []string `mapstructure:"urls" cty:"urls" hcl:"urls"`
}

FlatExternalVolumeSource is an auto-generated flat version of ExternalVolumeSource. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatExternalVolumeSource) HCL2Spec added in v0.3.0

func (*FlatExternalVolumeSource) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a ExternalVolumeSource. This spec is used by HCL to read the fields of ExternalVolumeSource. The decoded values from this spec will then be applied to a FlatExternalVolumeSource.

type FlatVolume

type FlatVolume struct {
	Pool      *string           `mapstructure:"pool" required:"false" cty:"pool" hcl:"pool"`
	Name      *string           `mapstructure:"name" required:"false" cty:"name" hcl:"name"`
	Source    *FlatVolumeSource `mapstructure:"source" required:"false" cty:"source" hcl:"source"`
	Size      *string           `mapstructure:"size" required:"false" cty:"size" hcl:"size"`
	Capacity  *string           `mapstructure:"capacity" required:"false" cty:"capacity" hcl:"capacity"`
	ReadOnly  *bool             `mapstructure:"readonly" required:"false" cty:"readonly" hcl:"readonly"`
	TargetDev *string           `mapstructure:"target_dev" required:"false" cty:"target_dev" hcl:"target_dev"`
	Bus       *string           `mapstructure:"bus" required:"false" cty:"bus" hcl:"bus"`
	Alias     *string           `mapstructure:"alias" required:"false" cty:"alias" hcl:"alias"`
	Format    *string           `mapstructure:"format" required:"false" cty:"format" hcl:"format"`
	Device    *string           `mapstructure:"device" required:"false" cty:"device" hcl:"device"`
}

FlatVolume is an auto-generated flat version of Volume. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatVolume) HCL2Spec

func (*FlatVolume) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Volume. This spec is used by HCL to read the fields of Volume. The decoded values from this spec will then be applied to a FlatVolume.

type FlatVolumeSource

type FlatVolumeSource struct {
	Type          *string           `mapstructure:"type" required:"true" cty:"type" hcl:"type"`
	Checksum      *string           `mapstructure:"checksum" cty:"checksum" hcl:"checksum"`
	Urls          []string          `mapstructure:"urls" cty:"urls" hcl:"urls"`
	MetaData      *string           `mapstructure:"meta_data" cty:"meta_data" hcl:"meta_data"`
	UserData      *string           `mapstructure:"user_data" cty:"user_data" hcl:"user_data"`
	NetworkConfig *string           `mapstructure:"network_config" cty:"network_config" hcl:"network_config"`
	Pool          *string           `mapstructure:"pool" required:"false" cty:"pool" hcl:"pool"`
	Volume        *string           `mapstructure:"volume" required:"false" cty:"volume" hcl:"volume"`
	Path          *string           `mapstructure:"path" required:"false" cty:"path" hcl:"path"`
	Files         []string          `mapstructure:"files" cty:"files" hcl:"files"`
	Contents      map[string]string `mapstructure:"contents" cty:"contents" hcl:"contents"`
	Label         *string           `mapstructure:"label" cty:"label" hcl:"label"`
}

FlatVolumeSource is an auto-generated flat version of VolumeSource. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatVolumeSource) HCL2Spec

func (*FlatVolumeSource) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a VolumeSource. This spec is used by HCL to read the fields of VolumeSource. The decoded values from this spec will then be applied to a FlatVolumeSource.

type PreparationContext

type PreparationContext struct {
	State            multistep.StateBag
	Ui               packersdk.Ui
	Driver           *libvirt.Libvirt
	VolumeConfig     *Volume
	VolumeRef        *libvirt.StorageVol
	VolumeDefinition *libvirtxml.StorageVolume
	PoolRef          *libvirt.StoragePool
	VolumeIsCreated  bool
	VolumeIsArtifact bool
	Context          context.Context
}

func (*PreparationContext) CloneVolumeFrom added in v0.2.0

func (pctx *PreparationContext) CloneVolumeFrom(sourcePool libvirt.StoragePool, sourceVol libvirt.StorageVol) error

func (*PreparationContext) CreateVolume

func (pctx *PreparationContext) CreateVolume() error

func (*PreparationContext) HaltOnError

func (pctx *PreparationContext) HaltOnError(err error, s string, a ...interface{}) multistep.StepAction

func (*PreparationContext) RefreshVolumeDefinition

func (pctx *PreparationContext) RefreshVolumeDefinition() error

type Volume

type Volume struct {
	// Specifies the name of the storage pool (managed by libvirt) where the disk resides. If not specified
	// the pool named `default` will be used
	Pool string `mapstructure:"pool" required:"false"`
	// Providing a name for the volume which is unique to the pool. (For a disk pool, the name must be
	// combination of the source device path device and next partition number to be
	// created. For example, if the source device path is /dev/sdb and there are no
	// partitions on the disk, then the name must be sdb1 with the next name being
	// sdb2 and so on.)
	// If not provided, a name will be generated in a format of `<domain_name>-<postfix>` where
	// postfix will be either the alias or a random id.
	// For cloudinit, the generated name will be `<domain_name>-cloudinit`
	Name string `mapstructure:"name" required:"false"`
	// Provides information about the underlying storage allocation of the volume.
	// This may not be available for some pool types.
	Source *VolumeSource `mapstructure:"source" required:"false"`
	// Providing the total storage allocation for the volume.
	// This may be smaller than the logical capacity if the volume is sparsely allocated.
	// It may also be larger than the logical capacity if the volume has substantial metadata overhead.
	// If omitted when creating a volume, the volume will be fully allocated at time of creation.
	// If set to a value smaller than the capacity, the pool has the option of deciding to sparsely allocate a volume.
	// It does not have to honour requests for sparse allocation though.
	// Different types of pools may treat sparse volumes differently.
	// For example, the logical pool will not automatically expand volume's allocation when it gets full;
	Size string `mapstructure:"size" required:"false"`
	// Providing the logical capacity for the volume. This value is in bytes by default,
	// but a unit attribute can be specified with the same semantics as for allocation
	// This is compulsory when creating a volume.
	Capacity string `mapstructure:"capacity" required:"false"`
	// If true, it indicates the device cannot be modified by the guest.
	ReadOnly bool `mapstructure:"readonly" required:"false"`
	// DEPRECATED!
	// The device order on the bus is determined automatically from the order of definition
	TargetDev string `mapstructure:"target_dev" required:"false"`
	// The optional bus attribute specifies the type of disk device to emulate;
	// possible values are driver specific, with typical values being
	// `ide`, `scsi`, `virtio`, `xen`, `usb`, `sata`, or `sd` `sd` since 1.1.2.
	// If omitted, the bus type is inferred from the style of the device name
	// (e.g. a device named 'sda' will typically be exported using a SCSI bus).
	Bus string `mapstructure:"bus" required:"false"`
	// To help users identifying devices they care about, every device can have an alias which must be unique within the domain.
	// Additionally, the identifier must consist only of the following characters: `[a-zA-Z0-9_-]`.
	Alias string `mapstructure:"alias" required:"false"`
	// Specifies the volume format type, like `qcow`, `qcow2`, `vmdk`, `raw`. If omitted, the storage pool's default format
	// will be used.
	Format string `mapstructure:"format" required:"false"`
	// Specifies the device type. If omitted, defaults to "disk". Can be `disk`, `floppy`, `cdrom` or `lun`.
	Device string `mapstructure:"device" required:"false"`
	// contains filtered or unexported fields
}

func (*Volume) DomainDiskXml

func (v *Volume) DomainDiskXml() *libvirtxml.DomainDisk

func (*Volume) FlatMapstructure

func (*Volume) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatVolume. FlatVolume is an auto-generated flat version of Volume. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*Volume) PrepareConfig

func (v *Volume) PrepareConfig(ctx *interpolate.Context, domainName string) (warnings []string, errs []error)

func (*Volume) PrepareVolume

func (v *Volume) PrepareVolume(pctx *PreparationContext) multistep.StepAction

func (*Volume) StorageDefinitionXml

func (v *Volume) StorageDefinitionXml() (*libvirtxml.StorageVolume, error)

type VolumeSource

type VolumeSource struct {
	Type          string                   `mapstructure:"type" required:"true"`
	External      ExternalVolumeSource     `mapstructure:",squash"`
	CloudInit     CloudInitSource          `mapstructure:",squash"`
	BackingStore  BackingStoreVolumeSource `mapstructure:",squash"`
	CloningVolume CloningVolumeSource      `mapstructure:",squash"`
	FilesSource   FilesVolumeSource        `mapstructure:",squash"`
}

func (*VolumeSource) FlatMapstructure

func (*VolumeSource) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatVolumeSource. FlatVolumeSource is an auto-generated flat version of VolumeSource. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*VolumeSource) PrepareConfig

func (vs *VolumeSource) PrepareConfig(ctx *interpolate.Context, vol *Volume, domainName string) (warnings []string, errs []error)

func (*VolumeSource) PrepareVolume

func (vs *VolumeSource) PrepareVolume(pctx *PreparationContext) multistep.StepAction

func (*VolumeSource) UpdateDomainDiskXml

func (vs *VolumeSource) UpdateDomainDiskXml(domainDisk *libvirtxml.DomainDisk)

func (*VolumeSource) UpdateStorageDefinitionXml

func (vs *VolumeSource) UpdateStorageDefinitionXml(storageDef *libvirtxml.StorageVolume)

Jump to

Keyboard shortcuts

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