common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MPL-2.0 Imports: 49 Imported by: 0

Documentation

Overview

These functions are compatible with WS 9 and 10 on *NIX

These functions are compatible with WS 9 and 10 on *NIX

Index

Constants

View Source
const (
	// BuilderId for the local artifacts
	BuilderId    = "mitchellh.vmware"
	BuilderIdESX = "mitchellh.vmware-esx"

	ArtifactConfFormat         = "artifact.conf.format"
	ArtifactConfKeepRegistered = "artifact.conf.keep_registered"
	ArtifactConfSkipExport     = "artifact.conf.skip_export"
)
View Source
const (
	ALLOW  grant = iota
	IGNORE grant = iota
	DENY   grant = iota
)
View Source
const (
	NetworkingType_HOSTONLY = iota + 1
	NetworkingType_NAT
	NetworkingType_BRIDGED
)
View Source
const (
	ExportFormatOvf = "ovf"
	ExportFormatOva = "ova"
	ExportFormatVmx = "vmx"
)

Set the export formats for the virtual machine.

View Source
const (
	FirmwareTypeBios       = "bios"
	FirmwareTypeUEFI       = "efi"
	FirmwareTypeUEFISecure = "efi-secure"
)

Set the firmware types for the virtual machine.

View Source
const (
	ToolsFlavorMacOS   = "darwin"
	ToolsFlavorLinux   = "linux"
	ToolsFlavorWindows = "windows"
)

Set the allowed values for the `ToolsUploadFlavor`.

View Source
const NetworkingInterfacePrefix = "vmnet"
View Source
const VMWARE_FUSION_VERSION = "6"
View Source
const VMWARE_PLAYER_VERSION = "6"
View Source
const VMWARE_WS_VERSION = "10"

Variables

View Source
var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"}

These are the extensions of files that are important for the function of a VMware virtual machine. Any other file is discarded as part of the build.

View Source
var NetworkingCommandParsers = []networkingCommandParser{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

Functions

func CheckOvfToolVersion added in v1.1.0

func CheckOvfToolVersion(ovftoolPath string) error

CheckOvfToolVersion checks the version of the VMware OVF Tool.

func CommHost

func CommHost(config *SSHConfig) func(multistep.StateBag) (string, error)

func EncodeVMX

func EncodeVMX(contents map[string]string) string

EncodeVMX takes a map and turns it into valid VMX contents.

func GetOvfTool added in v1.1.0

func GetOvfTool() string

func MockInterface

func MockInterface() net.Interface

func NetworkingParserByCommand

func NetworkingParserByCommand(command string) *func([]string) (*networkingCommandEntry, error)

func NewArtifact

func NewArtifact(remoteType string, format string, exportOutputPath string, vmName string, skipExport bool, keepRegistered bool, state multistep.StateBag) (packersdk.Artifact, error)

func ParseVMX

func ParseVMX(contents string) map[string]string

ParseVMX parses the keys and values from a VMX file and returns them as a Go map.

func ReadAppleDhcpdLeaseEntries

func ReadAppleDhcpdLeaseEntries(fd *os.File) ([]appleDhcpLeaseEntry, error)

func ReadDhcpdLeaseEntries

func ReadDhcpdLeaseEntries(fd *os.File) ([]dhcpLeaseEntry, error)

func ReadVMX

func ReadVMX(path string) (map[string]string, error)

ReadVMX takes a path to a VMX file and reads it into a k/v mapping.

func VNCPassword

func VNCPassword(skipPassword bool) string

func WriteVMX

func WriteVMX(path string, data map[string]string) (err error)

WriteVMX takes a path to a VMX file and contents in the form of a map and writes it out.

Types

type DhcpConfiguration

type DhcpConfiguration []configDeclaration

** Dhcp Configuration

func ReadDhcpConfig

func ReadDhcpConfig(path string) (DhcpConfiguration, error)

read the dhcp configuration out of the specified path

func ReadDhcpConfiguration

func ReadDhcpConfiguration(fd *os.File) (DhcpConfiguration, error)

func (*DhcpConfiguration) Global

func (e *DhcpConfiguration) Global() configDeclaration

func (*DhcpConfiguration) HostByName

func (e *DhcpConfiguration) HostByName(host string) (configDeclaration, error)

func (*DhcpConfiguration) SubnetByAddress

func (e *DhcpConfiguration) SubnetByAddress(address net.IP) (configDeclaration, error)

type DiskAndCDConfigData

type DiskAndCDConfigData struct {
	SCSI_Present         string
	SCSI_diskAdapterType string
	SATA_Present         string
	NVME_Present         string

	DiskType                   string
	CDROMType                  string
	CDROMType_PrimarySecondary string
	CDROM_PATH                 string
}

func DefaultDiskAndCDROMTypes

func DefaultDiskAndCDROMTypes(diskAdapterType string, cdromAdapterType string) DiskAndCDConfigData

DefaultDiskAndCDROMTypes takes the disk adapter type and cdrom adapter type from the config and converts them into template interpolation data for creating or configuring a vmx.

type DiskConfig

type DiskConfig struct {
	// The size(s) of additional virtual hard disks in MB. If not specified,
	// the virtual machine will contain only a primary hard disk.
	AdditionalDiskSize []uint `mapstructure:"disk_additional_size" required:"false"`
	// The adapter type for additional virtual disk(s). Available options
	//  are `ide`, `sata`, `nvme`, or `scsi`.
	//
	// ~> **Note:** When specifying `scsi` as the adapter type, the default
	// adapter type is set to `lsilogic`. If another option is specified, the
	// plugin will assume it is a `scsi` interface of that specified type.
	//
	// ~> **Note:** This option is intended for advanced users.
	DiskAdapterType string `mapstructure:"disk_adapter_type" required:"false"`
	// The filename for the virtual disk to create _without_ the `.vmdk`
	// extension. Defaults to `disk`.
	DiskName string `mapstructure:"vmdk_name" required:"false"`
	// The type of virtual disk to create.
	//
	//   For local desktop hypervisors, the available options are:
	//
	//   Type ID | Description
	//   ------- | ---
	//   `0`     | Growable virtual disk contained in a single file (monolithic sparse).
	//   `1`     | Growable virtual disk split into 2GB files (split sparse).
	//   `2`     | Preallocated virtual disk contained in a single file (monolithic flat).
	//   `3`     | Preallocated virtual disk split into 2GB files (split flat).
	//   `4`     | Preallocated virtual disk compatible with ESXi (VMFS flat).
	//   `5`     | Compressed disk optimized for streaming.
	//
	//   Defaults to `1`.
	//
	//   For remote hypervisors, the available options are: `zeroedthick`,
	//   `eagerzeroedthick`, and `thin`. Defaults to `zeroedthick`.
	//
	//   ~> **Note:** The `rdm:dev`, `rdmp:dev`, and `2gbsparse` types are not
	//   supported for remote hypervisors.
	//
	//   ~> **Note:** Set `skip_compaction` to `true` when using `zeroedthick`
	//   or `eagerzeroedthick` due to default disk compaction behavior.
	//
	// ~> **Note:** This option is intended for advanced users.
	DiskTypeId string `mapstructure:"disk_type_id" required:"false"`
}

func (*DiskConfig) Prepare

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

type Driver

type Driver interface {
	// Clone clones the VMX and the disk to the destination path. The
	// destination is a path to the VMX file. The disk will be copied
	// to that same directory.
	Clone(dst string, src string, cloneType bool, snapshot string) error

	// CompactDisk compacts a virtual disk.
	CompactDisk(string) error

	// CreateDisk creates a virtual disk with the given size.
	CreateDisk(string, string, string, string) error

	// CreateSnapshot creates a snapshot of the supplied .vmx file with
	// the given name
	CreateSnapshot(string, string) error

	// Checks if the VMX file at the given path is running.
	IsRunning(string) (bool, error)

	// Start starts a VM specified by the path to the VMX given.
	Start(string, bool) error

	// Stop stops a VM specified by the path to the VMX given.
	Stop(string) error

	// SuppressMessages modifies the VMX or surrounding directory so that
	// VMware doesn't show any annoying messages.
	SuppressMessages(string) error

	// Get the path to the VMware ISO for the given flavor.
	ToolsIsoPath(string) string

	// Attach the VMware tools ISO
	ToolsInstall() error

	// Verify checks to make sure that this driver should function
	// properly. This should check that all the files it will use
	// appear to exist and so on. If everything is okay, this doesn't
	// return an error. Otherwise, this returns an error. Each vmware
	// driver should assign the VmwareMachine callback functions for locating
	// paths within this function.
	Verify() error

	/// This is to establish a connection to the guest
	CommHost(multistep.StateBag) (string, error)

	/// These methods are generally implemented by the VmwareDriver
	/// structure within this file. A driver implementation can
	/// reimplement these, though, if it wants.
	GetVmwareDriver() VmwareDriver

	// Get the guest hw address for the vm
	GuestAddress(multistep.StateBag) (string, error)

	// Get the guest ip address for the vm
	PotentialGuestIP(multistep.StateBag) ([]string, error)

	// Get the host hw address for the vm
	HostAddress(multistep.StateBag) (string, error)

	// Get the host ip address for the vm
	HostIP(multistep.StateBag) (string, error)

	// Export the vm to ovf or ova format using ovftool
	Export([]string) error

	// OvfTool
	VerifyOvfTool(bool, bool) error
}

A driver is able to talk to VMware, control virtual machines, etc.

func NewDriver

func NewDriver(dconfig *DriverConfig, config *SSHConfig, vmName string) (Driver, error)

NewDriver returns a new driver implementation for this operating system, or an error if the driver couldn't be initialized.

func NewESX5Driver

func NewESX5Driver(dconfig *DriverConfig, config *SSHConfig, vmName string) (Driver, error)

func NewFusion5Driver

func NewFusion5Driver(dconfig *DriverConfig, config *SSHConfig) Driver

func NewFusion6Driver

func NewFusion6Driver(dconfig *DriverConfig, config *SSHConfig) Driver

func NewPlayer5Driver

func NewPlayer5Driver(config *SSHConfig) Driver

func NewPlayer6Driver

func NewPlayer6Driver(config *SSHConfig) Driver

func NewWorkstation10Driver

func NewWorkstation10Driver(config *SSHConfig) Driver

func NewWorkstation9Driver

func NewWorkstation9Driver(config *SSHConfig) Driver

type DriverConfig

type DriverConfig struct {
	// Path to "VMware Fusion.app". By default this is
	// /Applications/VMware Fusion.app but this setting allows you to
	// customize this.
	FusionAppPath string `mapstructure:"fusion_app_path" required:"false"`
	// The type of remote machine that will be used to
	// build this VM rather than a local desktop product. The only value accepted
	// for this currently is esx5. If this is not set, a desktop product will
	// be used. By default, this is not set.
	RemoteType string `mapstructure:"remote_type" required:"false"`
	// The path to the datastore where the VM will be stored
	// on the ESXi machine.
	RemoteDatastore string `mapstructure:"remote_datastore" required:"false"`
	// The path to the datastore where supporting files
	// will be stored during the build on the remote machine.
	RemoteCacheDatastore string `mapstructure:"remote_cache_datastore" required:"false"`
	// The path where the ISO and/or floppy files will
	// be stored during the build on the remote machine. The path is relative to
	// the remote_cache_datastore on the remote machine.
	RemoteCacheDirectory string `mapstructure:"remote_cache_directory" required:"false"`
	// When set to true, Packer will cleanup the cache folder where the ISO file is stored during the build on the remote machine.
	// By default, this is set to false.
	CleanUpRemoteCache bool `mapstructure:"cleanup_remote_cache" required:"false"`
	// The host of the remote machine used for access.
	// This is only required if remote_type is enabled.
	RemoteHost string `mapstructure:"remote_host" required:"false"`
	// The SSH port of the remote machine
	RemotePort int `mapstructure:"remote_port" required:"false"`
	// The SSH username used to access the remote machine.
	RemoteUser string `mapstructure:"remote_username" required:"false"`
	// The SSH password for access to the remote machine.
	RemotePassword string `mapstructure:"remote_password" required:"false"`
	// The SSH key for access to the remote machine.
	RemotePrivateKey string `mapstructure:"remote_private_key_file" required:"false"`
	// When Packer is preparing to run a
	// remote hypervisor build, and export is not disable, by default it runs a no-op
	// ovftool command to make sure that the remote_username and remote_password
	// given are valid. If you set this flag to true, Packer will skip this
	// validation. Default: false.
	SkipValidateCredentials bool `mapstructure:"skip_validate_credentials" required:"false"`
}

func (*DriverConfig) Prepare

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

func (*DriverConfig) Validate

func (c *DriverConfig) Validate(SkipExport bool) error

type DriverMock

type DriverMock struct {
	sync.Mutex

	CloneCalled bool
	CloneDst    string
	CloneSrc    string
	Linked      bool
	Snapshot    string
	CloneErr    error

	CompactDiskCalled bool
	CompactDiskPath   string
	CompactDiskErr    error

	CreateDiskCalled      bool
	CreateDiskOutput      string
	CreateDiskSize        string
	CreateDiskAdapterType string
	CreateDiskTypeId      string
	CreateDiskErr         error

	CreateSnapshotCalled  bool
	CreateSnapshotVMXPath string
	CreateSnapshotName    string
	CreateSnapshotErr     error

	ExportCalled bool
	ExportArgs   []string

	IsRunningCalled bool
	IsRunningPath   string
	IsRunningResult bool
	IsRunningErr    error

	CommHostCalled bool
	CommHostState  multistep.StateBag
	CommHostResult string
	CommHostErr    error

	HostAddressCalled bool
	HostAddressState  multistep.StateBag
	HostAddressResult string
	HostAddressErr    error

	HostIPCalled bool
	HostIPState  multistep.StateBag
	HostIPResult string
	HostIPErr    error

	GuestAddressCalled bool
	GuestAddressState  multistep.StateBag
	GuestAddressResult string
	GuestAddressErr    error

	PotentialGuestIPCalled bool
	PotentialGuestIPState  multistep.StateBag
	PotentialGuestIPResult []string
	PotentialGuestIPErr    error

	StartCalled   bool
	StartPath     string
	StartHeadless bool
	StartErr      error

	StopCalled bool
	StopPath   string
	StopErr    error

	SuppressMessagesCalled bool
	SuppressMessagesPath   string
	SuppressMessagesErr    error

	ToolsIsoPathCalled bool
	ToolsIsoPathFlavor string
	ToolsIsoPathResult string

	ToolsInstallCalled bool
	ToolsInstallErr    error

	DhcpLeasesPathCalled bool
	DhcpLeasesPathDevice string
	DhcpLeasesPathResult string

	DhcpConfPathCalled bool
	DhcpConfPathResult string

	VmnetnatConfPathCalled bool
	VmnetnatConfPathResult string

	NetmapConfPathCalled bool
	NetmapConfPathResult string

	VerifyCalled bool
	VerifyErr    error

	VerifyOvftoolCalled bool
}

func (*DriverMock) Clone

func (d *DriverMock) Clone(dst string, src string, linked bool, snapshot string) error

func (*DriverMock) CommHost

func (d *DriverMock) CommHost(state multistep.StateBag) (string, error)

func (*DriverMock) CompactDisk

func (d *DriverMock) CompactDisk(path string) error

func (*DriverMock) CreateDisk

func (d *DriverMock) CreateDisk(output string, size string, adapterType string, typeId string) error

func (*DriverMock) CreateSnapshot added in v1.0.0

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

func (*DriverMock) DhcpConfPath

func (d *DriverMock) DhcpConfPath(device string) string

func (*DriverMock) DhcpLeasesPath

func (d *DriverMock) DhcpLeasesPath(device string) string

func (*DriverMock) Export

func (d *DriverMock) Export(args []string) error

func (*DriverMock) GetVmwareDriver

func (d *DriverMock) GetVmwareDriver() VmwareDriver

func (*DriverMock) GuestAddress

func (d *DriverMock) GuestAddress(state multistep.StateBag) (string, error)

func (*DriverMock) HostAddress

func (d *DriverMock) HostAddress(state multistep.StateBag) (string, error)

func (*DriverMock) HostIP

func (d *DriverMock) HostIP(state multistep.StateBag) (string, error)

func (*DriverMock) IsRunning

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

func (*DriverMock) NetmapConfPath

func (d *DriverMock) NetmapConfPath() string

func (*DriverMock) PotentialGuestIP

func (d *DriverMock) PotentialGuestIP(state multistep.StateBag) ([]string, error)

func (*DriverMock) Start

func (d *DriverMock) Start(path string, headless bool) error

func (*DriverMock) Stop

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

func (*DriverMock) SuppressMessages

func (d *DriverMock) SuppressMessages(path string) error

func (*DriverMock) ToolsInstall

func (d *DriverMock) ToolsInstall() error

func (*DriverMock) ToolsIsoPath

func (d *DriverMock) ToolsIsoPath(flavor string) string

func (*DriverMock) Verify

func (d *DriverMock) Verify() error

func (*DriverMock) VerifyOvfTool

func (d *DriverMock) VerifyOvfTool(_ bool, _ bool) error

func (*DriverMock) VmnetnatConfPath

func (d *DriverMock) VmnetnatConfPath(device string) string

type ESX5Driver

type ESX5Driver struct {
	Host           string
	Port           int
	Username       string
	Password       string
	PrivateKeyFile string
	Datastore      string
	CacheDatastore string
	CacheDirectory string
	VMName         string
	CommConfig     communicator.Config
	// contains filtered or unexported fields
}

ESX5 driver talks to an ESXi5 hypervisor remotely over SSH to build virtual machines. This driver can only manage one machine at a time.

func (*ESX5Driver) AcquireVNCOverWebsocketTicket

func (d *ESX5Driver) AcquireVNCOverWebsocketTicket() (*types.VirtualMachineTicket, error)

func (*ESX5Driver) CachePath

func (d *ESX5Driver) CachePath(path string) string

func (*ESX5Driver) Clone

func (d *ESX5Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*ESX5Driver) CommHost

func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error)

func (*ESX5Driver) CompactDisk

func (d *ESX5Driver) CompactDisk(diskPathLocal string) error

func (*ESX5Driver) CreateDisk

func (d *ESX5Driver) CreateDisk(diskPathLocal string, size string, adapter_type string, typeId string) error

func (*ESX5Driver) CreateSnapshot added in v1.0.0

func (d *ESX5Driver) CreateSnapshot(vmxPath string, snapshotName string) error

func (*ESX5Driver) Destroy

func (d *ESX5Driver) Destroy() error

func (*ESX5Driver) DirExists

func (d *ESX5Driver) DirExists() (bool, error)

func (*ESX5Driver) Download

func (d *ESX5Driver) Download(src, dst string) error

func (*ESX5Driver) Export

func (d *ESX5Driver) Export(args []string) error

func (*ESX5Driver) GetVmwareDriver

func (d *ESX5Driver) GetVmwareDriver() VmwareDriver

func (*ESX5Driver) GuestAddress

func (d *ESX5Driver) GuestAddress(multistep.StateBag) (string, error)

func (*ESX5Driver) HostAddress

func (d *ESX5Driver) HostAddress(multistep.StateBag) (string, error)

func (*ESX5Driver) HostIP

func (d *ESX5Driver) HostIP(multistep.StateBag) (string, error)

func (*ESX5Driver) IsDestroyed

func (d *ESX5Driver) IsDestroyed() (bool, error)

func (*ESX5Driver) IsRunning

func (d *ESX5Driver) IsRunning(string) (bool, error)

func (*ESX5Driver) ListFiles

func (d *ESX5Driver) ListFiles() ([]string, error)

func (*ESX5Driver) MkdirAll

func (d *ESX5Driver) MkdirAll() error

func (*ESX5Driver) PotentialGuestIP

func (d *ESX5Driver) PotentialGuestIP(multistep.StateBag) ([]string, error)

func (*ESX5Driver) Register

func (d *ESX5Driver) Register(vmxPathLocal string) error

func (*ESX5Driver) ReloadVM

func (d *ESX5Driver) ReloadVM() error

func (*ESX5Driver) Remove

func (d *ESX5Driver) Remove(path string) error

func (*ESX5Driver) RemoveAll

func (d *ESX5Driver) RemoveAll() error

func (*ESX5Driver) RemoveCache

func (d *ESX5Driver) RemoveCache(localPath string) error

func (*ESX5Driver) SetOutputDir

func (d *ESX5Driver) SetOutputDir(path string)

func (*ESX5Driver) Start

func (d *ESX5Driver) Start(vmxPathLocal string, headless bool) error

func (*ESX5Driver) Stop

func (d *ESX5Driver) Stop(vmxPathLocal string) error

func (*ESX5Driver) String

func (d *ESX5Driver) String() string

func (*ESX5Driver) SuppressMessages

func (d *ESX5Driver) SuppressMessages(vmxPath string) error

func (*ESX5Driver) ToolsInstall

func (d *ESX5Driver) ToolsInstall() error

func (*ESX5Driver) ToolsIsoPath

func (d *ESX5Driver) ToolsIsoPath(string) string

func (*ESX5Driver) Unregister

func (d *ESX5Driver) Unregister(vmxPathLocal string) error

func (ESX5Driver) UpdateVMX

func (ESX5Driver) UpdateVMX(_, password string, port int, data map[string]string)

UpdateVMX, adds the VNC port to the VMX data.

func (*ESX5Driver) UploadISO

func (d *ESX5Driver) UploadISO(localPath string, checksum string, ui packersdk.Ui) (string, error)

func (*ESX5Driver) VNCAddress

func (d *ESX5Driver) VNCAddress(ctx context.Context, _ string, portMin, portMax int) (string, int, error)

func (*ESX5Driver) Verify

func (d *ESX5Driver) Verify() error

func (*ESX5Driver) VerifyChecksum

func (d *ESX5Driver) VerifyChecksum(hash string, file string) bool

VerifyChecksum checks that file on the esxi instance matches hash

func (*ESX5Driver) VerifyOvfTool

func (d *ESX5Driver) VerifyOvfTool(SkipExport, skipValidateCredentials bool) error

type ExportConfig

type ExportConfig struct {
	// The output format of the exported virtual machine. Allowed values are
	// `ova`, `ovf`, or `vmx`. Defaults to `vmx` for local desktop hypervisors
	// and `ova` for remote hypervisors.
	//
	// For builds on a remote hypervisor, `remote_password` must be set when
	// exporting the virtual machine
	//
	// For builds on a local desktop hypervisor, the plugin will create a `.vmx`
	// and export the virtual machine as an `.ovf` or `.ova` file. THe plugin
	// will not delete the `.vmx` and `.vmdk` files. You must manually delete
	// these files if they are no longer needed.
	//
	// ~> **Note:** Ensure VMware OVF Tool is installed. For the latest version,
	// visit [VMware OVF Tool](https://developer.broadcom.com/tools/open-virtualization-format-ovf-tool/latest).
	//
	// ~> **Note:** For local builds, the plugin will create a `.vmx` and
	// supporting files in the output directory and will then export the
	// virtual machine to the specified format. These files are **not**
	// automatically cleaned up after the export process.
	Format string `mapstructure:"format" required:"false"`
	// Additional command-line arguments to send to VMware OVF Tool during the
	// export process. Each string in the array represents a separate
	// command-line argument.
	//
	// ~> **Important:** The options `--noSSLVerify`, `--skipManifestCheck`, and
	// `--targetType` are automatically applied by the plugin for remote exports
	// and should not be included in the options. For local OVF/OVA exports,
	// the plugin does not preset any VMware OVF Tool options by default.
	//
	// ~> **Note:** Ensure VMware OVF Tool is installed. For the latest version,
	// visit [VMware OVF Tool](https://developer.broadcom.com/tools/open-virtualization-format-ovf-tool/latest).
	OVFToolOptions []string `mapstructure:"ovftool_options" required:"false"`
	// Skips the export of the virtual machine. This is useful if the build
	// output is not the resultant image, but created inside the virtual
	// machine. This is useful for debugging purposes. Defaults to `false`.
	SkipExport bool `mapstructure:"skip_export" required:"false"`
	// Determines whether a virtual machine built on a remote hypervisor should
	// remain registered after the build process. Setting this to `true` can be
	// useful if the virtual machine does not need to be exported. Defaults to
	// `false`.
	KeepRegistered bool `mapstructure:"keep_registered" required:"false"`
	// At the end of the build process, the plugin defragments and compacts the
	// disks using `vmware-vdiskmanager` or `vmkfstools` for ESXi environments.
	// In some cases, this process may result in slightly larger disk sizes.
	// If this occurs, you can opt to skip the disk compaction step by using
	// this setting. Defaults to `false`. Defaults to `true` for ESXi when
	// `disk_type_id` is not explicitly defined and `false`
	SkipCompaction bool `mapstructure:"skip_compaction" required:"false"`
}

func (*ExportConfig) Prepare

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

type Fusion5Driver

type Fusion5Driver struct {
	VmwareDriver

	// This is the path to the "VMware Fusion.app"
	AppPath string

	// SSHConfig are the SSH settings for the Fusion VM
	SSHConfig *SSHConfig
}

Fusion5Driver is a driver that can run VMware Fusion 5.

func (*Fusion5Driver) Clone

func (d *Fusion5Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Fusion5Driver) CommHost

func (d *Fusion5Driver) CommHost(state multistep.StateBag) (string, error)

func (*Fusion5Driver) CompactDisk

func (d *Fusion5Driver) CompactDisk(diskPath string) error

func (*Fusion5Driver) CreateDisk

func (d *Fusion5Driver) CreateDisk(output string, size string, adapter_type string, type_id string) error

func (*Fusion5Driver) CreateSnapshot added in v1.0.0

func (d *Fusion5Driver) CreateSnapshot(vmxPath string, snapshotName string) error

func (*Fusion5Driver) GetVmwareDriver

func (d *Fusion5Driver) GetVmwareDriver() VmwareDriver

func (*Fusion5Driver) IsRunning

func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error)

func (*Fusion5Driver) Start

func (d *Fusion5Driver) Start(vmxPath string, headless bool) error

func (*Fusion5Driver) Stop

func (d *Fusion5Driver) Stop(vmxPath string) error

func (*Fusion5Driver) SuppressMessages

func (d *Fusion5Driver) SuppressMessages(vmxPath string) error

func (*Fusion5Driver) ToolsInstall

func (d *Fusion5Driver) ToolsInstall() error

func (*Fusion5Driver) ToolsIsoPath

func (d *Fusion5Driver) ToolsIsoPath(k string) string

func (*Fusion5Driver) Verify

func (d *Fusion5Driver) Verify() error

type Fusion6Driver

type Fusion6Driver struct {
	Fusion5Driver
}

Fusion6Driver is a driver that can run VMware Fusion 6.

func (*Fusion6Driver) Clone

func (d *Fusion6Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Fusion6Driver) GetVmwareDriver

func (d *Fusion6Driver) GetVmwareDriver() VmwareDriver

func (*Fusion6Driver) ToolsIsoPath added in v1.0.8

func (d *Fusion6Driver) ToolsIsoPath(k string) string

func (*Fusion6Driver) Verify

func (d *Fusion6Driver) Verify() error

type HWConfig

type HWConfig struct {
	// The firmware type for the virtual machine.
	// Allowed values are `bios`, `efi`, and `efi-secure` (for secure boot).
	// Defaults to the recommended firmware type for the guest operating system.
	Firmware string `mapstructure:"firmware" required:"false"`
	// The number of virtual CPUs cores for the virtual machine.
	CpuCount int `mapstructure:"cpus" required:"false"`
	// The number of virtual CPU cores per socket for the virtual machine.
	CoreCount int `mapstructure:"cores" required:"false"`
	// The amount of memory for the virtual machine in MB.
	MemorySize int `mapstructure:"memory" required:"false"`
	// The network which the virtual machine will connect for local desktop
	// hypervisors. Use the generic values that map to a device, such as
	// `hostonly`, `nat`, or `bridged`. Defaults to `nat`.
	//
	// ~> **Note:** If not set to one of these generic values, then it is
	// assumed to be a network device (_e.g._, `VMnet0..x`).
	Network string `mapstructure:"network" required:"false"`
	// The network which the virtual machine will connect on a remote
	// hypervisor.
	NetworkName string `mapstructure:"network_name" required:"false"`
	// The virtual machine network card type. Recommended values are `e1000` and
	// `vmxnet3`. Defaults to `e1000`.
	//
	// Refer to VMware product documentation for supported network adapter types
	// for the hypervisor and guest operating system.
	NetworkAdapterType string `mapstructure:"network_adapter_type" required:"false"`
	// Enable virtual sound card device. Defaults to `false`.
	Sound bool `mapstructure:"sound" required:"false"`
	// Enable a the USB 2.0 controllers for the virtual machine.
	// Defaults to `false`.
	//
	// ~> **Note:** To enable USB 3.0 controllers, set a `usb_xhci.present`
	// key to `true` in the `vmx_data` option.
	USB bool `mapstructure:"usb" required:"false"`
	// Add a serial port to the virtual machine. Use a format of
	// `Type:option1,option2,...`. Allowed values for the field `Type` include:
	// `FILE`, `DEVICE`, `PIPE`, `AUTO`, or `NONE`.
	//
	// * `FILE:path(,yield)` - Specifies the path to the local file to be used
	//   as the serial port.
	//
	//   * `yield` (bool) - This is an optional boolean that specifies
	//     whether the virtual machine should yield the CPU when polling the
	//     port. By default, the builder will assume this as `FALSE`.
	//
	// * `DEVICE:path(,yield)` - Specifies the path to the local device to be
	//   used as the serial port. If `path` is empty, then default to the first
	//   serial port.
	//
	//   * `yield` (bool) - This is an optional boolean that specifies
	//     whether the virtual machine should yield the CPU when polling the
	//     port. By default, the builder will assume this as `FALSE`.
	//
	// * `PIPE:path,endpoint,host(,yield)` - Specifies to use the named-pipe
	//   "path" as a serial port. This has a few options that determine how the
	//   VM should use the named-pipe.
	//
	//   * `endpoint` (string) - Chooses the type of the VM-end, which can be
	//     either a `client` or `server`.
	//
	//   * `host` (string) - Chooses the type of the host-end, which can be
	//     either `app` (application) or `vm` (another virtual-machine).
	//
	//   * `yield` (bool) - This is an optional boolean that specifies whether
	//     the virtual machine should yield the CPU when polling the port. By
	//     default, the builder will assume this as `FALSE`.
	//
	// * `AUTO:(yield)` - Specifies to use auto-detection to determine the
	//   serial port to use. This has one option to determine how the virtual
	//   machine should support the serial port.
	//
	//   * `yield` (bool) - This is an optional boolean that specifies whether
	//     the virtual machine should yield the CPU when polling the port. By
	//     default, the builder will assume this as `FALSE`.
	//
	// * `NONE` - Specifies to not use a serial port. (default)
	Serial string `mapstructure:"serial" required:"false"`
	// Add a parallel port to add to the virtual machine. Use a format of
	// `Type:option1,option2,...`. Allowed values for the field `Type` include:
	// `FILE`, `DEVICE`, `AUTO`, or `NONE`.
	//
	// * `FILE:path` - Specifies the path to the local file to be used for the
	//    parallel port.
	//
	// * `DEVICE:path` - Specifies the path to the local device to be used for
	//    the parallel port.
	//
	// * `AUTO:direction` - Specifies to use auto-detection to determine the
	//   parallel port. Direction can be `BI` to specify bidirectional
	//   communication or `UNI` to specify unidirectional communication.
	//
	// * `NONE` - Specifies to not use a parallel port. (default)
	Parallel string `mapstructure:"parallel" required:"false"`
}

func (*HWConfig) HasParallel

func (c *HWConfig) HasParallel() bool

func (*HWConfig) HasSerial

func (c *HWConfig) HasSerial() bool

func (*HWConfig) Prepare

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

func (*HWConfig) ReadParallel

func (c *HWConfig) ReadParallel() (*ParallelUnion, error)

func (*HWConfig) ReadSerial

func (c *HWConfig) ReadSerial() (*SerialUnion, error)

type IfconfigIPFinder

type IfconfigIPFinder struct {
	Device string
}

IfconfigIPFinder finds the host IP based on the output of `ip address` or `ifconfig`.

func (*IfconfigIPFinder) HostIP

func (f *IfconfigIPFinder) HostIP() (string, error)

type LocalOutputDir

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

LocalOutputDir is an OutputDir implementation where the directory is on the local machine.

func (*LocalOutputDir) DirExists

func (d *LocalOutputDir) DirExists() (bool, error)

func (*LocalOutputDir) ListFiles

func (d *LocalOutputDir) ListFiles() ([]string, error)

func (*LocalOutputDir) MkdirAll

func (d *LocalOutputDir) MkdirAll() error

func (*LocalOutputDir) Remove

func (d *LocalOutputDir) Remove(path string) error

func (*LocalOutputDir) RemoveAll

func (d *LocalOutputDir) RemoveAll() error

func (*LocalOutputDir) SetOutputDir

func (d *LocalOutputDir) SetOutputDir(path string)

func (*LocalOutputDir) String

func (d *LocalOutputDir) String() string

type NetmapConfig added in v1.1.0

type NetmapConfig struct {
	Index  int
	Name   string
	Device string
}

NetmapConfig is a struct that represents a network mapper configuration.

type NetworkMap

type NetworkMap []map[string]string

** Network Map

func ReadNetmapConfig

func ReadNetmapConfig(path string) (NetworkMap, error)

helper functions that read configuration information from a file read the network<->device configuration out of the specified path

func ReadNetworkMap

func ReadNetworkMap(fd *os.File) (NetworkMap, error)

func (NetworkMap) DeviceIntoName

func (e NetworkMap) DeviceIntoName(device string) (string, error)

func (NetworkMap) NameIntoDevices

func (e NetworkMap) NameIntoDevices(name string) ([]string, error)

type NetworkMapperMock

type NetworkMapperMock struct {
	NameIntoDeviceCalled int
	DeviceIntoNameCalled int
}

func (*NetworkMapperMock) DeviceIntoName

func (m *NetworkMapperMock) DeviceIntoName(device string) (string, error)

func (*NetworkMapperMock) NameIntoDevices

func (m *NetworkMapperMock) NameIntoDevices(name string) ([]string, error)

type NetworkNameMapper

type NetworkNameMapper interface {
	NameIntoDevices(string) ([]string, error)
	DeviceIntoName(string) (string, error)
}

type NetworkingConfig

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

func ReadNetworkingConfig

func ReadNetworkingConfig(fd *os.File) (NetworkingConfig, error)

Constructor for networking file

func (NetworkingConfig) DeviceIntoName

func (e NetworkingConfig) DeviceIntoName(device string) (string, error)

func (NetworkingConfig) NameIntoDevices

func (e NetworkingConfig) NameIntoDevices(name string) ([]string, error)

type NetworkingType

type NetworkingType int

netmapper interface

type OutputConfig

type OutputConfig struct {
	// This is the path on your local machine (the one running Packer) 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.
	//
	// If you are running a remote hypervisor build, the output_dir is the path on your
	// local machine (the machine running Packer) to which Packer will export
	// the vm if you have `"skip_export": false`. If you want to manage the
	// virtual machine's path on the remote datastore, use `remote_output_dir`.
	//
	// 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 directory on your remote hypervisor where you will save your
	// vm, relative to your remote_datastore.
	//
	// This option's default value is your `vm_name`, and the final path of your
	// vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where
	// `$remote_datastore` and `$vm_name` match their corresponding template
	// options
	//
	// For example, setting `"remote_output_directory": "path/to/subdir`
	// will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`.
	//
	// Packer will not create the remote datastore for you; it must already
	// exist. However, Packer will create all directories defined in the option
	// that do not currently exist.
	//
	// This option will be ignored unless you are building on a remote hypervisor.
	RemoteOutputDir string `mapstructure:"remote_output_directory" required:"false"`
}

func (*OutputConfig) Prepare

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

type OutputDir

type OutputDir interface {
	DirExists() (bool, error)
	ListFiles() ([]string, error)
	MkdirAll() error
	Remove(string) error
	RemoveAll() error
	SetOutputDir(string)
	String() string
}

OutputDir is an interface type that abstracts the creation and handling of the output directory for VMware-based products. The abstraction is made so that the output directory can be properly made on remote (ESXi) based VMware products as well as local. For remote builds, OutputDir interface is satisfied by the ESX5Driver.

type ParallelPortAuto

type ParallelPortAuto struct {
	Bidirectional string
}

type ParallelPortDevice

type ParallelPortDevice struct {
	Bidirectional string
	Devicename    string
}

type ParallelPortFile

type ParallelPortFile struct {
	Filename string
}

type ParallelUnion

type ParallelUnion struct {
	Union  interface{}
	File   *ParallelPortFile
	Device *ParallelPortDevice
	Auto   *ParallelPortAuto
}

type Player5Driver

type Player5Driver struct {
	VmwareDriver

	AppPath          string
	VdiskManagerPath string
	QemuImgPath      string
	VmrunPath        string

	// SSHConfig are the SSH settings for the Fusion VM
	SSHConfig *SSHConfig
}

Player5Driver is a driver that can run VMware Player 5 on Linux.

func (*Player5Driver) Clone

func (d *Player5Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Player5Driver) CommHost

func (d *Player5Driver) CommHost(state multistep.StateBag) (string, error)

func (*Player5Driver) CompactDisk

func (d *Player5Driver) CompactDisk(diskPath string) error

func (*Player5Driver) CreateDisk

func (d *Player5Driver) CreateDisk(output string, size string, adapter_type string, type_id string) error

func (*Player5Driver) CreateSnapshot added in v1.0.0

func (d *Player5Driver) CreateSnapshot(vmxPath string, snapshotName string) error

func (*Player5Driver) GetVmwareDriver

func (d *Player5Driver) GetVmwareDriver() VmwareDriver

func (*Player5Driver) IsRunning

func (d *Player5Driver) IsRunning(vmxPath string) (bool, error)

func (*Player5Driver) Start

func (d *Player5Driver) Start(vmxPath string, headless bool) error

func (*Player5Driver) Stop

func (d *Player5Driver) Stop(vmxPath string) error

func (*Player5Driver) SuppressMessages

func (d *Player5Driver) SuppressMessages(vmxPath string) error

func (*Player5Driver) ToolsInstall

func (d *Player5Driver) ToolsInstall() error

func (*Player5Driver) ToolsIsoPath

func (d *Player5Driver) ToolsIsoPath(flavor string) string

func (*Player5Driver) Verify

func (d *Player5Driver) Verify() error

type Player6Driver

type Player6Driver struct {
	Player5Driver
}

func (*Player6Driver) Clone

func (d *Player6Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Player6Driver) GetVmwareDriver

func (d *Player6Driver) GetVmwareDriver() VmwareDriver

func (*Player6Driver) Verify

func (d *Player6Driver) Verify() error

type RemoteDriver

type RemoteDriver interface {
	Driver

	// UploadISO uploads a local ISO to the remote side and returns the
	// new path that should be used in the VMX along with an error if it
	// exists.
	UploadISO(path string, checksum string, ui packersdk.Ui) (string, error)

	// RemoveCache deletes localPath from the remote cache.
	RemoveCache(localPath string) error

	// Adds a VM to inventory specified by the path to the VMX given.
	Register(path string) error

	// Removes a VM from inventory specified by the path to the VMX given.
	Unregister(path string) error

	// Destroys a VM
	Destroy() error

	// Checks if the VM is destroyed.
	IsDestroyed() (bool, error)

	// Download a remote file to a local file.
	Download(src, dst string) error

	// Reload VM on remote side.
	ReloadVM() error
	// contains filtered or unexported methods
}

type RemoteDriverMock

type RemoteDriverMock struct {
	DriverMock

	UploadISOCalled bool
	UploadISOPath   string
	UploadISOResult string
	UploadISOErr    error

	RegisterCalled bool
	RegisterPath   string
	RegisterErr    error

	UnregisterCalled bool
	UnregisterPath   string
	UnregisterErr    error

	DestroyCalled bool
	DestroyErr    error

	IsDestroyedCalled bool
	IsDestroyedResult bool
	IsDestroyedErr    error

	UploadErr   error
	DownloadErr error

	RemovedCachePath string
	CacheRemoved     bool

	ReturnValDirExists bool

	ReloadVMErr error
	// contains filtered or unexported fields
}

func (*RemoteDriverMock) Destroy

func (d *RemoteDriverMock) Destroy() error

func (*RemoteDriverMock) DirExists

func (d *RemoteDriverMock) DirExists() (bool, error)

func (*RemoteDriverMock) Download

func (d *RemoteDriverMock) Download(src, dst string) error

func (*RemoteDriverMock) IsDestroyed

func (d *RemoteDriverMock) IsDestroyed() (bool, error)

func (*RemoteDriverMock) ListFiles

func (d *RemoteDriverMock) ListFiles() ([]string, error)

func (*RemoteDriverMock) MkdirAll

func (d *RemoteDriverMock) MkdirAll() error

func (*RemoteDriverMock) Register

func (d *RemoteDriverMock) Register(path string) error

func (*RemoteDriverMock) ReloadVM

func (d *RemoteDriverMock) ReloadVM() error

func (*RemoteDriverMock) Remove

func (d *RemoteDriverMock) Remove(string) error

func (*RemoteDriverMock) RemoveAll

func (d *RemoteDriverMock) RemoveAll() error

func (*RemoteDriverMock) RemoveCache

func (d *RemoteDriverMock) RemoveCache(localPath string) error

func (*RemoteDriverMock) SetOutputDir

func (d *RemoteDriverMock) SetOutputDir(s string)

func (*RemoteDriverMock) String

func (d *RemoteDriverMock) String() string

func (*RemoteDriverMock) Unregister

func (d *RemoteDriverMock) Unregister(path string) error

func (*RemoteDriverMock) UploadISO

func (d *RemoteDriverMock) UploadISO(path string, checksum string, ui packersdk.Ui) (string, error)

type RunConfig

type RunConfig struct {
	// The plugin defaults to building virtual machines by launching the
	// desktop hypervisor's graphical user interface (GUI) to display the
	// console of the virtual machine being built. When this value is set to
	// `true`, the virtual machine will start without a console; however, the
	// plugin will output VNC connection information in case you need to connect
	// to the console to debug the build process. Defaults to `false`.
	//
	// ~> **Note:** Some users have experienced issues where Packer cannot
	// properly connect to a virtual machine when using `headless`. This is
	// often attributed to the use of an evaluation license for VMware desktop
	// hypervisors. It is recommended to launch the product and accept the
	// evaluation license to resolve this if you encounter an issue with this
	// option.
	Headless bool `mapstructure:"headless" required:"false"`
	// The IP address to use for VNC access to the virtual machine. Defaults to
	// `127.0.0.1`.
	//
	// ~> **Note:** To bind to all interfaces use `0.0.0.0`.
	VNCBindAddress string `mapstructure:"vnc_bind_address" required:"false"`
	// The minimum port number to use for VNC access to the virtual machine.
	// The plugin uses VNC to type the `boot_command`. Defaults to `5900`.
	VNCPortMin int `mapstructure:"vnc_port_min" required:"false"`
	// The maximum port number to use for VNC access to the virtual machine.
	// The plugin uses VNC to type the `boot_command`. Defaults to `6000`.
	//
	// ~> **Note:** The plugin randomly selects port within the inclusive range
	// specified by `vnc_port_min` and `vnc_port_max`.
	VNCPortMax int `mapstructure:"vnc_port_max"`
	// Disables the auto-generation of a VNC password that is used to secure the
	// VNC communication with the virtual machine. Defaults to `false`.
	//
	// ~> **Important:** Must be set to `true` for remote hypervisor builds with
	// VNC enabled.
	VNCDisablePassword bool `mapstructure:"vnc_disable_password" required:"false"`
	// Connect to VNC over a websocket connection. Defaults to `false`.
	//
	// ~> **Note:** When set to `true`, any other VNC configuration options will
	// be ignored.
	//
	// ~> **Important:** Must be set to `true` for remote hypervisor builds with
	// VNC enabled.
	VNCOverWebsocket bool `mapstructure:"vnc_over_websocket" required:"false"`
	// Do not validate TLS certificate when connecting to VNC over a websocket
	// connection. Defaults to `false`.
	InsecureConnection bool `mapstructure:"insecure_connection" required:"false"`
}

func (*RunConfig) Prepare

func (c *RunConfig) Prepare(_ *interpolate.Context, driverConfig *DriverConfig) (warnings []string, errs []error)

type SSHConfig

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

	// TODO: Deprecated. Remove in next major release
	SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"`
}

func (*SSHConfig) Prepare

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

type SerialConfigAuto

type SerialConfigAuto struct {
	Devicename string
	Yield      string
}

type SerialConfigDevice

type SerialConfigDevice struct {
	Devicename string
	Yield      string
}

type SerialConfigFile

type SerialConfigFile struct {
	Filename string
	Yield    string
}

type SerialConfigPipe

type SerialConfigPipe struct {
	Filename string
	Endpoint string
	Host     string
	Yield    string
}

type SerialUnion

type SerialUnion struct {
	Union  interface{}
	Pipe   *SerialConfigPipe
	File   *SerialConfigFile
	Device *SerialConfigDevice
	Auto   *SerialConfigAuto
}

type StepCleanFiles

type StepCleanFiles struct{}

This step removes unnecessary files from the final result.

Uses: dir OutputDir ui packersdk.Ui

Produces: <nothing>

func (StepCleanFiles) Cleanup

func (StepCleanFiles) Run

type StepCleanVMX

type StepCleanVMX struct {
	RemoveEthernetInterfaces bool
	VNCEnabled               bool
}

StepCleanVMX cleans up the VMX by removing or changing this prior to being ready for use.

func (StepCleanVMX) Cleanup

func (StepCleanVMX) Cleanup(multistep.StateBag)

func (StepCleanVMX) Run

type StepCompactDisk

type StepCompactDisk struct {
	Skip bool
}

This step compacts the virtual disk for the VM unless the "skip_compaction" boolean is true.

Uses: driver Driver disk_full_paths ([]string) - The full paths to all created disks ui packersdk.Ui

Produces: <nothing>

func (StepCompactDisk) Cleanup

func (StepCompactDisk) Run

type StepConfigureVMX

type StepConfigureVMX struct {
	CustomData       map[string]string
	DisplayName      string
	SkipDevices      bool
	VMName           string
	DiskAdapterType  string
	CDROMAdapterType string
}

This step configures a VMX by setting some default settings as well as taking in custom data to set, attaching a floppy if it exists, etc.

Uses: vmx_path string Produces: display_name string - Value of the displayName key set in the VMX file

func (*StepConfigureVMX) Cleanup

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

func (*StepConfigureVMX) Run

type StepConfigureVNC

type StepConfigureVNC struct {
	Enabled            bool
	VNCBindAddress     string
	VNCPortMin         int
	VNCPortMax         int
	VNCDisablePassword bool
	// contains filtered or unexported fields
}

func (*StepConfigureVNC) Cleanup

func (s *StepConfigureVNC) Cleanup(multistep.StateBag)

func (*StepConfigureVNC) Run

func (*StepConfigureVNC) UpdateVMX

func (*StepConfigureVNC) UpdateVMX(address, password string, port int, data map[string]string)

func (*StepConfigureVNC) VNCAddress

func (s *StepConfigureVNC) VNCAddress(ctx context.Context, vncBindAddress string, portMin, portMax int) (string, int, error)

type StepCreateDisks

type StepCreateDisks struct {
	OutputDir          *string
	CreateMainDisk     bool
	DiskName           string
	MainDiskSize       uint
	AdditionalDiskSize []uint
	DiskAdapterType    string
	DiskTypeId         string
}

StepCreateDisks creates the virtual disks for the VM.

func (*StepCreateDisks) Cleanup

func (s *StepCreateDisks) Cleanup(multistep.StateBag)

func (*StepCreateDisks) Run

type StepCreateSnapshot added in v1.0.0

type StepCreateSnapshot struct {
	SnapshotName *string
}

StepCreateSnapshot step creates a snapshot for the virtual machine after the build has been completed.

func (*StepCreateSnapshot) Cleanup added in v1.0.0

func (*StepCreateSnapshot) Run added in v1.0.0

type StepExport

type StepExport struct {
	Format         string
	SkipExport     bool
	VMName         string
	OVFToolOptions []string
	OutputDir      *string
}

This step exports a VM built on ESXi using ovftool

func (*StepExport) Cleanup

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

func (*StepExport) Run

type StepHTTPIPDiscover

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

func (*StepHTTPIPDiscover) Run

type StepOutputDir

type StepOutputDir struct {
	Force bool

	OutputConfig *OutputConfig
	VMName       string

	RemoteType 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

func (*StepOutputDir) SetOutputAndExportDirs

func (s *StepOutputDir) SetOutputAndExportDirs(state multistep.StateBag) OutputDir

type StepPrepareTools

type StepPrepareTools struct {
	RemoteType        string
	ToolsUploadFlavor string
	ToolsSourcePath   string
}

func (*StepPrepareTools) Cleanup

func (c *StepPrepareTools) Cleanup(multistep.StateBag)

func (*StepPrepareTools) Run

type StepRegister

type StepRegister struct {
	Format         string
	KeepRegistered bool
	SkipExport     bool
	// contains filtered or unexported fields
}

func (*StepRegister) Cleanup

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

func (*StepRegister) Run

type StepRemoteUpload

type StepRemoteUpload struct {
	Key       string
	Message   string
	DoCleanup bool
	Checksum  string
}

stepRemoteUpload uploads some thing from the state bag to a remote driver (if it can) and stores that new remote path into the state bag.

func (*StepRemoteUpload) Cleanup

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

func (*StepRemoteUpload) Run

type StepRun

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

StepRun runs the created virtual machine.

func (*StepRun) Cleanup

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

func (*StepRun) Run

type StepShutdown

type StepShutdown struct {
	Command string
	Timeout time.Duration

	// Set this to true if we're testing
	Testing bool
}

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

func (*StepShutdown) Cleanup

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

func (*StepShutdown) Run

type StepSuppressMessages

type StepSuppressMessages struct{}

This step suppresses any messages that VMware product might show.

func (*StepSuppressMessages) Cleanup

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

func (*StepSuppressMessages) Run

type StepUploadTools

type StepUploadTools struct {
	RemoteType        string
	ToolsUploadFlavor string
	ToolsUploadPath   string
	Ctx               interpolate.Context
}

func (*StepUploadTools) Cleanup

func (c *StepUploadTools) Cleanup(multistep.StateBag)

func (*StepUploadTools) Run

type StepUploadVMX

type StepUploadVMX struct {
	RemoteType string
}

StepUploadVMX upload the VMX to the remote host

func (StepUploadVMX) Cleanup

func (StepUploadVMX) Cleanup(multistep.StateBag)

func (*StepUploadVMX) Run

type StepVNCBootCommand

type StepVNCBootCommand struct {
	Config bootcommand.VNCConfig
	VMName string
	Ctx    interpolate.Context
	Comm   *communicator.Config
}

StepVNCBootCommand "types" the boot command into the VM over VNC.

func (*StepVNCBootCommand) Cleanup

func (*StepVNCBootCommand) Run

type StepVNCConnect

type StepVNCConnect struct {
	VNCEnabled         bool
	VNCOverWebsocket   bool
	InsecureConnection bool
	DriverConfig       *DriverConfig
}

func (*StepVNCConnect) Cleanup

func (s *StepVNCConnect) Cleanup(multistep.StateBag)

func (*StepVNCConnect) ConnectVNC

func (s *StepVNCConnect) ConnectVNC(state multistep.StateBag) (*vnc.ClientConn, error)

func (*StepVNCConnect) ConnectVNCOverWebsocketClient

func (s *StepVNCConnect) ConnectVNCOverWebsocketClient(state multistep.StateBag) (*vnc.ClientConn, error)

func (*StepVNCConnect) Run

type ToolsConfig

type ToolsConfig struct {
	// The flavor of VMware tools to upload into the virtual machine based on
	// the guest operating system. Allowed values are `darwin` (macOS), `linux`,
	// and `windows`. Default is empty and no version will be uploaded.
	ToolsUploadFlavor string `mapstructure:"tools_upload_flavor" required:"false"`
	// The path in the virtual machine to upload the VMware Tools. This only
	// takes effect if `tools_upload_flavor` is non-empty. This is a
	// [configuration template](/packer/docs/templates/legacy_json_templates/engine)
	// that has a single valid variable, `Flavor`, which will be the value of
	// `tools_upload_flavor` when the upload path is set to `{{.Flavor}}.iso`.
	//
	// ~> **Note:** This setting is not used when `remote_type` is `esx5`.
	ToolsUploadPath string `mapstructure:"tools_upload_path" required:"false"`
	// The local path on your machine to the VMware Tools ISO file.
	//
	// ~> **Note:** If not set, but the `tools_upload_flavor` is set, the plugin
	// will load the VMware Tools from the product installation directory.
	ToolsSourcePath string `mapstructure:"tools_source_path" required:"false"`
}

func (*ToolsConfig) Prepare

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

type VMXConfig

type VMXConfig struct {
	// Key-value pairs that will be inserted into the virtual machine `.vmx`
	// file **before** the virtual machine is started. This is useful for
	// setting advanced properties that are not supported by the plugin.
	//
	// ~> **Note**: This option is intended for advanced users who understand
	// the ramifications of making changes to the `.vmx` file. This option is
	// not necessary for most users.
	VMXData map[string]string `mapstructure:"vmx_data" required:"false"`
	// Key-value pairs that will be inserted into the virtual machine `.vmx`
	// file **after** the virtual machine is started. This is useful for setting
	// advanced properties that are not supported by the plugin.
	//
	// ~> **Note**: This option is intended for advanced users who understand
	// the ramifications of making changes to the `.vmx` file. This option is
	// not necessary for most users.
	VMXDataPost map[string]string `mapstructure:"vmx_data_post" required:"false"`
	// Remove all network adapters from virtual machine `.vmx` file after the
	// virtual machine build is complete. Defaults to `false`.
	//
	// ~> **Note**: This option is useful when building Vagrant boxes since
	// Vagrant will create interfaces when provisioning a box.
	VMXRemoveEthernet bool `mapstructure:"vmx_remove_ethernet_interfaces" required:"false"`
	// The inventory display name for the virtual machine. If set, the value
	// provided will override any value set in the `vmx_data` option or in the
	// `.vmx` file. This option is useful if you are chaining builds and want to
	// ensure that the display name of each step in the chain is unique.
	VMXDisplayName string `mapstructure:"display_name" required:"false"`
}

func (*VMXConfig) Prepare

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

type VNCAddressFinder

type VNCAddressFinder interface {
	VNCAddress(context.Context, string, int, int) (string, int, error)

	// UpdateVMX, sets driver specific VNC values to VMX data.
	UpdateVMX(vncAddress, vncPassword string, vncPort int, vmxData map[string]string)
}

type VNCBootCommandTemplateData

type VNCBootCommandTemplateData struct {
	HTTPIP       string
	HTTPPort     int
	Name         string
	SSHPublicKey string
}

type VmwareDriver

type VmwareDriver struct {
	/// These methods define paths that are utilized by the driver
	/// A driver must overload these in order to point to the correct
	/// files so that the address detection (ip and ethernet) machinery
	/// works.
	DhcpLeasesPath   func(string) string
	DhcpConfPath     func(string) string
	VmnetnatConfPath func(string) string

	/// This method returns an object with the NetworkNameMapper interface
	/// that maps network to device and vice-versa.
	NetworkMapper func() (NetworkNameMapper, error)
}

This VmwareDriver is a base class that contains default methods that a Driver can use or implement themselves.

func (*VmwareDriver) Export

func (d *VmwareDriver) Export(args []string) error

func (*VmwareDriver) GuestAddress

func (d *VmwareDriver) GuestAddress(state multistep.StateBag) (string, error)

func (*VmwareDriver) HostAddress

func (d *VmwareDriver) HostAddress(state multistep.StateBag) (string, error)

func (*VmwareDriver) HostIP

func (d *VmwareDriver) HostIP(state multistep.StateBag) (string, error)

func (*VmwareDriver) PotentialGuestIP

func (d *VmwareDriver) PotentialGuestIP(state multistep.StateBag) ([]string, error)

func (*VmwareDriver) VerifyOvfTool

func (d *VmwareDriver) VerifyOvfTool(SkipExport, _ bool) error

type Workstation10Driver

type Workstation10Driver struct {
	Workstation9Driver
}

func (*Workstation10Driver) Clone

func (d *Workstation10Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Workstation10Driver) GetVmwareDriver

func (d *Workstation10Driver) GetVmwareDriver() VmwareDriver

func (*Workstation10Driver) Verify

func (d *Workstation10Driver) Verify() error

type Workstation9Driver

type Workstation9Driver struct {
	VmwareDriver

	AppPath          string
	VdiskManagerPath string
	VmrunPath        string

	// SSHConfig are the SSH settings for the Fusion VM
	SSHConfig *SSHConfig
}

Workstation9Driver is a driver that can run VMware Workstation 9

func (*Workstation9Driver) Clone

func (d *Workstation9Driver) Clone(dst, src string, linked bool, snapshot string) error

func (*Workstation9Driver) CommHost

func (d *Workstation9Driver) CommHost(state multistep.StateBag) (string, error)

func (*Workstation9Driver) CompactDisk

func (d *Workstation9Driver) CompactDisk(diskPath string) error

func (*Workstation9Driver) CreateDisk

func (d *Workstation9Driver) CreateDisk(output string, size string, adapter_type string, type_id string) error

func (*Workstation9Driver) CreateSnapshot added in v1.0.0

func (d *Workstation9Driver) CreateSnapshot(vmxPath string, snapshotName string) error

func (*Workstation9Driver) GetVmwareDriver

func (d *Workstation9Driver) GetVmwareDriver() VmwareDriver

func (*Workstation9Driver) IsRunning

func (d *Workstation9Driver) IsRunning(vmxPath string) (bool, error)

func (*Workstation9Driver) Start

func (d *Workstation9Driver) Start(vmxPath string, headless bool) error

func (*Workstation9Driver) Stop

func (d *Workstation9Driver) Stop(vmxPath string) error

func (*Workstation9Driver) SuppressMessages

func (d *Workstation9Driver) SuppressMessages(vmxPath string) error

func (*Workstation9Driver) ToolsInstall

func (d *Workstation9Driver) ToolsInstall() error

func (*Workstation9Driver) ToolsIsoPath

func (d *Workstation9Driver) ToolsIsoPath(flavor string) string

func (*Workstation9Driver) Verify

func (d *Workstation9Driver) Verify() error

Jump to

Keyboard shortcuts

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