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

Support eager zeroed thick virtual disk in CreateDisk() #254

Closed
tkak opened this issue Apr 28, 2015 · 4 comments
Closed

Support eager zeroed thick virtual disk in CreateDisk() #254

tkak opened this issue Apr 28, 2015 · 4 comments

Comments

@tkak
Copy link
Contributor

tkak commented Apr 28, 2015

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,

@pietern
Copy link
Contributor

pietern commented Apr 28, 2015

@tkak The level of parameterization of the disk is pretty large. I would rather add a function that takes a VirtualDisk type and adds that to the virtual disk list, so that you can customize however you want, instead of only whether or not you want the disk to be zeroed.

@dougm What do you think?

@dougm
Copy link
Member

dougm commented Apr 29, 2015

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

@tkak
Copy link
Contributor Author

tkak commented Apr 30, 2015

@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)
...

@pietern
Copy link
Contributor

pietern commented Apr 30, 2015

Nice :)

Closing the issue.

@pietern pietern closed this as completed Apr 30, 2015
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants