Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware-iso: Using the snapshot_name option with ESXi, the VMX file does not refer the correct snapshot #68

Open
julien-lang opened this issue Mar 4, 2022 · 1 comment
Assignees
Milestone

Comments

@julien-lang
Copy link

julien-lang commented Mar 4, 2022

I use packer to generate virtual machines on ESXi.

I set a snapshot_name combined with "keep_registered": true and "skip_export": true.

Packer succeed to create the Virtual Machine and the snapshot is created indeed but the VMX file does refer the snapshot:

  • Actual result:

    scsi0:0.filename = "disk.vmdk"
    
  • Expected result:

    scsi0:0.filename = "disk-000001.vmdk"
    

Related to #20

@julien-lang julien-lang added the bug label Mar 4, 2022
@julien-lang
Copy link
Author

julien-lang commented Jul 25, 2022

I think the error might come from the list of steps in the builder/vmware/iso/builder.go file.

The StepCreateSnapshot is defined before the StepUploadVMX step. So if I understand the code correclty, This will override the VMDK filename in the VMX.

So the fixup could simply be:

diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go
index 951aaab..4074d62 100644
--- a/builder/vmware/iso/builder.go
+++ b/builder/vmware/iso/builder.go
@@ -179,12 +179,12 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
                        RemoveEthernetInterfaces: b.config.VMXConfig.VMXRemoveEthernet,
                        VNCEnabled:               !b.config.DisableVNC,
                },
-               &vmwcommon.StepCreateSnapshot{
-                       SnapshotName: &b.config.SnapshotName,
-               },
                &vmwcommon.StepUploadVMX{
                        RemoteType: b.config.RemoteType,
                },
+               &vmwcommon.StepCreateSnapshot{
+                       SnapshotName: &b.config.SnapshotName,
+               },
                &vmwcommon.StepExport{
                        Format:         b.config.Format,
                        SkipExport:     b.config.SkipExport,

But I have not tested it yet.

@tenthirtyam tenthirtyam changed the title Using the snapshot_name option with ESXi, the VMX file does not refer the right snapshot vmware-iso: Using the snapshot_name option with ESXi, the VMX file does not refer the correct snapshot Aug 22, 2023
@tenthirtyam tenthirtyam self-assigned this Mar 11, 2024
@tenthirtyam tenthirtyam added the hypervisor/esx VMware ESXi label May 19, 2024
@tenthirtyam tenthirtyam added this to the Backlog milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants