Issue running vSphere provider and Fog
I'm not sure what's wrong here. Are there known issues with Fog and vSphere appliances?
2.0.0-p247 :001 > require 'fog'
[fog][WARNING] Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.
=> true
2.0.0-p247 :002 >
2.0.0-p247 :003 > compute = Fog::Compute.new(
2.0.0-p247 :004 > :provider => 'vSphere',
2.0.0-p247 :005 > :vsphere_username => myusername,
2.0.0-p247 :006 > :vsphere_password => mypassword,
2.0.0-p247 :007 > :vsphere_server => serverip,
2.0.0-p247 :008 > :vsphere_expected_pubkey_hash => hash,
2.0.0-p247 :009 > )
=> #<Fog::Compute::Vsphere::Real:70207033816940 [...]>
2.0.0-p247 :010 >
2.0.0-p247 :011 > compute.servers
Fog::Compute::Vsphere::NotFound: 14 was not found
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:27:in `get_vm_ref'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb:32:in `list_vm_interfaces'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/vsphere/models/compute/interfaces.rb:18:in `all'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:141:in `lazy_load'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:15:in `empty?'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:86:in `block in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/formatador-0.2.4/lib/formatador.rb:92:in `indent'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:79:in `inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/model.rb:29:in `block (2 levels) in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/model.rb:29:in `map'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/model.rb:29:in `block in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/formatador-0.2.4/lib/formatador.rb:92:in `indent'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/model.rb:26:in `inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:89:in `block (3 levels) in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:17:in `map'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:17:in `map'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:89:in `block (2 levels) in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/formatador-0.2.4/lib/formatador.rb:92:in `indent'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:88:in `block in inspect'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/formatador-0.2.4/lib/formatador.rb:92:in `indent'
from /Users/lanceblais/.rvm/gems/ruby-2.0.0-p247/gems/fog-1.18.0/lib/fog/core/collection.rb:79:in `inspect'
from /Users/lanceblais/.rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `<main>'2.0.0-p247 :012 >
Are you missing anything from that trace? What I'm seeing there doesn't make a terribly large amount of sense.
That's the whole trace. Is there anything else I can try to help you out?
Do you get something different if you run compute.servers.all ?
Same error. Just tried it.
My Gemfile has:
gem 'fog'
And I'm running irb using:
bundle exec irb
Then the above are typed in to irb.
Am I doing something wrong in loading or using Fog this way?
That should work. It's choking on a vm-ref of 14. I'm trying to find a way of how it got there. But that data almost certainly came from your vCenter host.
What should my setup look like?
I'm running this on a Mac directly against a vSphere server (I hope that makes sense).
It authenticates no problem and some of the commands work (datacenters does for example) but servers doesn't.
I don't know. I just know this call works for others (including me). But there's so many different ways to lay out your cluster that I wouldn't be shocked if there are corner cases. Can you output: compute.list_virtual_machines({}).collect { |vm| vm['mo_ref'] }
Even better would be dropping off the collect part, but I don't know if that'll leak information you don't want to.
2.0.0-p247 :014 > compute.list_virtual_machines({}).collect { |vm| vm['mo_ref'] }
=> ["14", "15", "16", "17", "21", "26", "28", "29"]
Dropping the collect part reveals a lot of information. Oddly enough, the one with "id" of 14 has a nil uuid and an "Unknown" name.
Thoughts?
That looks like the culprit then. Can you correlate that back to anything odd in your vCenter console? You should have the path to the VM in there.
I won't be able to look at it today. Is there something I can do get around this for now?
Beyond patching fog locally, I don't think there's anything you can do to work around it. Do you have a few options you can pass to servers.all that may filter out that bad entry naturally, but without seeing your output I can't say for certain. The options hash looks like:
{
:datacenter => datacenter,
:cluster => cluster,
:network => network,
:resource_pool => resource_pool,
:folder => folder
}
Im closing this due inactivity and lack of feedback.
Please comment if you still need to fix this.
Thanks!
On Fri, Nov 21, 2014 at 3:14 PM, Paulo Henrique Lopes Ribeiro < [email protected]> wrote:
Im closing this due inactivity and lack of feedback.
Please comment if you still need to fix this.
Reply to this email directly or view it on GitHub https://github.com/fog/fog/issues/2351#issuecomment-64038641.
I'm unsure if this is helpful or not, but I ran into a bug identical to this one, and it was because there was somehow a 'junk' VM in the datacenter that didn't have a lot of its required options set. (For instance, it had a nil hostname, ipaddress, and guest_id).
It didn't show in the web UI or the VIM client, so I killed it off with rbvmomi, and all is well :)
@Karunamon ah, I could see how that would be problematic. Thanks for sharing your fix!
@Karunamon I don't suppose you could think of a way that we could maybe validate instance correctness based on your experience, could you? If so, that'd allow us to provide better error messaging in those sorts of cases.