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

[BUG] vcsim does not set VAppProductInfo on VirtualMachine #3111

Closed
jcpowermac opened this issue Apr 25, 2023 · 4 comments · Fixed by #3252
Closed

[BUG] vcsim does not set VAppProductInfo on VirtualMachine #3111

jcpowermac opened this issue Apr 25, 2023 · 4 comments · Fixed by #3252

Comments

@jcpowermac
Copy link

jcpowermac commented Apr 25, 2023

Describe the bug

vcsim does not set VAppProductInfo on imported or created VirtualMachine

To Reproduce
Steps to reproduce the behavior:

wget https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.12/latest/rhcos-4.12.10-x86_64-vmware.x86_64.ova
govc import.ova -pool /DC0/host/DC0_C0 -dc DC0 rhcos-4.12.10-x86_64-vmware.x86_64.ova 
govc vm.info -json '/DC0/vm/OpenShift 4' | jq
	config := types.VirtualMachineConfigSpec{
		Name:    name,
		GuestId: string(types.VirtualMachineGuestOsIdentifierOtherGuest),
		Files: &types.VirtualMachineFileInfo{
			VmPathName: "[LocalDS_0]",
		},
		VAppConfig: &types.VAppConfigSpec{
			VmConfigSpec: types.VmConfigSpec{
				Product: []types.VAppProductSpec{{
					ArrayUpdateSpec: types.ArrayUpdateSpec{
						Operation: types.ArrayUpdateOperationAdd,
					},
					Info: &types.VAppProductInfo{
						Key:     int32(0),
						Name:    "rhcos OpenShift 4",
						Vendor:  "rhcos",
						Version: "foo",
					},
				}},
			},
		},
	}

	var devices object.VirtualDeviceList
	vmnet := esx.EthernetCard.Backing
	nic := esx.EthernetCard
	nic.Backing = vmnet

	scsi, _ := devices.CreateSCSIController("pvscsi")
	ide, _ := devices.CreateIDEController()
	cdrom, _ := devices.CreateCdrom(ide.(*types.VirtualIDEController))
	disk := devices.CreateDisk(scsi.(types.BaseVirtualController), datastores[0].Reference(),
		config.Files.VmPathName+" "+path.Join(name, "disk1.vmdk"))
	disk.CapacityInKB = int64(units.GB*10) / units.KB
	disk.StorageIOAllocation = &types.StorageIOAllocationInfo{Limit: types.NewInt64(-1)}

	devices = append(devices, scsi, cdrom, disk, &nic)

	config.DeviceChange, _ = devices.ConfigSpec(types.VirtualDeviceConfigSpecOperationAdd)


	task, err := vmFolder.CreateVM(ctx, config, resourcePools[0], hosts[0])
	if err != nil {
		log.Fatal(err)
	}

	info, err := task.WaitForResult(ctx, nil)
	if err != nil {
		log.Fatal(err)
	}

	rhcos := object.NewVirtualMachine(c.Client, info.Result.(types.ManagedObjectReference))
	spew.Dump(rhcos)
	vms, err := finder.VirtualMachineList(ctx, "/...")

	if err != nil {
		log.Fatal(err)
	}

	for _, v := range vms {
		fmt.Println(v.Name())

		if strings.Contains(v.Name(), "rhcos") {
			var vmMo mo.VirtualMachine

			err = v.Properties(ctx, v.Reference(), []string{"config"}, &vmMo)

			if err != nil {
				log.Fatal(err)
			}
			if vmMo.Config != nil {
				if vmMo.Config.VAppConfig != nil {
					spew.Dump(vmMo.Config.VAppConfig)

				}
			}
		}
	}

Expected behavior
Configuration spec of virtual machine set should be applied to VirtualMachine.

Affected version
0.30.4, main

Screenshots/Debug Output
If applicable, add screenshots or debug output to help explain your problem.

Additional context
Add any other context about the problem here.

@github-actions
Copy link
Contributor

Howdy 🖐   jcpowermac ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Mark as fresh by adding the comment /remove-lifecycle stale.

dougm added a commit to dougm/govmomi that referenced this issue Oct 2, 2023
vcsim: ResourcePool.ImportVApp improvements
- Run within an internal Task as real vCenter does
- Set VirtualMachineImportSpec.VAppConfig in CreateImportSpec
- Propagate VAppConfig to VirtualMachine (config.vAppConfig)
- Validate userConfigurable=false properties

Fixes vmware#3111
@dougm
Copy link
Member

dougm commented Oct 3, 2023

@jcpowermac sorry for the delay, fixed by #3252 if you want to give it a try

@jcpowermac
Copy link
Author

@jcpowermac sorry for the delay, fixed by #3252 if you want to give it a try

No worries @dougm thanks for fixing it! Though now I have to remember what I was up to ;-)

priyanka19-98 pushed a commit to priyanka19-98/govmomi that referenced this issue Jan 17, 2024
vcsim: ResourcePool.ImportVApp improvements
- Run within an internal Task as real vCenter does
- Set VirtualMachineImportSpec.VAppConfig in CreateImportSpec
- Propagate VAppConfig to VirtualMachine (config.vAppConfig)
- Validate userConfigurable=false properties

Fixes vmware#3111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants