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: 45 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 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 CommHost added in v0.8.0

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.3.3

func GetOVFTool() string

func MockInterface added in v1.2.0

func MockInterface() net.Interface

func NetworkingParserByCommand added in v1.2.0

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

func NewArtifact added in v1.3.3

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 added in v1.6.6

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

func ReadDhcpdLeaseEntries added in v1.6.0

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 added in v0.11.0

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 added in v1.2.0

type DhcpConfiguration []configDeclaration

** Dhcp Configuration

func ReadDhcpConfig added in v1.2.0

func ReadDhcpConfig(path string) (DhcpConfiguration, error)

read the dhcp configuration out of the specified path

func ReadDhcpConfiguration added in v1.2.0

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

func (*DhcpConfiguration) Global added in v1.2.0

func (e *DhcpConfiguration) Global() configDeclaration

func (*DhcpConfiguration) HostByName added in v1.2.0

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

func (*DhcpConfiguration) SubnetByAddress added in v1.2.0

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

type DiskAndCDConfigData added in v1.6.3

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 added in v1.6.3

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 added in v1.6.2

type DiskConfig struct {
	// The size(s) of any additional
	// hard disks for the VM in megabytes. If this is not specified then the VM
	// will only contain a primary hard disk. The builder uses expandable, not
	// fixed-size virtual hard disks, so the actual file representing the disk will
	// not use the full size unless it is full.
	AdditionalDiskSize []uint `mapstructure:"disk_additional_size" required:"false"`
	// The adapter type of the VMware virtual disk to create. This option is
	// for advanced usage, modify only if you know what you're doing. Some of
	// the options you can specify are `ide`, `sata`, `nvme` or `scsi` (which
	// uses the "lsilogic" scsi interface by default). If you specify another
	// option, Packer will assume that you're specifying a `scsi` interface of
	// that specified type. For more information, please consult [Virtual Disk
	// Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf)
	// for desktop VMware clients. For ESXi, refer to the proper ESXi
	// documentation.
	DiskAdapterType string `mapstructure:"disk_adapter_type" required:"false"`
	// The filename of the virtual disk that'll be created,
	// without the extension. This defaults to "disk".
	DiskName string `mapstructure:"vmdk_name" required:"false"`
	// The type of VMware virtual disk to create. This
	// option is for advanced usage.
	//
	//   For desktop VMware clients:
	//
	//   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 ESX server (VMFS flat).
	//   `5`     | Compressed disk optimized for streaming.
	//
	//   The default is `1`.
	//
	//   For ESXi, this defaults to `zeroedthick`. The available options for ESXi
	//   are: `zeroedthick`, `eagerzeroedthick`, `thin`. `rdm:dev`, `rdmp:dev`,
	//   `2gbsparse` are not supported. Due to default disk compaction, when using
	//   `zeroedthick` or `eagerzeroedthick` set `skip_compaction` to `true`.
	//
	//   For more information, please consult the [Virtual Disk Manager User's
	//   Guide](https://www.vmware.com/pdf/VirtualDiskManager.pdf) for desktop
	//   VMware clients. For ESXi, refer to the proper ESXi documentation.
	DiskTypeId string `mapstructure:"disk_type_id" required:"false"`
}

func (*DiskConfig) Prepare added in v1.6.2

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

	// 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 added in v1.6.3

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

func NewFusion5Driver added in v1.6.3

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

func NewFusion6Driver added in v1.6.3

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

func NewPlayer5Driver added in v1.6.3

func NewPlayer5Driver(config *SSHConfig) Driver

func NewPlayer6Driver added in v1.6.3

func NewPlayer6Driver(config *SSHConfig) Driver

func NewWorkstation10Driver added in v1.6.3

func NewWorkstation10Driver(config *SSHConfig) Driver

func NewWorkstation9Driver added in v1.6.3

func NewWorkstation9Driver(config *SSHConfig) Driver

type DriverConfig

type DriverConfig struct {
	// 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"`
	// 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"`
	// 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 esxi 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 added in v1.3.3

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

	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 added in v0.8.0

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) DhcpConfPath added in v1.2.0

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

func (*DriverMock) DhcpLeasesPath

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

func (*DriverMock) Export added in v1.6.2

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

func (*DriverMock) GetVmwareDriver added in v1.2.0

func (d *DriverMock) GetVmwareDriver() VmwareDriver

func (*DriverMock) GuestAddress added in v1.2.0

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

func (*DriverMock) HostAddress added in v1.2.0

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

func (*DriverMock) HostIP added in v1.2.0

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

func (*DriverMock) IsRunning

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

func (*DriverMock) NetmapConfPath added in v1.2.0

func (d *DriverMock) NetmapConfPath() string

func (*DriverMock) PotentialGuestIP added in v1.6.0

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 added in v0.6.0

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 added in v1.6.3

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

func (*DriverMock) VmnetnatConfPath added in v1.2.0

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

type ESX5Driver added in v1.3.3

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 added in v1.6.3

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

func (*ESX5Driver) CachePath added in v1.3.3

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

func (*ESX5Driver) Clone added in v1.3.3

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

func (*ESX5Driver) CommHost added in v1.3.3

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

func (*ESX5Driver) CompactDisk added in v1.3.3

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

func (*ESX5Driver) CreateDisk added in v1.3.3

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

func (*ESX5Driver) Destroy added in v1.3.3

func (d *ESX5Driver) Destroy() error

func (*ESX5Driver) DirExists added in v1.3.3

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

func (*ESX5Driver) Download added in v1.3.3

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

func (*ESX5Driver) Export added in v1.6.2

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

func (*ESX5Driver) GetVmwareDriver added in v1.3.3

func (d *ESX5Driver) GetVmwareDriver() VmwareDriver

func (*ESX5Driver) GuestAddress added in v1.3.3

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

func (*ESX5Driver) HostAddress added in v1.3.3

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

func (*ESX5Driver) HostIP added in v1.3.3

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

func (*ESX5Driver) IsDestroyed added in v1.3.3

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

func (*ESX5Driver) IsRunning added in v1.3.3

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

func (*ESX5Driver) ListFiles added in v1.3.3

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

func (*ESX5Driver) MkdirAll added in v1.3.3

func (d *ESX5Driver) MkdirAll() error

func (*ESX5Driver) PotentialGuestIP added in v1.6.0

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

func (*ESX5Driver) Register added in v1.3.3

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

func (*ESX5Driver) ReloadVM added in v1.3.3

func (d *ESX5Driver) ReloadVM() error

func (*ESX5Driver) Remove added in v1.3.3

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

func (*ESX5Driver) RemoveAll added in v1.3.3

func (d *ESX5Driver) RemoveAll() error

func (*ESX5Driver) RemoveCache added in v1.3.3

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

func (*ESX5Driver) SetOutputDir added in v1.3.3

func (d *ESX5Driver) SetOutputDir(path string)

func (*ESX5Driver) Start added in v1.3.3

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

func (*ESX5Driver) Stop added in v1.3.3

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

func (*ESX5Driver) String added in v1.3.3

func (d *ESX5Driver) String() string

func (*ESX5Driver) SuppressMessages added in v1.3.3

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

func (*ESX5Driver) ToolsInstall added in v1.3.3

func (d *ESX5Driver) ToolsInstall() error

func (*ESX5Driver) ToolsIsoPath added in v1.3.3

func (d *ESX5Driver) ToolsIsoPath(string) string

func (*ESX5Driver) Unregister added in v1.3.3

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

func (ESX5Driver) UpdateVMX added in v1.3.3

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

UpdateVMX, adds the VNC port to the VMX data.

func (*ESX5Driver) UploadISO added in v1.3.3

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

func (*ESX5Driver) VNCAddress added in v1.3.3

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

func (*ESX5Driver) Verify added in v1.3.3

func (d *ESX5Driver) Verify() error

func (*ESX5Driver) VerifyChecksum added in v1.3.3

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

VerifyChecksum checks that file on the esxi instance matches hash

func (*ESX5Driver) VerifyOvfTool added in v1.6.3

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

type ExportConfig added in v1.3.3

type ExportConfig struct {
	// Either "ovf", "ova" or "vmx", this specifies the output
	// format of the exported virtual machine. This defaults to "ovf" for
	// remote (esx) builds, and "vmx" for local builds.
	// Before using this option, you need to install ovftool.
	// Since ovftool is only capable of password based authentication
	// remote_password must be set when exporting the VM from a remote instance.
	// If you are building locally, Packer will create a vmx and then
	// export that vm to an ovf or ova. Packer will not delete the vmx and vmdk
	// files; this is left up to the user if you don't want to keep those
	// files.
	Format string `mapstructure:"format" required:"false"`
	// Extra options to pass to ovftool during export. Each item in the array
	// is a new argument. The options `--noSSLVerify`, `--skipManifestCheck`,
	// and `--targetType` are used by Packer for remote exports, and should not
	// be passed to this argument. For ovf/ova exports from local builds, Packer
	// does not automatically set any ovftool options.
	OVFToolOptions []string `mapstructure:"ovftool_options" required:"false"`
	// Defaults to `false`. When true, Packer will not export the VM. This can
	// be useful if the build output is not the resultant image, but created
	// inside the VM.
	SkipExport bool `mapstructure:"skip_export" required:"false"`
	// Set this to true if you would like to keep a remotely-built
	// VM registered with the remote ESXi server. If you do not need to export
	// the vm, then also set `skip_export: true` in order to avoid unnecessarily
	// using ovftool to export the vm. Defaults to false.
	KeepRegistered bool `mapstructure:"keep_registered" required:"false"`
	// VMware-created disks are defragmented and
	// compacted at the end of the build process using vmware-vdiskmanager or
	// vmkfstools in ESXi. In certain rare cases, this might actually end up
	// making the resulting disks slightly larger. If you find this to be the case,
	// you can disable compaction using this configuration value. Defaults to
	// false. Default to true for ESXi when disk_type_id is not explicitly
	// defined and false otherwise.
	SkipCompaction bool `mapstructure:"skip_compaction" required:"false"`
}

func (*ExportConfig) Prepare added in v1.3.3

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 added in v0.8.0

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) GetVmwareDriver added in v1.2.0

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 added in v0.6.0

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 added in v1.2.0

func (d *Fusion6Driver) GetVmwareDriver() VmwareDriver

func (*Fusion6Driver) Verify

func (d *Fusion6Driver) Verify() error

type HWConfig added in v1.3.3

type HWConfig struct {
	// The number of cpus to use when building the VM.
	CpuCount int `mapstructure:"cpus" required:"false"`
	// The amount of memory to use when building the VM in megabytes.
	MemorySize int `mapstructure:"memory" required:"false"`
	// The number of cores per socket to use when building the VM. This
	// corresponds to the cpuid.coresPerSocket option in the .vmx file.
	CoreCount int `mapstructure:"cores" required:"false"`
	// This is the network type that the virtual machine will be created with.
	// This can be one of the generic values that map to a device such as
	// hostonly, nat, or bridged. If the network is not one of these values,
	// then it is assumed to be a VMware network device. (VMnet0..x)
	Network string `mapstructure:"network" required:"false"`
	// This is the ethernet adapter type the the virtual machine will be
	// created with. By default the `e1000` network adapter type will be used
	// by Packer. For more information, please consult [Choosing a network
	// adapter for your virtual
	// machine](https://kb.vmware.com/s/article/1001805) for desktop VMware
	// clients. For ESXi, refer to the proper ESXi documentation.
	NetworkAdapterType string `mapstructure:"network_adapter_type" required:"false"`
	// The custom name of the network. Sets the vmx value "ethernet0.networkName"
	NetworkName string `mapstructure:"network_name" required:"false"`
	// Specify whether to enable VMware's virtual soundcard device when
	// building the VM. Defaults to false.
	Sound bool `mapstructure:"sound" required:"false"`
	// Enable VMware's USB bus when building the guest VM. Defaults to false.
	// To enable usage of the XHCI bus for USB 3 (5 Gbit/s), one can use the
	// vmx_data option to enable it by specifying true for the usb_xhci.present
	// property.
	USB bool `mapstructure:"usb" required:"false"`
	// This specifies a serial port to add to the VM. It has a format of
	// `Type:option1,option2,...`. The field `Type` can be one of the following
	// values: `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 vm 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 vm 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 vm 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 VM should
	//   support the serial port.
	//
	//   * `yield` (bool) - This is an optional boolean that specifies
	//     whether the vm 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"`
	// This specifies a parallel port to add to the VM. It has the format of
	// `Type:option1,option2,...`. Type can be one of the following values:
	// `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 added in v1.3.3

func (c *HWConfig) HasParallel() bool

func (*HWConfig) HasSerial added in v1.3.3

func (c *HWConfig) HasSerial() bool

func (*HWConfig) Prepare added in v1.3.3

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

func (*HWConfig) ReadParallel added in v1.3.3

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

func (*HWConfig) ReadSerial added in v1.3.3

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

type IfconfigIPFinder added in v0.7.0

type IfconfigIPFinder struct {
	Device string
}

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

func (*IfconfigIPFinder) HostIP added in v0.7.0

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 NetworkMap added in v1.2.0

type NetworkMap []map[string]string

** Network Map

func ReadNetmapConfig added in v1.2.0

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 added in v1.2.0

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

func (NetworkMap) DeviceIntoName added in v1.2.0

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

func (NetworkMap) NameIntoDevices added in v1.2.2

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

type NetworkMapperMock added in v1.2.0

type NetworkMapperMock struct {
	NameIntoDeviceCalled int
	DeviceIntoNameCalled int
}

func (NetworkMapperMock) DeviceIntoName added in v1.2.0

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

func (NetworkMapperMock) NameIntoDevices added in v1.2.2

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

type NetworkNameMapper added in v1.2.0

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

type NetworkingConfig added in v1.2.0

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

func ReadNetworkingConfig added in v1.2.0

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

Constructor for networking file

func (NetworkingConfig) DeviceIntoName added in v1.2.0

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

func (NetworkingConfig) NameIntoDevices added in v1.2.2

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

type NetworkingType added in v1.2.0

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 esx 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 directoy on your remote esx host 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 esx host.
	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 added in v1.3.3

type ParallelPortAuto struct {
	Bidirectional string
}

type ParallelPortDevice added in v1.3.3

type ParallelPortDevice struct {
	Bidirectional string
	Devicename    string
}

type ParallelPortFile added in v1.3.3

type ParallelPortFile struct {
	Filename string
}

type ParallelUnion added in v1.3.3

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

parallel port

type Player5Driver added in v0.7.0

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 added in v0.7.0

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

func (*Player5Driver) CommHost added in v0.8.0

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

func (*Player5Driver) CompactDisk added in v0.7.0

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

func (*Player5Driver) CreateDisk added in v0.7.0

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

func (*Player5Driver) GetVmwareDriver added in v1.2.0

func (d *Player5Driver) GetVmwareDriver() VmwareDriver

func (*Player5Driver) IsRunning added in v0.7.0

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

func (*Player5Driver) Start added in v0.7.0

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

func (*Player5Driver) Stop added in v0.7.0

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

func (*Player5Driver) SuppressMessages added in v0.7.0

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

func (*Player5Driver) ToolsInstall added in v0.7.0

func (d *Player5Driver) ToolsInstall() error

func (*Player5Driver) ToolsIsoPath added in v0.7.0

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

func (*Player5Driver) Verify added in v0.7.0

func (d *Player5Driver) Verify() error

type Player6Driver added in v0.7.0

type Player6Driver struct {
	Player5Driver
}

func (*Player6Driver) Clone added in v0.7.0

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

func (*Player6Driver) GetVmwareDriver added in v1.2.0

func (d *Player6Driver) GetVmwareDriver() VmwareDriver

func (*Player6Driver) Verify added in v0.7.0

func (d *Player6Driver) Verify() error

type RemoteDriver added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

func (d *RemoteDriverMock) Destroy() error

func (*RemoteDriverMock) DirExists added in v1.6.2

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

func (*RemoteDriverMock) Download added in v1.3.3

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

func (*RemoteDriverMock) IsDestroyed added in v1.3.3

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

func (*RemoteDriverMock) ListFiles added in v1.6.2

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

func (*RemoteDriverMock) MkdirAll added in v1.6.2

func (d *RemoteDriverMock) MkdirAll() error

func (*RemoteDriverMock) Register added in v1.3.3

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

func (*RemoteDriverMock) ReloadVM added in v1.3.3

func (d *RemoteDriverMock) ReloadVM() error

func (*RemoteDriverMock) Remove added in v1.6.2

func (d *RemoteDriverMock) Remove(string) error

func (*RemoteDriverMock) RemoveAll added in v1.6.2

func (d *RemoteDriverMock) RemoveAll() error

func (*RemoteDriverMock) RemoveCache added in v1.3.3

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

func (*RemoteDriverMock) SetOutputDir added in v1.6.2

func (d *RemoteDriverMock) SetOutputDir(s string)

func (*RemoteDriverMock) String added in v1.6.2

func (d *RemoteDriverMock) String() string

func (*RemoteDriverMock) Unregister added in v1.3.3

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

func (*RemoteDriverMock) UploadISO added in v1.3.3

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

type RunConfig

type RunConfig struct {
	// Packer defaults to building VMware 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. For
	// VMware machines, Packer will output VNC connection information in case you
	// need to connect to the console to debug the build process.
	// Some users have experienced issues where Packer cannot properly connect
	// to a VM if it is headless; this appears to be a result of not ever having
	// launched the VMWare GUI and accepting the evaluation license, or
	// supplying a real license. If you experience this, launching VMWare and
	// accepting the license should resolve your problem.
	Headless bool `mapstructure:"headless" required:"false"`
	// The IP address that should be
	// binded to for VNC. By default packer will use 127.0.0.1 for this. If you
	// wish to bind to all interfaces use 0.0.0.0.
	VNCBindAddress string `mapstructure:"vnc_bind_address" required:"false"`
	// The minimum and maximum port
	// to use for VNC access to the virtual machine. The builder uses VNC to type
	// the initial boot_command. Because Packer generally runs in parallel,
	// 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.
	VNCPortMin int `mapstructure:"vnc_port_min" required:"false"`
	VNCPortMax int `mapstructure:"vnc_port_max"`
	// Don't auto-generate a VNC password that
	// is used to secure the VNC communication with the VM. This must be set to
	// true if building on ESXi 6.5 and 6.7 with VNC enabled. Defaults to
	// false.
	VNCDisablePassword bool `mapstructure:"vnc_disable_password" required:"false"`
	// When set to true, Packer will connect to the remote VNC server over a websocket connection
	// and any other VNC configuration option will be ignored.
	// Remote builds using ESXi 6.7+ allows to connect to the VNC server only over websocket,
	// for these the `vnc_over_websocket` must be set to true.
	VNCOverWebsocket bool `mapstructure:"vnc_over_websocket" required:"false"`
	// Do not validate VNC over websocket server's TLS certificate. Defaults to `false`.
	InsecureConnection bool `mapstructure:"insecure_connection" required:"false"`
}

~> **Note:** If [vnc_over_websocket](#vnc_over_websocket) is set to true, any other VNC configuration will be ignored.

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"`

	// These are deprecated, but we keep them around for BC
	// TODO(@mitchellh): remove
	SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"`
}

func (*SSHConfig) Prepare

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

type SerialConfigAuto added in v1.3.3

type SerialConfigAuto struct {
	Devicename string
	Yield      string
}

type SerialConfigDevice added in v1.3.3

type SerialConfigDevice struct {
	Devicename string
	Yield      string
}

type SerialConfigFile added in v1.3.3

type SerialConfigFile struct {
	Filename string
	Yield    string
}

type SerialConfigPipe added in v1.3.3

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

serial conversions

type SerialUnion added in v1.3.3

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
}

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

Uses:

ui     packersdk.Ui
vmx_path string

Produces:

<nothing>

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
	SkipFloppy       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 added in v0.7.0

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

This step configures the VM to enable the VNC server.

Uses:

ui     packersdk.Ui
vmx_path string

Produces:

vnc_port int - The port that VNC is configured to listen on.

func (*StepConfigureVNC) Cleanup added in v0.7.0

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

func (*StepConfigureVNC) Run added in v0.7.0

func (*StepConfigureVNC) UpdateVMX added in v0.11.0

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

func (*StepConfigureVNC) VNCAddress added in v0.7.0

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

type StepCreateDisks added in v1.6.2

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

This step creates the virtual disks for the VM.

Uses:

config *config
driver Driver
ui     packersdk.Ui

Produces:

disk_full_paths ([]string) - The full paths to all created disks

func (*StepCreateDisks) Cleanup added in v1.6.2

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

func (*StepCreateDisks) Run added in v1.6.2

type StepExport added in v1.3.3

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 added in v1.3.3

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

func (*StepExport) Run added in v1.3.3

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 (*StepHTTPIPDiscover) Run added in v1.5.2

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 added in v1.6.2

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

type StepPrepareTools added in v0.6.1

type StepPrepareTools struct {
	RemoteType        string
	ToolsUploadFlavor string
	ToolsSourcePath   string
}

func (*StepPrepareTools) Cleanup added in v0.6.1

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

func (*StepPrepareTools) Run added in v0.6.1

type StepRegister added in v1.3.3

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

func (*StepRegister) Cleanup added in v1.3.3

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

func (*StepRegister) Run added in v1.3.3

type StepRemoteUpload added in v1.4.4

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 added in v1.4.4

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

func (*StepRemoteUpload) Run added in v1.4.4

type StepRun

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

This step runs the created virtual machine.

Uses:

driver Driver
ui     packersdk.Ui
vmx_path string

Produces:

<nothing>

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
}

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
dir OutputDir
driver Driver
ui     packersdk.Ui
vmx_path string

Produces:

<nothing>

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 added in v0.6.1

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

func (*StepUploadTools) Cleanup added in v0.6.1

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

func (*StepUploadTools) Run added in v0.6.1

type StepUploadVMX added in v1.3.3

type StepUploadVMX struct {
	RemoteType string
}

This step upload the VMX to the remote host

Uses:

driver Driver
ui     packersdk.Ui
vmx_path string

Produces:

<nothing>

func (StepUploadVMX) Cleanup added in v1.3.3

func (StepUploadVMX) Cleanup(multistep.StateBag)

func (*StepUploadVMX) Run added in v1.3.3

type StepVNCBootCommand added in v1.6.3

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

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

Uses:

http_port int
ui     packersdk.Ui
vnc_port int

Produces:

<nothing>

func (*StepVNCBootCommand) Cleanup added in v1.6.3

func (*StepVNCBootCommand) Run added in v1.6.3

type StepVNCConnect added in v1.6.3

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

func (*StepVNCConnect) Cleanup added in v1.6.3

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

func (*StepVNCConnect) ConnectVNC added in v1.6.3

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

func (*StepVNCConnect) ConnectVNCOverWebsocketClient added in v1.6.3

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

func (*StepVNCConnect) Run added in v1.6.3

type ToolsConfig added in v0.6.1

type ToolsConfig struct {
	// The flavor of the VMware Tools ISO to
	// upload into the VM. Valid values are darwin, linux, and windows. By
	// default, this is empty, which means VMware tools won't be uploaded.
	ToolsUploadFlavor string `mapstructure:"tools_upload_flavor" required:"false"`
	// The path in the VM to upload the VMware tools. This only takes effect if
	// `tools_upload_flavor` is non-empty. This is a [configuration
	// template](/docs/templates/legacy_json_templates/engine) that has a single valid variable:
	// `Flavor`, which will be the value of `tools_upload_flavor`. By default
	// the upload path is set to `{{.Flavor}}.iso`. This setting is not used
	// when `remote_type` is `esx5`.
	ToolsUploadPath string `mapstructure:"tools_upload_path" required:"false"`
	// The path on your local machine to fetch the vmware tools from. If this
	// is not set but the tools_upload_flavor is set, then Packer will try to
	// load the VMWare tools from the VMWare installation directory.
	ToolsSourcePath string `mapstructure:"tools_source_path" required:"false"`
}

func (*ToolsConfig) Prepare added in v0.6.1

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

type VMXConfig

type VMXConfig struct {
	// Arbitrary key/values to enter
	// into the virtual machine VMX file. This is for advanced users who want to
	// set properties that aren't yet supported by the builder.
	VMXData map[string]string `mapstructure:"vmx_data" required:"false"`
	// Identical to vmx_data,
	// except that it is run after the virtual machine is shutdown, and before the
	// virtual machine is exported.
	VMXDataPost map[string]string `mapstructure:"vmx_data_post" required:"false"`
	// Remove all ethernet interfaces
	// from the VMX file after building. This is for advanced users who understand
	// the ramifications, but is useful for building Vagrant boxes since Vagrant
	// will create ethernet interfaces when provisioning a box. Defaults to
	// false.
	VMXRemoveEthernet bool `mapstructure:"vmx_remove_ethernet_interfaces" required:"false"`
	// The name that will appear in your vSphere client,
	// and will be used for the vmx basename. This will override the "displayname"
	// value in your vmx file. It will also override the "displayname" if you have
	// set it in the "vmx_data" Packer option. This option is useful if you are
	// chaining vmx builds and want to make sure 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 added in v0.7.0

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 added in v1.6.3

type VNCBootCommandTemplateData struct {
	HTTPIP   string
	HTTPPort int
	Name     string
}

type VmwareDriver added in v1.2.0

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 added in v1.6.2

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

func (*VmwareDriver) GuestAddress added in v1.2.0

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

func (*VmwareDriver) HostAddress added in v1.2.0

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

func (*VmwareDriver) HostIP added in v1.2.0

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

func (*VmwareDriver) PotentialGuestIP added in v1.6.0

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

func (*VmwareDriver) VerifyOvfTool added in v1.6.3

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

type Workstation10Driver added in v0.6.0

type Workstation10Driver struct {
	Workstation9Driver
}

func (*Workstation10Driver) Clone added in v0.6.0

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

func (*Workstation10Driver) GetVmwareDriver added in v1.2.0

func (d *Workstation10Driver) GetVmwareDriver() VmwareDriver

func (*Workstation10Driver) Verify added in v0.6.0

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 added in v0.8.0

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) GetVmwareDriver added in v1.2.0

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 added in v0.6.0

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