The below code was one of the ways I found to get the ID of a guest system in Vsphere. It doesn't seem to work if ARGV[0] has a dash in it.
Ideally, this would find the ID of a guest, then shut it off.
(Other methods seems to fail to find the ID, or set the instance_uuid. )
This code has been around for a few months so the bugs behind the initial attempt might have been fixed in Fog…
(Once it's fixed & vetted, I'm happy to contribute this to the docs for Vsphere. )
----
include fog
host_name=ARGV[0]
f=Fog::Compute.new(:provider => "Vsphere" )
vm=f.get_virtual_machine(host_name)
vm["instance_uuid"] = vm["id"]
vm["force"] = true
f.vm_power_off(vm)
f.vm_destroy(vm)
----
Matthew Barr
Technical Architect
E:
mb...@snap-interactive.com
AIM: matthewbarr1
c:
(646) 727-0535