common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2013 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const BuilderId = "mitchellh.virtualbox"

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

Variables

This section is empty.

Functions

func NewArtifact

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

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

func SSHAddress

func SSHAddress(state multistep.StateBag) (string, error)

func SSHConfigFunc

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

Types

type Driver

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

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

	// Import a VM
	Import(string, 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

	DeleteCalled bool
	DeleteName   string
	DeleteErr    error

	ImportCalled bool
	ImportName   string
	ImportPath   string
	ImportErr    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) Delete

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

func (*DriverMock) Import

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

func (*DriverMock) IsRunning

func (d *DriverMock) IsRunning(name string) (bool, 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(t *packer.ConfigTemplate) []error

type FloppyConfig

type FloppyConfig struct {
	FloppyFiles []string `mapstructure:"floppy_files"`
}

FloppyConfig is configuration related to created floppy disks and attaching them to a VirtualBox machine.

func (*FloppyConfig) Prepare

func (c *FloppyConfig) Prepare(t *packer.ConfigTemplate) []error

type OutputConfig

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

func (*OutputConfig) Prepare

type RunConfig

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

	BootWait time.Duration ``
}

func (*RunConfig) Prepare

func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error

type SSHConfig

type SSHConfig struct {
	SSHHostPortMin    uint   `mapstructure:"ssh_host_port_min"`
	SSHHostPortMax    uint   `mapstructure:"ssh_host_port_max"`
	SSHKeyPath        string `mapstructure:"ssh_key_path"`
	SSHPassword       string `mapstructure:"ssh_password"`
	SSHPort           uint   `mapstructure:"ssh_port"`
	SSHUser           string `mapstructure:"ssh_username"`
	RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`

	SSHWaitTimeout time.Duration
}

func (*SSHConfig) Prepare

func (c *SSHConfig) Prepare(t *packer.ConfigTemplate) []error

type ShutdownConfig

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

	ShutdownTimeout time.Duration ``
}

func (*ShutdownConfig) Prepare

func (c *ShutdownConfig) Prepare(t *packer.ConfigTemplate) []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 StepExport

type StepExport struct {
	Format    string
	OutputDir string
}

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 {
	GuestPort   uint
	HostPortMin uint
	HostPortMax uint
}

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
}

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
}

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 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
	Tpl      *packer.ConfigTemplate
}

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) Delete

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

func (*VBox42Driver) Import

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

func (*VBox42Driver) IsRunning

func (d *VBox42Driver) IsRunning(name string) (bool, 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(t *packer.ConfigTemplate) []error

type VBoxVersionConfig

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

func (*VBoxVersionConfig) Prepare

func (c *VBoxVersionConfig) Prepare(t *packer.ConfigTemplate) []error

Jump to

Keyboard shortcuts

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