vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.3k stars 910 forks source link

[BUG] l try to create vm and add disk with different datastore but do not happen #3407

Closed TAOTAO-WEB closed 1 month ago

TAOTAO-WEB commented 5 months ago

l use govmomi to create the vm and try to add disk., but the disk use the datastore specify in types.VirtualMachineRelocateSpec not the types.VirtualDeviceFileBackingInfo->Datastore

    device := types.VirtualDisk{
                CapacityInKB: disks[idx].Cap * 1024 * 1024,
                VirtualDevice: types.VirtualDevice{
                    Backing: &types.VirtualDiskFlatVer2BackingInfo{
                        DiskMode:        string(types.VirtualDiskModePersistent),
                        ThinProvisioned: types.NewBool(true),
                        VirtualDeviceFileBackingInfo: types.VirtualDeviceFileBackingInfo{
                            Datastore: &storeCusInfo.Self,
                        },
                    },
                },
            }
deviceList.AssignController(&device, controller)
            addDeviceSpec := &types.VirtualDeviceConfigSpec{
                Operation:     types.VirtualDeviceConfigSpecOperationAdd,
                FileOperation: types.VirtualDeviceConfigSpecFileOperationCreate,
                Device:        &device,
            }

relocateSpec := types.VirtualMachineRelocateSpec{
        Folder:    &folderRef,
        Datastore: &storeInfo.Self,
        Pool:      &resRef,
    }
github-actions[bot] commented 5 months ago

Howdy 🖐   TAOTAO-WEB ! 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.

TAOTAO-WEB commented 5 months ago

您好,已收到您的邮件,我会尽快查看并给你回复的。 Hello, I have received your email. I will check it and reply to you as soon as possible.

github-actions[bot] commented 2 months ago

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.

TAOTAO-WEB commented 2 months ago

您好,已收到您的邮件,我会尽快查看并给你回复的。 Hello, I have received your email. I will check it and reply to you as soon as possible.

TAOTAO-WEB commented 2 months ago

it works after I specify the fiileName with "[]"

VirtualDeviceFileBackingInfo: types.VirtualDeviceFileBackingInfo{
                    Datastore: &ds.Self,
                    FileName:  "[" + ds.Name + "]",
                },