Skip to content

Instantly share code, notes, and snippets.

@echohack
Created May 19, 2015 22:09
Show Gist options
  • Save echohack/5e2bc48b3815503cea0b to your computer and use it in GitHub Desktop.
Save echohack/5e2bc48b3815503cea0b to your computer and use it in GitHub Desktop.
why_rubocop.rb
def virtual_disk_for(vm, options)
if options[:datastore].to_s.empty?
raise ":datastore must be specified when adding a disk to a cloned vm"
end
idx = vm.disks.count
RbVmomi::VIM::VirtualDeviceConfigSpec(
:operation => :add,
:fileOperation => :create,
:device => RbVmomi::VIM.VirtualDisk(
:key => idx,
:backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
:fileName => "[#{options[:datastore]}]",
:diskMode => 'persistent',
:thinProvisioned => true
),
:capacityInKB => options[:additional_disk_size_gb] * 1024 * 1024,
:controllerKey => 1000,
:unitNumber => idx
)
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment