Skip to content

Instantly share code, notes, and snippets.

@jedi4ever
Created June 1, 2011 08:27
Show Gist options
  • Save jedi4ever/1001978 to your computer and use it in GitHub Desktop.
Save jedi4ever/1001978 to your computer and use it in GitHub Desktop.
vsphere -ruby testing notes
To setup a test environment
- install vmware Fusion (trial)
- install A machine (windows 2003 / 64 Bit /trial available)
- install B machine (ESX) (trial download)
- install on A, vsphere server (trial download/requires Win2003/Win2008)
- install on A, vsphere client
- import ESX host B into vsphere via vsphere client
- create a user vmware (Local User)
- put it in Administrator group
Libraries we use
- https://github.com/vmware/rbvmomi
Cloning example (cfr. https://github.com/vmware/rbvmomi/blob/master/examples/clone_vm.rb)
require 'rbvmomi'
vim = RbVmomi::VIM.connect host: '172.16.44.133',user: 'vmware', password: 'password', insecure: true
vm=vim.serviceInstance.find_datacenter.find_vm("New Virtual Machine 1")
VIM = RbVmomi::VIM
relocateSpec = RbVmomi::VIM.VirtualMachineRelocateSpec
spec = VIM.VirtualMachineCloneSpec(:location => relocateSpec, :powerOn => false, :template => false)
vm.CloneVM_Task(:folder => vm.parent, :name => "bla", :spec => spec).wait_for_completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment