common

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

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 (
	NetworkingTypeHostonly = iota + 1
	NetworkingTypeNat
	NetworkingTypeBridged
)
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   = osMacOS
	ToolsFlavorLinux   = osLinux
	ToolsFlavorWindows = osWindows
)

Set the allowed values for the `ToolsUploadFlavor`.

View Source
const NetworkingInterfacePrefix = "vmnet"

Variables

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

KeepFileExtensions is a list of file extensions to retain when cleaning up files in a virtual machine environment.

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

func GetDhcpConfPaths() []string

GetDhcpConfPaths returns a copy of the DHCP configuration paths.

func GetDhcpLeasesPaths added in v1.2.0

func GetDhcpLeasesPaths() []string

GetDhcpLeasesPaths returns a copy of the DHCP leases paths.

func GetOvfTool added in v1.1.0

func GetOvfTool() string

GetOvfTool returns the path to the `ovftool` binary if found in the system's PATH, otherwise returns an empty 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 ConfigDeclaration added in v1.2.0

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

func (*ConfigDeclaration) Hardware added in v1.2.0

func (e *ConfigDeclaration) Hardware() (net.HardwareAddr, error)

func (*ConfigDeclaration) IP4 added in v1.2.0

func (e *ConfigDeclaration) IP4() (net.IP, error)

func (*ConfigDeclaration) IP6 added in v1.2.0

func (e *ConfigDeclaration) IP6() (net.IP, error)

type DhcpConfiguration

type DhcpConfiguration []ConfigDeclaration

DhcpConfiguration represents a list of configuration declarations parsed from a DHCP configuration file.

func ReadDhcpConfig

func ReadDhcpConfig(path string) (DhcpConfiguration, error)

ReadDhcpConfig reads a DHCP configuration file from the specified path and returns the parsed configuration.

func ReadDhcpConfiguration

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

func (*DhcpConfiguration) Global

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 {
	ScsiPresent         string
	ScsiDiskAdapterType string
	SataPresent         string
	NvmePresent         string

	DiskType                  string
	CdromType                 string
	CdromTypePrimarySecondary string
	CdromPath                 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 duplicates the source virtual machine to the destination, using the specified clone type and snapshot.
	Clone(dst string, src string, cloneType bool, snapshot string) error

	// CompactDisk compacts the specified virtual disk to reclaim unused space on the virtual machine.
	CompactDisk(string) error

	// CreateDisk creates a virtual disk with specified path, size, adapter type, and disk type.
	CreateDisk(string, string, string, string) error

	// CreateSnapshot creates a snapshot of the virtual machine specified by its path and assigns it the given snapshot
	// name.
	CreateSnapshot(string, string) error

	// IsRunning checks if the specified virtual machine is currently running.
	IsRunning(string) (bool, error)

	// Start powers on a virtual machine with the specified path and a boolean indicating whether it starts in headless
	// mode.
	Start(string, bool) error

	// Stop gracefully or forcibly halts the virtual machine identified by the provided path. Returns an error if it fails.
	Stop(string) error

	// SuppressMessages modifies the .vmx or surrounding directory to suppress messages.
	SuppressMessages(string) error

	// ToolsIsoPath returns the path to the VMware Tools ISO based on the specified flavor.
	ToolsIsoPath(string) string

	// ToolsInstall installs VMware Tools on the guest OS by mounting the Tools ISO via the driver.
	ToolsInstall() error

	// Verify checks the configuration and ensures that the driver is ready for use.
	Verify() error

	// CommHost determines and returns the host address for communication with the virtual machine from the provided
	// state.
	CommHost(multistep.StateBag) (string, error)

	// GetVmwareDriver retrieves an instance of VmwareDriver, a base class containing default methods for virtual
	// machine management.
	GetVmwareDriver() VmwareDriver

	// GuestAddress retrieves the MAC address of a guest machine from its VMX configuration using the provided state.
	GuestAddress(multistep.StateBag) (string, error)

	// PotentialGuestIP retrieves a list of potential IP addresses for the guest from the provided state.
	PotentialGuestIP(multistep.StateBag) ([]string, error)

	// HostAddress retrieves the host's network address based on the state.
	HostAddress(multistep.StateBag) (string, error)

	// HostIP retrieves the host IP address for the virtual machine based on the state.
	HostIP(multistep.StateBag) (string, error)

	// Export exports a virtual machine using the provided arguments.
	Export([]string) error

	// VerifyOvfTool validates the presence and compatibility of the OVF Tool based on specified conditions.
	VerifyOvfTool(bool, bool) error
}

Driver represents an interface for managing virtual machines.

func NewDriver

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

NewDriver initializes a suitable virtual machine driver based on the given configuration and host environment.

func NewEsxiDriver added in v1.2.0

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

func NewFusionDriver added in v1.2.0

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

func NewPlayerDriver added in v1.2.0

func NewPlayerDriver(config *SSHConfig) Driver

NewPlayerDriver creates a new PlayerDriver.

func NewWorkstationDriver added in v1.2.0

func NewWorkstationDriver(config *SSHConfig) Driver

NewWorkstationDriver creates a new WorkstationDriver.

type DriverConfig

type DriverConfig struct {
	// The installation path of the VMware Fusion application. Defaults to
	// `/Applications/VMware Fusion.app`
	//
	// ~> **Note:** This is only required if you are using VMware Fusion as a
	// local desktop hypervisor and have installed it in a non-default location.
	FusionAppPath string `mapstructure:"fusion_app_path" required:"false"`
	// The type of remote hypervisor that will be used. If set, the remote
	// hypervisor will be used for the build. If not set, a local desktop
	// hypervisor (VMware Fusion or VMware Workstation) will be used.
	// Available options include `esxi` for VMware ESXi.
	//
	// ~> **Note:** Use of `esxi` is recommended; `esx5` is deprecated.
	RemoteType string `mapstructure:"remote_type" required:"false"`
	// The datastore on the remote hypervisor where the virtual machine will be
	// stored.
	RemoteDatastore string `mapstructure:"remote_datastore" required:"false"`
	// The datastore attached to the remote hypervisor to use for the build.
	// Supporting files such as ISOs and floppies are cached in this datastore
	// during the build. Defaults to `datastore1`.
	RemoteCacheDatastore string `mapstructure:"remote_cache_datastore" required:"false"`
	// The directory path on the remote cache datastore to use for the build.
	// Supporting files such as ISOs and floppies are cached in this directory,
	// relative to the `remote_cache_datastore`, during the build. Defaults to
	// `packer_cache`.
	RemoteCacheDirectory string `mapstructure:"remote_cache_directory" required:"false"`
	// Remove items added to the remote cache after the build is complete.
	// Defaults to `false`.
	CleanUpRemoteCache bool `mapstructure:"cleanup_remote_cache" required:"false"`
	// The fully qualified domain name or IP address of the remote hypervisor
	// where the virtual machine is created.
	//
	// ~> **Note:** Required if `remote_type` is set.
	RemoteHost string `mapstructure:"remote_host" required:"false"`
	// The SSH port of the remote hypervisor. Defaults to `22`.
	RemotePort int `mapstructure:"remote_port" required:"false"`
	// The SSH username for access to the remote hypervisor. Defaults to `root`.
	RemoteUser string `mapstructure:"remote_username" required:"false"`
	// The SSH password for access to the remote hypervisor.
	RemotePassword string `mapstructure:"remote_password" required:"false"`
	// The SSH key for access to the remote hypervisor.
	RemotePrivateKey string `mapstructure:"remote_private_key_file" required:"false"`
	// Skip the validation of the credentials for access to the remote
	// hypervisor. By default, export is enabled and the plugin will validate
	// the credentials ('remote_username' and 'remote_password'), for use by
	// VMware OVF Tool, before starting the build. Defaults to `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 EsxiDriver added in v1.2.0

type EsxiDriver 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
}

EsxiDriver is a driver for building virtual machines on an ESXi host.

func (*EsxiDriver) AcquireVNCOverWebsocketTicket added in v1.2.0

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

func (*EsxiDriver) CachePath added in v1.2.0

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

func (*EsxiDriver) Clone added in v1.2.0

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

func (*EsxiDriver) CommHost added in v1.2.0

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

func (*EsxiDriver) CompactDisk added in v1.2.0

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

func (*EsxiDriver) CreateDisk added in v1.2.0

func (d *EsxiDriver) CreateDisk(diskPathLocal string, size string, adapterType string, typeId string) error

func (*EsxiDriver) CreateSnapshot added in v1.2.0

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

func (*EsxiDriver) Destroy added in v1.2.0

func (d *EsxiDriver) Destroy() error

func (*EsxiDriver) DirExists added in v1.2.0

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

func (*EsxiDriver) Download added in v1.2.0

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

func (*EsxiDriver) Export added in v1.2.0

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

func (*EsxiDriver) GetVmwareDriver added in v1.2.0

func (d *EsxiDriver) GetVmwareDriver() VmwareDriver

func (*EsxiDriver) GuestAddress added in v1.2.0

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

func (*EsxiDriver) HostAddress added in v1.2.0

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

func (*EsxiDriver) HostIP added in v1.2.0

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

func (*EsxiDriver) IsDestroyed added in v1.2.0

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

func (*EsxiDriver) IsRunning added in v1.2.0

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

func (*EsxiDriver) ListFiles added in v1.2.0

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

func (*EsxiDriver) MkdirAll added in v1.2.0

func (d *EsxiDriver) MkdirAll() error

func (*EsxiDriver) PotentialGuestIP added in v1.2.0

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

func (*EsxiDriver) Register added in v1.2.0

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

func (*EsxiDriver) ReloadVM added in v1.2.0

func (d *EsxiDriver) ReloadVM() error

func (*EsxiDriver) Remove added in v1.2.0

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

func (*EsxiDriver) RemoveAll added in v1.2.0

func (d *EsxiDriver) RemoveAll() error

func (*EsxiDriver) RemoveCache added in v1.2.0

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

func (*EsxiDriver) SetOutputDir added in v1.2.0

func (d *EsxiDriver) SetOutputDir(path string)

func (*EsxiDriver) Start added in v1.2.0

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

func (*EsxiDriver) Stop added in v1.2.0

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

func (*EsxiDriver) String added in v1.2.0

func (d *EsxiDriver) String() string

func (*EsxiDriver) SuppressMessages added in v1.2.0

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

func (*EsxiDriver) ToolsInstall added in v1.2.0

func (d *EsxiDriver) ToolsInstall() error

func (*EsxiDriver) ToolsIsoPath added in v1.2.0

func (d *EsxiDriver) ToolsIsoPath(string) string

func (*EsxiDriver) Unregister added in v1.2.0

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

func (EsxiDriver) UpdateVMX added in v1.2.0

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

UpdateVMX configures the VMX file with VNC parameters such as enablement, port, and optional password.

func (*EsxiDriver) UploadISO added in v1.2.0

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

func (*EsxiDriver) VNCAddress added in v1.2.0

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

func (*EsxiDriver) Verify added in v1.2.0

func (d *EsxiDriver) Verify() error

func (*EsxiDriver) VerifyChecksum added in v1.2.0

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

VerifyChecksum checks that file on the esxi instance matches hash

func (*EsxiDriver) VerifyOvfTool added in v1.2.0

func (d *EsxiDriver) 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 FusionDriver added in v1.2.0

type FusionDriver struct {
	VmwareDriver

	// The path to the "VMware Fusion.app"
	AppPath string

	SSHConfig *SSHConfig
}

FusionDriver is a driver for VMware Fusion for macOS.

func (*FusionDriver) Clone added in v1.2.0

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

func (*FusionDriver) CommHost added in v1.2.0

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

func (*FusionDriver) CompactDisk added in v1.2.0

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

func (*FusionDriver) CreateDisk added in v1.2.0

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

func (*FusionDriver) CreateSnapshot added in v1.2.0

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

func (*FusionDriver) GetVmwareDriver added in v1.2.0

func (d *FusionDriver) GetVmwareDriver() VmwareDriver

func (*FusionDriver) IsRunning added in v1.2.0

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

func (*FusionDriver) Start added in v1.2.0

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

func (*FusionDriver) Stop added in v1.2.0

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

func (*FusionDriver) SuppressMessages added in v1.2.0

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

func (*FusionDriver) ToolsInstall added in v1.2.0

func (d *FusionDriver) ToolsInstall() error

func (*FusionDriver) ToolsIsoPath added in v1.2.0

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

func (*FusionDriver) Verify added in v1.2.0

func (d *FusionDriver) 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 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

NetworkMap represents a collection of configurations, where each configuration is a map of string key-value pairs.

func ReadNetmapConfig

func ReadNetmapConfig(path string) (NetworkMap, error)

ReadNetmapConfig reads a network map configuration file from the specified path and parses it.

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)

ReadNetworkingConfig reads and parses a networking configuration 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

NetworkingType represents the type of network configuration.

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 virtual machine  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
	// virtual machine, relative to your remote_datastore.
	//
	// This option's default value is your `vm_name`, and the final path of your
	// virtual machine 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 EsxiDriver.

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

type PlayerDriver struct {
	VmwareDriver

	// The path to VMware Workstation Player.
	AppPath string

	VdiskManagerPath string
	QemuImgPath      string
	VmrunPath        string

	SSHConfig *SSHConfig
}

PlayerDriver is a driver for VMware Workstation Player.

func (*PlayerDriver) Clone added in v1.2.0

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

Clone clones a virtual machine.

func (*PlayerDriver) CommHost added in v1.2.0

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

CommHost returns the host address based on the SSH configuration.

func (*PlayerDriver) CompactDisk added in v1.2.0

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

CompactDisk compacts a virtual machine disk based on the disk path.

func (*PlayerDriver) CreateDisk added in v1.2.0

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

CreateDisk creates a virtual machine disk based on the output path, size, adapter type, and type ID.

func (*PlayerDriver) CreateSnapshot added in v1.2.0

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

CreateSnapshot creates a snapshot of a virtual machine based on the .vmx file path and snapshot name.

func (*PlayerDriver) GetVmwareDriver added in v1.2.0

func (d *PlayerDriver) GetVmwareDriver() VmwareDriver

GetVmwareDriver returns the VmwareDriver.

func (*PlayerDriver) IsRunning added in v1.2.0

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

IsRunning checks if a virtual machine is running based on the .vmx file path.

func (*PlayerDriver) Start added in v1.2.0

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

Start powers on a virtual machine based on the .vmx file path and mode (headless or GUI).

func (*PlayerDriver) Stop added in v1.2.0

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

Stop powers off a virtual machine based on the .vmx file path.

func (*PlayerDriver) SuppressMessages added in v1.2.0

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

SuppressMessages suppresses messages for a virtual machine based on the .vmx file path.

func (*PlayerDriver) ToolsInstall added in v1.2.0

func (d *PlayerDriver) ToolsInstall() error

ToolsInstall installs VMware Tools.

func (*PlayerDriver) ToolsIsoPath added in v1.2.0

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

ToolsIsoPath returns the path to the VMware Tools ISO based on the flavor.

func (*PlayerDriver) Verify added in v1.2.0

func (d *PlayerDriver) Verify() error

Verify checks if the VMware Workstation Player installation is valid.

type RemoteDriver

type RemoteDriver interface {
	Driver

	// UploadISO uploads an ISO file to a remote destination.
	UploadISO(path string, checksum string, ui packersdk.Ui) (string, error)

	// RemoveCache removes a cached file or resource from the specified local path.
	RemoveCache(localPath string) error

	// Register adds a virtual machine to the inventory using the provided path to the VMX file.
	Register(path string) error

	// Unregister removes a virtual machine from the inventory using the provided path to the VMX file.
	Unregister(path string) error

	// Destroy removes the virtual machine from the remote inventory and deletes its associated resources.
	Destroy() error

	// IsDestroyed checks if the virtual machine has been successfully destroyed.
	IsDestroyed() (bool, error)

	// Download transfers a file from a remote source location to a local destination path.
	Download(src, dst string) error

	// ReloadVM reloads the virtual machine configuration on the remote hypervisor and applies any necessary updates.
	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{}

StepCleanFiles represents a step for cleaning up unnecessary files from a directory.

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
}

StepCompactDisk represents a step for compacting attached virtual disks.

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
}

StepConfigureVMX represents the configuration settings for a VMX configuration 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
}

StepExport represents a step to export a virtual machines to specific formats.

func (*StepExport) Cleanup

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

func (*StepExport) Run

type StepHTTPIPDiscover

type StepHTTPIPDiscover struct{}

StepHTTPIPDiscover represents a step to discover the HTTP IP for a virtual machine during provisioning.

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 manages the output directory configuration for a build step, including forceful directory overwrite.

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 represents a step to upload a file to a remote location.

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{}

StepSuppressMessages represents a step to handle the suppression of messages in a VMX file.

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 VM 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`. By default, the upload path is set to
	// `{{.Flavor}}.iso`.
	//
	// ~> **Note:** This setting is not used when `remote_type` is `esxi`.
	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(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)
}

VmwareDriver is a struct that provides methods and paths needed for virtual machine management.

func (*VmwareDriver) Export

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

Export runs the ovftool command-line utility with the specified arguments for exporting the virtual machines.

func (*VmwareDriver) GuestAddress

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

GuestAddress retrieves the MAC address of a guest virtual machine from the .vmx configuration.

func (*VmwareDriver) HostAddress

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

HostAddress retrieves the host's hardware address linked to the network device specified in the state.

func (*VmwareDriver) HostIP

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

HostIP retrieves the host machine's IP address associated with the specific network device defined in the state.

func (*VmwareDriver) PotentialGuestIP

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

PotentialGuestIP identifies potential guest IP addresses for a virtual machine using DHCP leases and MAC address.

func (*VmwareDriver) VerifyOvfTool

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

VerifyOvfTool ensures the VMware OVF Tool is installed, available in the system's PATH, and meets the required version.

type WorkstationDriver added in v1.2.0

type WorkstationDriver struct {
	VmwareDriver

	AppPath          string
	VdiskManagerPath string
	VmrunPath        string

	SSHConfig *SSHConfig
}

WorkstationDriver is a driver for VMware Workstation.

func (*WorkstationDriver) Clone added in v1.2.0

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

Clone clones a virtual machine.

func (*WorkstationDriver) CommHost added in v1.2.0

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

CommHost returns the host address based on the SSH configuration.

func (*WorkstationDriver) CompactDisk added in v1.2.0

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

CompactDisk compacts a virtual machine disk based on the disk path.

func (*WorkstationDriver) CreateDisk added in v1.2.0

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

CreateDisk creates a virtual machine disk based on the output path, size, adapter type, and type ID.

func (*WorkstationDriver) CreateSnapshot added in v1.2.0

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

CreateSnapshot creates a snapshot of a virtual machine based on the .vmx file path and snapshot name.

func (*WorkstationDriver) GetVmwareDriver added in v1.2.0

func (d *WorkstationDriver) GetVmwareDriver() VmwareDriver

GetVmwareDriver returns the VmwareDriver.

func (*WorkstationDriver) IsRunning added in v1.2.0

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

IsRunning checks if a virtual machine is running based on the .vmx file path.

func (*WorkstationDriver) Start added in v1.2.0

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

Start powers on a virtual machine based on the .vmx file path and mode (headless or GUI).

func (*WorkstationDriver) Stop added in v1.2.0

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

Stop powers off a virtual machine based on the .vmx file path.

func (*WorkstationDriver) SuppressMessages added in v1.2.0

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

SuppressMessages suppresses messages for a virtual machine based on the .vmx file path.

func (*WorkstationDriver) ToolsInstall added in v1.2.0

func (d *WorkstationDriver) ToolsInstall() error

ToolsInstall installs VMware Tools.

func (*WorkstationDriver) ToolsIsoPath added in v1.2.0

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

ToolsIsoPath returns the path to the VMware Tools ISO based on the flavor.

func (*WorkstationDriver) Verify added in v1.2.0

func (d *WorkstationDriver) Verify() error

Verify checks if the VMware Workstation installation is valid.

Jump to

Keyboard shortcuts

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