Discussion:
Finding a Vsphere guest's id...
Matthew Barr
2013-05-21 22:53:27 UTC
Permalink
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: mbarr-q2pkGsKyZe6Kf2Id4j40wVaTQe2KTcn/@public.gmane.org
AIM: matthewbarr1
c: (646) 727-0535
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Bruce
2013-11-15 22:14:59 UTC
Permalink
This isn't working for me in fog 1.18.0, connecting a vsphere 5.1.

irb(main):011:0> vm = f.get_virtual_machine(host)
Fog::Compute::Vsphere::NotFound: XXX.XXX.com was not found
from
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/fog-1.18.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:27:in
`get_vm_ref'
from
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/fog-1.18.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:6:in
`get_virtual_machine'
from (irb):11
from /opt/boxen/rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):012:0>

host contains just the hostname string.

Any ideas?
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Kevin Menard
2013-11-15 22:50:35 UTC
Permalink
Hi Bruce,



Do you have multiple datacenters? If so, you probably need to pass the
one you want to search through as the second argument to that call.



--

Kevin





On Fri, Nov 15, 2013, at 17:14, Bruce wrote:


This isn't working for me in fog 1.18.0, connecting a vsphere 5.1.

irb(main):011:0> vm = f.get_virtual_machine(host)
Fog::Compute::Vsphere::NotFound: XXX.XXX.com was not found
from
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/fog-1.18.
0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:27:in
`get_vm_ref'
from
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/fog-1.18.
0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:6:in
`get_virtual_machine'
from (irb):11
from /opt/boxen/rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):012:0>

host contains just the hostname string.

Any ideas?

--

You received this message because you are subscribed to the Google
Groups "ruby-fog" group.

To unsubscribe from this group and stop receiving emails from it, send
an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org

For more options, visit [1]https://groups.google.com/groups/opt_out.

References

1. https://groups.google.com/groups/opt_out
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...