common

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GuestAdditionsModeDisable string = "disable"
	GuestAdditionsModeAttach         = "attach"
	GuestAdditionsModeUpload         = "upload"
)

These are the different valid mode values for "guest_additions_mode" which determine how guest additions are delivered to the guest.

View Source
const BuilderId = "mitchellh.virtualbox"

This is the common builder ID to all of these artifacts.

View Source
const KeyLeftShift uint32 = 0xFFE1

Variables

This section is empty.

Functions

func CommHost added in v0.8.0

func CommHost(host string) func(multistep.StateBag) (string, error)

func CommPort added in v1.5.2

func CommPort(state multistep.StateBag) (int, error)

func NewArtifact

func NewArtifact(dir string, generatedData map[string]interface{}) (packersdk.Artifact, error)

NewArtifact returns a VirtualBox artifact containing the files in the given directory.

Types

type CommConfig added in v1.5.2

type CommConfig struct {
	Comm communicator.Config `mapstructure:",squash"`
	// The minimum port to use for the Communicator port on the host machine which is forwarded
	// to the SSH or WinRM port on the guest machine. By default this is 2222.
	HostPortMin int `mapstructure:"host_port_min" required:"false"`
	// The maximum port to use for the Communicator port on the host machine which is forwarded
	// to the SSH or WinRM port on the guest machine. Because Packer often runs in parallel,
	// Packer will choose a randomly available port in this range to use as the
	// host port. By default this is 4444.
	HostPortMax int `mapstructure:"host_port_max" required:"false"`
	// Defaults to false. When enabled, Packer
	// does not setup forwarded port mapping for communicator (SSH or WinRM) requests and uses ssh_port or winrm_port
	// on the host to communicate to the virtual machine.
	SkipNatMapping bool `mapstructure:"skip_nat_mapping" required:"false"`

	// These are deprecated, but we keep them around for backwards compatibility
	// TODO: remove later
	SSHHostPortMin int `mapstructure:"ssh_host_port_min" required:"false"`
	// TODO: remove later
	SSHHostPortMax int `mapstructure:"ssh_host_port_max"`
	// TODO: remove later
	SSHSkipNatMapping bool `mapstructure:"ssh_skip_nat_mapping" required:"false"`
}

func (*CommConfig) Prepare added in v1.5.2

func (c *CommConfig) Prepare(ctx *interpolate.Context) []error

type Driver

type Driver interface {
	// Create a SATA controller.
	CreateSATAController(vm string, controller string, portcount int) error

	// Create a SCSI controller.
	CreateSCSIController(vm string, controller string) error

	// Create a VirtIO controller.
	CreateVirtIOController(vm string, controller string) error

	// Create an NVME controller
	CreateNVMeController(vm string, controller string, portcount int) error

	// Delete all floppy controllers
	RemoveFloppyControllers(vm string) error

	// Delete a VM by name
	Delete(string) error

	// Import a VM
	Import(string, string, []string) error

	// The complete path to the Guest Additions ISO
	Iso() (string, error)

	// Checks if the VM with the given name is running.
	IsRunning(string) (bool, error)

	// Stop stops a running machine, forcefully.
	Stop(string) error

	// ACPIStop stops a running machine via ACPI power button.
	StopViaACPI(string) error

	// SuppressMessages should do what needs to be done in order to
	// suppress any annoying popups from VirtualBox.
	SuppressMessages() error

	// VBoxManage executes the given VBoxManage command
	// and returns the stdout channel as string
	VBoxManage(...string) error

	// Verify checks to make sure that this driver should function
	// properly. If there is any indication the driver can't function,
	// this will return an error.
	Verify() error

	// Version reads the version of VirtualBox that is installed.
	Version() (string, error)

	// LoadSnapshots Loads all defined snapshots for a vm.
	// if no snapshots are defined nil will be returned
	LoadSnapshots(string) (*VBoxSnapshot, error)

	// CreateSnapshot Creates a snapshot for a vm with a given name
	CreateSnapshot(string, string) error

	// HasSnapshots tests if a vm has snapshots
	HasSnapshots(string) (bool, error)

	// GetCurrentSnapshot Returns the current snapshot for a vm
	GetCurrentSnapshot(string) (*VBoxSnapshot, error)

	// SetSnapshot sets the for a vm
	SetSnapshot(string, *VBoxSnapshot) error

	// DeleteSnapshot deletes the specified snapshot from a vm
	DeleteSnapshot(string, *VBoxSnapshot) error
}

A driver is able to talk to VirtualBox and perform certain operations with it. Some of the operations on here may seem overly specific, but they were built specifically in mind to handle features of the VirtualBox builder for Packer, and to abstract differences in versions out of the builder steps, so sometimes the methods are extremely specific.

func NewDriver

func NewDriver() (Driver, error)

type DriverMock

type DriverMock struct {
	sync.Mutex

	CreateSATAControllerVM         string
	CreateSATAControllerController string
	CreateSATAControllerErr        error

	CreateSCSIControllerVM         string
	CreateSCSIControllerController string
	CreateSCSIControllerErr        error

	CreateVirtIOControllerVM         string
	CreateVirtIOControllerController string
	CreateVirtIOControllerErr        error

	CreateNVMeControllerVM         string
	CreateNVMeControllerController string
	CreateNVMeControllerErr        error

	RemoveFloppyControllersVM  string
	RemoveFloppyControllersErr error

	DeleteCalled bool
	DeleteName   string
	DeleteErr    error

	ImportCalled bool
	ImportName   string
	ImportPath   string
	ImportFlags  []string
	ImportErr    error

	IsoCalled bool
	IsoErr    error

	IsRunningName   string
	IsRunningReturn bool
	IsRunningErr    error

	StopViaACPIName string
	StopName        string
	StopErr         error

	SuppressMessagesCalled bool
	SuppressMessagesErr    error

	VBoxManageCalls [][]string
	VBoxManageErrs  []error

	VerifyCalled bool
	VerifyErr    error

	VersionCalled bool
	VersionResult string
	VersionErr    error

	LoadSnapshotsCalled      []string
	LoadSnapshotsResult      *VBoxSnapshot
	CreateSnapshotCalled     []string
	CreateSnapshotError      error
	HasSnapshotsCalled       []string
	HasSnapshotsResult       bool
	GetCurrentSnapshotCalled []string
	GetCurrentSnapshotResult *VBoxSnapshot
	SetSnapshotCalled        []*VBoxSnapshot
	DeleteSnapshotCalled     []*VBoxSnapshot
}

func (*DriverMock) CreateNVMeController added in v1.4.5

func (d *DriverMock) CreateNVMeController(vm string, controller string, portcount int) error

func (*DriverMock) CreateSATAController

func (d *DriverMock) CreateSATAController(vm string, controller string, portcount int) error

func (*DriverMock) CreateSCSIController added in v0.8.0

func (d *DriverMock) CreateSCSIController(vm string, controller string) error

func (*DriverMock) CreateSnapshot added in v1.4.3

func (d *DriverMock) CreateSnapshot(vmName string, snapshotName string) error

func (*DriverMock) CreateVirtIOController added in v1.7.1

func (d *DriverMock) CreateVirtIOController(vm string, controller string) error

func (*DriverMock) Delete

func (d *DriverMock) Delete(name string) error

func (*DriverMock) DeleteSnapshot added in v1.4.3

func (d *DriverMock) DeleteSnapshot(vmName string, snapshot *VBoxSnapshot) error

func (*DriverMock) GetCurrentSnapshot added in v1.4.3

func (d *DriverMock) GetCurrentSnapshot(vmName string) (*VBoxSnapshot, error)

func (*DriverMock) HasSnapshots added in v1.4.3

func (d *DriverMock) HasSnapshots(vmName string) (bool, error)

func (*DriverMock) Import

func (d *DriverMock) Import(name string, path string, flags []string) error

func (*DriverMock) IsRunning

func (d *DriverMock) IsRunning(name string) (bool, error)

func (*DriverMock) Iso added in v0.6.1

func (d *DriverMock) Iso() (string, error)

func (*DriverMock) LoadSnapshots added in v1.4.3

func (d *DriverMock) LoadSnapshots(vmName string) (*VBoxSnapshot, error)

func (*DriverMock) RemoveFloppyControllers added in v1.5.5

func (d *DriverMock) RemoveFloppyControllers(vm string) error

func (*DriverMock) SetSnapshot added in v1.4.3

func (d *DriverMock) SetSnapshot(vmName string, snapshot *VBoxSnapshot) error

func (*DriverMock) Stop

func (d *DriverMock) Stop(name string) error

func (*DriverMock) StopViaACPI added in v1.5.2

func (d *DriverMock) StopViaACPI(name string) error

func (*DriverMock) SuppressMessages

func (d *DriverMock) SuppressMessages() error

func (*DriverMock) VBoxManage

func (d *DriverMock) VBoxManage(args ...string) error

func (*DriverMock) Verify

func (d *DriverMock) Verify() error

func (*DriverMock) Version

func (d *DriverMock) Version() (string, error)

type ExportConfig

type ExportConfig struct {
	// Either ovf or ova, this specifies the output format
	// of the exported virtual machine. This defaults to ovf.
	Format string `mapstructure:"format" required:"false"`
	// Additional options to pass to the [VBoxManage
	// export](https://www.virtualbox.org/manual/ch09.html#vboxmanage-export).
	// This can be useful for passing product information to include in the
	// resulting appliance file. Packer JSON configuration file example:
	//
	// In JSON:
	// “`json
	// {
	//   "type": "virtualbox-iso",
	//   "export_opts":
	//   [
	//     "--manifest",
	//     "--vsys", "0",
	//     "--description", "{{user `vm_description`}}",
	//     "--version", "{{user `vm_version`}}"
	//   ],
	//   "format": "ova",
	// }
	// “`
	//
	// In HCL2:
	// “`hcl
	//	source "virtualbox-iso" "basic-example" {
	//		export_opts = [
	//	          "--manifest",
	//	          "--vsys", "0",
	//	          "--description", "{{user `vm_description`}}",
	//	          "--version", "{{user `vm_version`}}"
	//	   	]
	//		format = "ova"
	//  }
	// “`
	//
	// A VirtualBox [VM
	// description](https://www.virtualbox.org/manual/ch09.html#vboxmanage-export-ovf)
	// may contain arbitrary strings; the GUI interprets HTML formatting. However,
	// the JSON format does not allow arbitrary newlines within a value. Add a
	// multi-line description by preparing the string in the shell before the
	// packer call like this (shell `>` continuation character snipped for easier
	// copy & paste):
	//
	// “`shell
	// vm_description='some
	// multiline
	// description'
	//
	// vm_version='0.2.0'
	//
	// packer build \
	//     -var "vm_description=${vm_description}" \
	//     -var "vm_version=${vm_version}"         \
	//     "packer_conf.json"
	// “`
	ExportOpts []string `mapstructure:"export_opts" required:"false"`
}

func (*ExportConfig) Prepare

func (c *ExportConfig) Prepare(ctx *interpolate.Context) []error

type GuestAdditionsConfig added in v1.4.0

type GuestAdditionsConfig struct {
	// The method by which guest additions are
	// made available to the guest for installation. Valid options are `upload`,
	// `attach`, or `disable`. If the mode is `attach` the guest additions ISO will
	// be attached as a CD device to the virtual machine. If the mode is `upload`
	// the guest additions ISO will be uploaded to the path specified by
	// `guest_additions_path`. The default value is `upload`. If `disable` is used,
	// guest additions won't be downloaded, either.
	GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
	// The interface type to use to mount guest additions when
	// guest_additions_mode is set to attach. Will default to the value set in
	// iso_interface, if iso_interface is set. Will default to "ide", if
	// iso_interface is not set. Options are "ide" and "sata".
	GuestAdditionsInterface string `mapstructure:"guest_additions_interface" required:"false"`
	// The path on the guest virtual machine
	//  where the VirtualBox guest additions ISO will be uploaded. By default this
	//  is `VBoxGuestAdditions.iso` which should upload into the login directory of
	//  the user. This is a [configuration
	//  template](/docs/templates/legacy_json_templates/engine) where the `Version`
	//  variable is replaced with the VirtualBox version.
	GuestAdditionsPath string `mapstructure:"guest_additions_path"`
	// The SHA256 checksum of the guest
	//  additions ISO that will be uploaded to the guest VM. By default the
	//  checksums will be downloaded from the VirtualBox website, so this only needs
	//  to be set if you want to be explicit about the checksum.
	GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
	// The URL of the guest additions ISO
	//  to upload. This can also be a file URL if the ISO is at a local path. By
	//  default, the VirtualBox builder will attempt to find the guest additions ISO
	//  on the local file system. If it is not available locally, the builder will
	//  download the proper guest additions ISO from the internet.
	GuestAdditionsURL string `mapstructure:"guest_additions_url" required:"false"`
}

func (*GuestAdditionsConfig) Prepare added in v1.4.0

func (c *GuestAdditionsConfig) Prepare(communicatorType string) []error

type HWConfig added in v1.3.3

type HWConfig struct {
	// The number of cpus to use for building the VM.
	// Defaults to 1.
	CpuCount int `mapstructure:"cpus" required:"false"`
	// The amount of memory to use for building the VM
	// in megabytes. Defaults to 512 megabytes.
	MemorySize int `mapstructure:"memory" required:"false"`
	// Defaults to none. The type of audio device to use for
	// sound when building the VM. Some of the options that are available are
	// dsound, oss, alsa, pulse, coreaudio, null.
	Sound string `mapstructure:"sound" required:"false"`
	// Specifies whether or not to enable the USB bus when
	// building the VM. Defaults to false.
	USB bool `mapstructure:"usb" required:"false"`
}

func (*HWConfig) Prepare added in v1.3.3

func (c *HWConfig) Prepare(ctx *interpolate.Context) []error

type OutputConfig

type OutputConfig struct {
	// This is the path to the directory where the
	// resulting virtual machine will be created. This may be relative or absolute.
	// If relative, the path is relative to the working directory when packer
	// is executed. This directory must not exist or be empty prior to running
	// the builder. By default this is output-BUILDNAME where "BUILDNAME" is the
	// name of the build.
	OutputDir string `mapstructure:"output_directory" required:"false"`
	// This is the base name of the file (excluding the file extension) where
	// the resulting virtual machine will be created. By default this is the
	// `vm_name`.
	OutputFilename string `mapstructure:"output_filename" required:"false"`
}

func (*OutputConfig) Prepare

func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error

type RunConfig

type RunConfig struct {
	// Packer defaults to building VirtualBox virtual
	// machines by launching a GUI that shows the console of the machine
	// being built. When this value is set to true, the machine will start
	// without a console.
	Headless bool `mapstructure:"headless" required:"false"`
	// The IP address that should be
	// binded to for VRDP. By default packer will use 127.0.0.1 for this. If you
	// wish to bind to all interfaces use 0.0.0.0.
	VRDPBindAddress string `mapstructure:"vrdp_bind_address" required:"false"`
	// The minimum and maximum port
	// to use for VRDP access to the virtual machine. Packer uses a randomly chosen
	// port in this range that appears available. By default this is 5900 to
	// 6000. The minimum and maximum ports are inclusive.
	VRDPPortMin int `mapstructure:"vrdp_port_min" required:"false"`
	VRDPPortMax int `mapstructure:"vrdp_port_max"`
}

func (*RunConfig) Prepare

func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error)

type ShutdownConfig

type ShutdownConfig struct {
	// The command to use to gracefully shut down the
	// machine once all the provisioning is done. By default this is an empty
	// string, which tells Packer to just forcefully shut down the machine unless a
	// shutdown command takes place inside script so this may safely be omitted. If
	// one or more scripts require a reboot it is suggested to leave this blank
	// since reboots may fail and specify the final shutdown command in your
	// last script.
	ShutdownCommand string `mapstructure:"shutdown_command" required:"false"`
	// The amount of time to wait after executing the
	// shutdown_command for the virtual machine to actually shut down. If it
	// doesn't shut down in this time, it is an error. By default, the timeout is
	// 5m or five minutes.
	ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" required:"false"`
	// The amount of time to wait after shutting
	// down the virtual machine. If you get the error
	// Error removing floppy controller, you might need to set this to 5m
	// or so. By default, the delay is 0s or disabled.
	PostShutdownDelay time.Duration `mapstructure:"post_shutdown_delay" required:"false"`
	// Packer normally halts the virtual machine after all provisioners have
	// run when no `shutdown_command` is defined.  If this is set to `true`, Packer
	// *will not* halt the virtual machine but will assume that you will send the stop
	// signal yourself through the preseed.cfg or your final provisioner.
	// Packer will wait for a default of 5 minutes until the virtual machine is shutdown.
	// The timeout can be changed using `shutdown_timeout` option.
	DisableShutdown bool `mapstructure:"disable_shutdown" required:"false"`
	// If it's set to true, it will shutdown the VM via power button. It could be a good option
	// when keeping the machine state is necessary after shutting it down.
	ACPIShutdown bool `mapstructure:"acpi_shutdown" required:"false"`
}

func (*ShutdownConfig) Prepare

func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error

type StepAttachFloppy

type StepAttachFloppy struct {
	// contains filtered or unexported fields
}

This step attaches the ISO to the virtual machine.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces:

func (*StepAttachFloppy) Cleanup

func (s *StepAttachFloppy) Cleanup(state multistep.StateBag)

func (*StepAttachFloppy) Run

type StepAttachISOs added in v1.6.3

type StepAttachISOs struct {
	AttachBootISO           bool
	ISOInterface            string
	GuestAdditionsMode      string
	GuestAdditionsInterface string
	// contains filtered or unexported fields
}

This step attaches the boot ISO, cd_files iso, and guest additions to the virtual machine, if present.

func (*StepAttachISOs) Cleanup added in v1.6.3

func (s *StepAttachISOs) Cleanup(state multistep.StateBag)

func (*StepAttachISOs) Run added in v1.6.3

type StepConfigureVRDP added in v0.9.0

type StepConfigureVRDP struct {
	VRDPBindAddress string
	VRDPPortMin     int
	VRDPPortMax     int
	// contains filtered or unexported fields
}

This step configures the VM to enable the VRDP server on the guest machine.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces: vrdp_port unit - The port that VRDP is configured to listen on.

func (*StepConfigureVRDP) Cleanup added in v0.9.0

func (s *StepConfigureVRDP) Cleanup(state multistep.StateBag)

func (*StepConfigureVRDP) Run added in v0.9.0

type StepDownloadGuestAdditions added in v0.6.1

type StepDownloadGuestAdditions struct {
	GuestAdditionsMode   string
	GuestAdditionsURL    string
	GuestAdditionsSHA256 string
	Ctx                  interpolate.Context
}

This step uploads a file containing the VirtualBox version, which can be useful for various provisioning reasons.

Produces:

guest_additions_path string - Path to the guest additions.

func (*StepDownloadGuestAdditions) Cleanup added in v0.6.1

func (s *StepDownloadGuestAdditions) Cleanup(state multistep.StateBag)

func (*StepDownloadGuestAdditions) Run added in v0.6.1

type StepExport

type StepExport struct {
	Format         string
	OutputDir      string
	OutputFilename string
	ExportOpts     []string
	Bundling       VBoxBundleConfig
	SkipNatMapping bool
	SkipExport     bool
}

This step cleans up forwarded ports and exports the VM to an OVF.

Uses:

Produces:

exportPath string - The path to the resulting export.

func (*StepExport) Cleanup

func (s *StepExport) Cleanup(state multistep.StateBag)

func (*StepExport) Run

type StepHTTPIPDiscover added in v1.5.2

type StepHTTPIPDiscover struct{}

Step to discover the http ip which guests use to reach the vm host To make sure the IP is set before boot command and http server steps

func (*StepHTTPIPDiscover) Cleanup added in v1.5.2

func (s *StepHTTPIPDiscover) Cleanup(state multistep.StateBag)

func (*StepHTTPIPDiscover) Run added in v1.5.2

type StepPortForwarding added in v1.5.2

type StepPortForwarding struct {
	CommConfig     *communicator.Config
	HostPortMin    int
	HostPortMax    int
	SkipNatMapping bool
	// contains filtered or unexported fields
}

This step adds a NAT port forwarding definition so that SSH or WinRM is available on the guest machine.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces:

func (*StepPortForwarding) Cleanup added in v1.5.2

func (s *StepPortForwarding) Cleanup(state multistep.StateBag)

func (*StepPortForwarding) Run added in v1.5.2

type StepRemoveDevices

type StepRemoveDevices struct {
	Bundling VBoxBundleConfig
}

This step removes any devices (floppy disks, ISOs, etc.) from the machine that we may have added.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces:

func (*StepRemoveDevices) Cleanup

func (s *StepRemoveDevices) Cleanup(state multistep.StateBag)

func (*StepRemoveDevices) Run

type StepRun

type StepRun struct {
	Headless bool
	// contains filtered or unexported fields
}

This step starts the virtual machine.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces:

func (*StepRun) Cleanup

func (s *StepRun) Cleanup(state multistep.StateBag)

func (*StepRun) Run

type StepShutdown

type StepShutdown struct {
	Command         string
	Timeout         time.Duration
	Delay           time.Duration
	DisableShutdown bool
	ACPIShutdown    bool
}

This step shuts down the machine. It first attempts to do so gracefully, but ultimately forcefully shuts it down if that fails.

Uses:

communicator packersdk.Communicator
driver Driver
ui     packersdk.Ui
vmName string

Produces:

<nothing>

func (*StepShutdown) Cleanup

func (s *StepShutdown) Cleanup(state multistep.StateBag)

func (*StepShutdown) Run

type StepSshKeyPair added in v1.4.0

type StepSshKeyPair struct {
	Debug        bool
	DebugKeyPath string
	Comm         *communicator.Config
}

StepSshKeyPair executes the business logic for setting the SSH key pair in the specified communicator.Config.

func (*StepSshKeyPair) Cleanup added in v1.4.0

func (s *StepSshKeyPair) Cleanup(state multistep.StateBag)

func (*StepSshKeyPair) Run added in v1.4.0

type StepSuppressMessages

type StepSuppressMessages struct{}

This step sets some variables in VirtualBox so that annoying pop-up messages don't exist.

func (StepSuppressMessages) Cleanup

func (StepSuppressMessages) Run

type StepTypeBootCommand added in v0.7.0

type StepTypeBootCommand struct {
	BootCommand   string
	BootWait      time.Duration
	VMName        string
	Ctx           interpolate.Context
	GroupInterval time.Duration
	Comm          *communicator.Config
}

func (*StepTypeBootCommand) Cleanup added in v0.7.0

func (*StepTypeBootCommand) Run added in v0.7.0

type StepUploadGuestAdditions added in v0.6.1

type StepUploadGuestAdditions struct {
	GuestAdditionsMode string
	GuestAdditionsPath string
	Ctx                interpolate.Context
}

This step uploads the guest additions ISO to the VM.

func (*StepUploadGuestAdditions) Cleanup added in v0.6.1

func (s *StepUploadGuestAdditions) Cleanup(state multistep.StateBag)

func (*StepUploadGuestAdditions) Run added in v0.6.1

type StepUploadVersion

type StepUploadVersion struct {
	Path string
}

This step uploads a file containing the VirtualBox version, which can be useful for various provisioning reasons.

func (*StepUploadVersion) Cleanup

func (s *StepUploadVersion) Cleanup(state multistep.StateBag)

func (*StepUploadVersion) Run

type StepVBoxManage

type StepVBoxManage struct {
	Commands [][]string
	Ctx      interpolate.Context
}

This step executes additional VBoxManage commands as specified by the template.

Uses:

driver Driver
ui packersdk.Ui
vmName string

Produces:

func (*StepVBoxManage) Cleanup

func (s *StepVBoxManage) Cleanup(state multistep.StateBag)

func (*StepVBoxManage) Run

type VBox42Driver

type VBox42Driver struct {
	// This is the path to the "VBoxManage" application.
	VBoxManagePath string
}

func (*VBox42Driver) CreateNVMeController added in v1.4.5

func (d *VBox42Driver) CreateNVMeController(vmName string, name string, portcount int) error

func (*VBox42Driver) CreateSATAController

func (d *VBox42Driver) CreateSATAController(vmName string, name string, portcount int) error

func (*VBox42Driver) CreateSCSIController added in v0.8.0

func (d *VBox42Driver) CreateSCSIController(vmName string, name string) error

func (*VBox42Driver) CreateSnapshot added in v1.4.3

func (d *VBox42Driver) CreateSnapshot(vmname string, snapshotName string) error

func (*VBox42Driver) CreateVirtIOController added in v1.7.1

func (d *VBox42Driver) CreateVirtIOController(vmName string, name string) error

func (*VBox42Driver) Delete

func (d *VBox42Driver) Delete(name string) error

func (*VBox42Driver) DeleteSnapshot added in v1.4.3

func (d *VBox42Driver) DeleteSnapshot(vmname string, sn *VBoxSnapshot) error

func (*VBox42Driver) GetCurrentSnapshot added in v1.4.3

func (d *VBox42Driver) GetCurrentSnapshot(vmname string) (*VBoxSnapshot, error)

func (*VBox42Driver) HasSnapshots added in v1.4.3

func (d *VBox42Driver) HasSnapshots(vmname string) (bool, error)

func (*VBox42Driver) Import

func (d *VBox42Driver) Import(name string, path string, flags []string) error

func (*VBox42Driver) IsRunning

func (d *VBox42Driver) IsRunning(name string) (bool, error)

func (*VBox42Driver) Iso added in v0.6.1

func (d *VBox42Driver) Iso() (string, error)

func (*VBox42Driver) LoadSnapshots added in v1.4.3

func (d *VBox42Driver) LoadSnapshots(vmName string) (*VBoxSnapshot, error)

LoadSnapshots load the snapshots for a VM instance

func (*VBox42Driver) RemoveFloppyControllers added in v1.5.5

func (d *VBox42Driver) RemoveFloppyControllers(vmName string) error

func (*VBox42Driver) SetSnapshot added in v1.4.3

func (d *VBox42Driver) SetSnapshot(vmname string, sn *VBoxSnapshot) error

func (*VBox42Driver) Stop

func (d *VBox42Driver) Stop(name string) error

func (*VBox42Driver) StopViaACPI added in v1.5.2

func (d *VBox42Driver) StopViaACPI(name string) error

func (*VBox42Driver) SuppressMessages

func (d *VBox42Driver) SuppressMessages() error

func (*VBox42Driver) VBoxManage

func (d *VBox42Driver) VBoxManage(args ...string) error

func (*VBox42Driver) VBoxManageWithOutput added in v1.4.3

func (d *VBox42Driver) VBoxManageWithOutput(args ...string) (string, error)

func (*VBox42Driver) Verify

func (d *VBox42Driver) Verify() error

func (*VBox42Driver) Version

func (d *VBox42Driver) Version() (string, error)

type VBoxBundleConfig added in v1.3.3

type VBoxBundleConfig struct {
	// Defaults to false. When enabled, Packer includes
	// any attached ISO disc devices into the final virtual machine. Useful for
	// some live distributions that require installation media to continue to be
	// attached after installation.
	BundleISO bool `mapstructure:"bundle_iso" required:"false"`
}

func (*VBoxBundleConfig) Prepare added in v1.3.3

func (c *VBoxBundleConfig) Prepare(ctx *interpolate.Context) []error

type VBoxManageConfig

type VBoxManageConfig struct {
	// Custom `VBoxManage` commands to execute in order to further customize
	// the virtual machine being created. The example shown below sets the memory and number of CPUs
	// within the virtual machine:
	//
	// In JSON:
	// “`json
	// "vboxmanage": [
	//    ["modifyvm", "{{.Name}}", "--memory", "1024"],
	//    ["modifyvm", "{{.Name}}", "--cpus", "2"]
	// ]
	// “`
	//
	// In HCL2:
	// “`hcl
	// vboxmanage = [
	//    ["modifyvm", "{{.Name}}", "--memory", "1024"],
	//    ["modifyvm", "{{.Name}}", "--cpus", "2"],
	// ]
	// “`
	//
	// The value of `vboxmanage` is an array of commands to execute. These commands are
	// executed in the order defined. So in the above example, the memory will be set
	// followed by the CPUs.
	// Each command itself is an array of strings, where each string is an argument to
	// `VBoxManage`. Each argument is treated as a [configuration
	// template](/docs/templates/legacy_json_templates/engine). The only available
	// variable is `Name` which is replaced with the unique name of the VM, which is
	// required for many VBoxManage calls.
	VBoxManage [][]string `mapstructure:"vboxmanage" required:"false"`
	// Identical to vboxmanage,
	// except that it is run after the virtual machine is shutdown, and before the
	// virtual machine is exported.
	VBoxManagePost [][]string `mapstructure:"vboxmanage_post" required:"false"`
}

In order to perform extra customization of the virtual machine, a template can define extra calls to `VBoxManage` to perform. [VBoxManage](https://www.virtualbox.org/manual/ch09.html) is the command-line interface to VirtualBox where you can completely control VirtualBox. It can be used to do things such as set RAM, CPUs, etc.

func (*VBoxManageConfig) Prepare

func (c *VBoxManageConfig) Prepare(ctx *interpolate.Context) []error

type VBoxSnapshot added in v1.4.3

type VBoxSnapshot struct {
	Name      string
	UUID      string
	IsCurrent bool
	Parent    *VBoxSnapshot // nil if topmost (root) snapshot
	Children  []*VBoxSnapshot
}

VBoxSnapshot stores the hierarchy of snapshots for a VM instance

func ParseSnapshotData added in v1.4.3

func ParseSnapshotData(snapshotData string) (*VBoxSnapshot, error)

ParseSnapshotData parses the machinereadable representation of a virtualbox snapshot tree

func (*VBoxSnapshot) GetChildWithName added in v1.4.3

func (sn *VBoxSnapshot) GetChildWithName(name string) *VBoxSnapshot

func (*VBoxSnapshot) GetCurrentSnapshot added in v1.4.3

func (sn *VBoxSnapshot) GetCurrentSnapshot() *VBoxSnapshot

GetCurrentSnapshot returns the currently attached snapshot

func (*VBoxSnapshot) GetRoot added in v1.4.3

func (sn *VBoxSnapshot) GetRoot() *VBoxSnapshot

GetRoot returns the top-most (root) snapshot for a given snapshot

func (*VBoxSnapshot) GetSnapshotByUUID added in v1.4.3

func (sn *VBoxSnapshot) GetSnapshotByUUID(uuid string) *VBoxSnapshot

GetSnapshotByUUID returns a snapshot by it's UUID

func (*VBoxSnapshot) GetSnapshots added in v1.4.3

func (sn *VBoxSnapshot) GetSnapshots() []*VBoxSnapshot

GetSnapshots returns an array of all snapshots defined

func (*VBoxSnapshot) GetSnapshotsByName added in v1.4.3

func (sn *VBoxSnapshot) GetSnapshotsByName(name string) []*VBoxSnapshot

GetSnapshotsByName find all snapshots with a given name

func (*VBoxSnapshot) IsChildOf added in v1.4.3

func (sn *VBoxSnapshot) IsChildOf(candidate *VBoxSnapshot) bool

IsChildOf verifies if the current snaphot is a child of the passed as argument

type VBoxVersionConfig

type VBoxVersionConfig struct {
	// The path within the virtual machine to
	// upload a file that contains the VirtualBox version that was used to create
	// the machine. This information can be useful for provisioning. By default
	// this is .vbox_version, which will generally be upload it into the
	// home directory. Set to an empty string to skip uploading this file, which
	// can be useful when using the none communicator.
	VBoxVersionFile *string `mapstructure:"virtualbox_version_file" required:"false"`
}

func (*VBoxVersionConfig) Prepare

func (c *VBoxVersionConfig) Prepare(communicatorType string) []error

Jump to

Keyboard shortcuts

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