We need to ensure the VMWare process has exited before attempting to run VMX file cleanup steps, otherwise VMWare may overwrite our changes. While Packer does its best to ensure VMWare has exited, there's still a race condition on some OSs between VMWare flushing the VMX and Packer updating it. The workaround is to artifically wait 5 seconds.
When using the VMX builder its possible for the source machine to have a floppy and/or CD-ROM mounted which gets cloned to the new VM Packer spins up, but have no Packer configuration for those devices. With this change we always attempt to remove the mounted devices regardless of the Packer configuration.
In order that something consuming an artifact can have access to extra
builder specific data add the State method which allows the caller to
ask for arbitary values by name.
Adds logic to ESXi driver VNC Address function to ignore listen
addresses that bind to localhost (127.0.0.1), this allows certain
default ports to be available on ESXi for VNC connections
When using the VMX builder its possible for the source machine to have a floppy configured which gets cloned to the new VM Packer spins up. When the new VM's Packer config doesn't have a floppy_files config entry, the Packer clean VMX step fails to remove the floppy disk from the new VM. This can cause build failures, for example with the vsphere post processor; generating errors like:
* Post-processor failed: Failed: exit status 1
Error: File (/home/teamcity/tmp/buildTmp/packer941120499) could not be found.
Opening the cloned VM's VMX file you can clearly see it has a floppy entry from the source machine's VMX file (exact same path) even though the Packer config contains no floppy_files entry.
Add configuration option to explicitly control where Packer uploads
ISO and floppy files to on ESXi hosts. The `remote_cache_datastore`
defaults to the `remote_datastore` value. The 'remote_cache_directory'
defaults to 'packer_cache', similar to the local caching capabilities.
Addresses issues with [GH-1218] and [GH-1221] where paths for uploaded
ISO and floppy files are not written to a valid location in the
datastore.
This commit fixes errors like this in the vsphere post-processor when using floppy files in the builder step:
Error: File (/var/folders/zl/57c1vmr532z_ryf1scw53_b9ycmxh7/T/packer964492999) could not be found
The configure VMX step re-adds the floppy files, so we need to configure the VMX and _then_ clean the VMX in that order.
before, this code had joining path elements by filepath module. filepath module generate path string with backslash-joined in Windows. but ESX require path string with slash-joined. it means that this code generate illegal path string in windows. illegal path string raised "Error creating disk".
this patch fixes path separator from backslash to slash in windows. from this, creating disk would succeed without error.