common

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2017 License: MPL-2.0 Imports: 25 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 NewArtifact

func NewArtifact(dir string) (packer.Artifact, error)

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

func SSHConfigFunc

func SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*gossh.ClientConfig, error)

func SSHPort added in v0.8.0

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

Types

type Driver

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

	// Create a SCSI controller.
	CreateSCSIController(vm string, controller 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

	// 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
	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)
}

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

	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

	StopName string
	StopErr  error

	SuppressMessagesCalled bool
	SuppressMessagesErr    error

	VBoxManageCalls [][]string
	VBoxManageErrs  []error

	VerifyCalled bool
	VerifyErr    error

	VersionCalled bool
	VersionResult string
	VersionErr    error
}

func (*DriverMock) CreateSATAController

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

func (*DriverMock) CreateSCSIController added in v0.8.0

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

func (*DriverMock) Delete

func (d *DriverMock) Delete(name string) 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) Stop

func (d *DriverMock) Stop(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 {
	Format string `mapstruture:"format"`
}

func (*ExportConfig) Prepare

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

type ExportOpts added in v0.6.0

type ExportOpts struct {
	ExportOpts []string `mapstructure:"export_opts"`
}

func (*ExportOpts) Prepare added in v0.6.0

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

type OutputConfig

type OutputConfig struct {
	OutputDir string `mapstructure:"output_directory"`
}

func (*OutputConfig) Prepare

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

type RunConfig

type RunConfig struct {
	Headless    bool   `mapstructure:"headless"`
	RawBootWait string `mapstructure:"boot_wait"`

	VRDPBindAddress string `mapstructure:"vrdp_bind_address"`
	VRDPPortMin     uint   `mapstructure:"vrdp_port_min"`
	VRDPPortMax     uint   `mapstructure:"vrdp_port_max"`

	BootWait time.Duration ``
}

func (*RunConfig) Prepare

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

type SSHConfig

type SSHConfig struct {
	Comm communicator.Config `mapstructure:",squash"`

	SSHHostPortMin    uint `mapstructure:"ssh_host_port_min"`
	SSHHostPortMax    uint `mapstructure:"ssh_host_port_max"`
	SSHSkipNatMapping bool `mapstructure:"ssh_skip_nat_mapping"`

	// These are deprecated, but we keep them around for BC
	// TODO(@mitchellh): remove
	SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"`
}

func (*SSHConfig) Prepare

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

type ShutdownConfig

type ShutdownConfig struct {
	ShutdownCommand      string `mapstructure:"shutdown_command"`
	RawShutdownTimeout   string `mapstructure:"shutdown_timeout"`
	RawPostShutdownDelay string `mapstructure:"post_shutdown_delay"`

	ShutdownTimeout   time.Duration ``
	PostShutdownDelay time.Duration ``
}

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 packer.Ui
vmName string

Produces:

func (*StepAttachFloppy) Cleanup

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

func (*StepAttachFloppy) Run

type StepAttachGuestAdditions added in v0.6.1

type StepAttachGuestAdditions struct {
	GuestAdditionsMode string
	// contains filtered or unexported fields
}

This step attaches the VirtualBox guest additions as a inserted CD onto the virtual machine.

Uses:

config *config
driver Driver
guest_additions_path string
ui packer.Ui
vmName string

Produces:

func (*StepAttachGuestAdditions) Cleanup added in v0.6.1

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

func (*StepAttachGuestAdditions) Run added in v0.6.1

type StepConfigureVRDP added in v0.9.0

type StepConfigureVRDP struct {
	VRDPBindAddress string
	VRDPPortMin     uint
	VRDPPortMax     uint
}

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

Uses:

driver Driver
ui packer.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
	ExportOpts     []string
	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 StepForwardSSH

type StepForwardSSH struct {
	CommConfig     *communicator.Config
	HostPortMin    uint
	HostPortMax    uint
	SkipNatMapping bool
}

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

Uses:

driver Driver
ui packer.Ui
vmName string

Produces:

func (*StepForwardSSH) Cleanup

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

func (*StepForwardSSH) Run

type StepOutputDir

type StepOutputDir struct {
	Force bool
	Path  string
	// contains filtered or unexported fields
}

StepOutputDir sets up the output directory by creating it if it does not exist, deleting it if it does exist and we're forcing, and cleaning it up when we're done with it.

func (*StepOutputDir) Cleanup

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

func (*StepOutputDir) Run

type StepRemoveDevices

type StepRemoveDevices struct{}

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

Uses:

driver Driver
ui packer.Ui
vmName string

Produces:

func (*StepRemoveDevices) Cleanup

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

func (*StepRemoveDevices) Run

type StepRun

type StepRun struct {
	BootWait time.Duration
	Headless bool
	// contains filtered or unexported fields
}

This step starts the virtual machine.

Uses:

driver Driver
ui packer.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
}

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

Uses:

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

Produces:

<nothing>

func (*StepShutdown) Cleanup

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

func (*StepShutdown) Run

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
	VMName      string
	Ctx         interpolate.Context
}

This step "types" the boot command into the VM over VNC.

Uses:

driver Driver
http_port int
ui     packer.Ui
vmName string

Produces:

<nothing>

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 packer.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) CreateSATAController

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

func (*VBox42Driver) CreateSCSIController added in v0.8.0

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

func (*VBox42Driver) Delete

func (d *VBox42Driver) Delete(name string) 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) Stop

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

func (*VBox42Driver) SuppressMessages

func (d *VBox42Driver) SuppressMessages() error

func (*VBox42Driver) VBoxManage

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

func (*VBox42Driver) Verify

func (d *VBox42Driver) Verify() error

func (*VBox42Driver) Version

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

type VBoxManageConfig

type VBoxManageConfig struct {
	VBoxManage [][]string `mapstructure:"vboxmanage"`
}

func (*VBoxManageConfig) Prepare

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

type VBoxManagePostConfig added in v0.6.0

type VBoxManagePostConfig struct {
	VBoxManagePost [][]string `mapstructure:"vboxmanage_post"`
}

func (*VBoxManagePostConfig) Prepare added in v0.6.0

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

type VBoxVersionConfig

type VBoxVersionConfig struct {
	VBoxVersionFile string `mapstructure:"virtualbox_version_file"`
}

func (*VBoxVersionConfig) Prepare

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

Jump to

Keyboard shortcuts

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