-
Notifications
You must be signed in to change notification settings - Fork 911
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
Support eager zeroed thick virtual disk in CreateDisk() #254
Comments
Already possible to append a VirtualDisk constructed elsewhere to the list. You could also customize by modifying the return value of CreateDisk(). For example, see: https://github.com/vmware/govmomi/blob/master/govc/vm/disk/attach.go#L76-L93 |
@pietern @dougm Thank you for your advice. I could create eager zeroed thick virtual disk! This is my code snippet. ...
vm, err := finder.VirtualMachine(context.TODO(), "test-01")
if err != nil {
log.Printf("[ERROR] %s", err)
}
log.Printf("[DEBUG] %#v\n", vm)
devices, err := vm.Device(context.TODO())
if err != nil {
log.Printf("[ERROR] %s", err)
}
log.Printf("[DEBUG] %#v\n", devices)
controller, err := devices.FindDiskController("scsi")
if err != nil {
log.Printf("[ERROR] %s", err)
}
log.Printf("[DEBUG] %#v\n", controller)
disk := devices.CreateDisk(controller, "")
existing := devices.SelectByBackingInfo(disk.Backing)
log.Printf("[DEBUG] %#v\n", existing)
if len(existing) == 0 {
log.Printf("Creating disk\n")
disk.CapacityInKB = 1048576
} else {
log.Printf("Disk already present\n")
}
backing := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
log.Printf("[DEBUG] %#v\n", backing)
// eager zeroed thick virtual disk
backing.ThinProvisioned = types.NewBool(false)
backing.EagerlyScrub = types.NewBool(true)
vm.AddDevice(context.TODO(), disk)
... |
Nice :) Closing the issue. |
dougm
added a commit
that referenced
this issue
Mar 8, 2016
Added arguments to govc vm.disk.create for thick provisioning and eager scrubbing, as requested in issue #254
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think current CreateDisk() function just creates thin provisioned virtual disk. I would appreciate it if you could support eager zeroed thick virtual disk.
References:
Thanks,
The text was updated successfully, but these errors were encountered: