jedi4ever / sahara

a plugin for vagrant that allows you manage a sandbox state
733 stars 53 forks source link

Problem with fog when entering sandbox mode #50

Open mdimjasevic opened 8 years ago

mdimjasevic commented 8 years ago

I use libvirt as the provider for my VMs. Here is what happens.

$ vagrant sandbox on /home/vagrant/gems/gems/sahara-0.0.17/lib/sahara/session/libvirt.rb:1:in require': cannot load such file -- fog (LoadError) from /home/vagrant/gems/gems/sahara-0.0.17/lib/sahara/session/libvirt.rb:1:in<top (required)>' from /home/marko/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/session/factory.rb:12:in require_relative' from /home/marko/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/session/factory.rb:12:increate' from /home/vagrant/gems/gems/sahara-0.0.17/lib/sahara/command/on.rb:21:in block in execute' from /usr/lib/ruby/vendor_ruby/vagrant/plugin/v2/command.rb:226:inblock in with_target_vms' from /usr/lib/ruby/vendor_ruby/vagrant/plugin/v2/command.rb:220:in each' from /usr/lib/ruby/vendor_ruby/vagrant/plugin/v2/command.rb:220:inwith_target_vms' from /home/vagrant/gems/gems/sahara-0.0.17/lib/sahara/command/on.rb:19:in execute' from /home/marko/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/command/root.rb:52:inexecute' from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in execute' from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:258:incli' from /usr/bin/vagrant:173:in `

'

Is this the fog gem's problem? Or sahara's?

chekolyn commented 8 years ago

This is a sahara issue.

Take a look at this vagrant-libvirt issue: https://github.com/pradels/vagrant-libvirt/issues/363

In sahara you have to edit line one of /lib/sahara/session/libvirt.rb

From:

require "fog"

module Sahara
  module Session
    class Libvirt

To:

require "fog/libvirt"

module Sahara
  module Session
    class Libvirt
mdimjasevic commented 8 years ago

Hi @chekolyn ,

Thanks for this! Can you import this fix into Sahara such that everyone has it by default?

chekolyn commented 8 years ago

@mdimjasevic

Yup just submitted the pull request. https://github.com/chekolyn/sahara/commit/83801c923b33ee81d264d991dc959d0fc136616d

tehsmyers commented 8 years ago

I was hitting this issue, but to me it looks like fog isn't installed where vagrant needs it. My workaround was to vagrant plugin install fog, which got the sandbox subcommand working by putting fog where vagrant was looking for it.

My first thought is that sahara should probably mention this in the Gemfile, but it looks like only libvirt needs it, so the "fix" might as simple as a note in the readme: "If you're using sahara with libvirt, vagrant plugin install fog"

I felt a little bad about lying to vagrant since fog isn't a vagrant plugin, but now sandbox works and I got over it.

chekolyn commented 8 years ago

@seandst

I think you make a good point however the "fog/libvirt" requirement source is from vagrant-libvirt itself If you take a look at the gemspec; vagrant-libvirt has it as a gem requirement: https://github.com/pradels/vagrant-libvirt/blob/master/vagrant-libvirt.gemspec

I think the change was somewhat recent: https://github.com/pradels/vagrant-libvirt/commit/749b431bc85a6a94dbda77e95e5e005b335953a7

tehsmyers commented 8 years ago

Ah, that makes perfect sense, thanks. Now I see how your PR fixes it.

So this is probably fixed with the next release of sahara after the current, and until that's released you can work around it by either manually applying the patch in #50 or being slightly evil like me and installing fog as a vagrant plugin.

flavio-fernandes commented 8 years ago

Many thanks for this thread and fix!!!

After trying the change I now hit this:

https://gist.github.com/f42ad2deef8908bee8cb

Any ideas?

--flaviof

$ vagrant sandbox on [vm1] Starting sandbox mode... /home/ff/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/session/libvirt.rb:106:in snapshot_create_xml': Call to virDomainS (Libvirt::Error)failed: operation failed: Error -22 while writing VM from /home/ff/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/session/libvirt.rb:106:inon' from /home/ff/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/command/on.rb:28:in block in execute' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:226:inblock in with_target_vms' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:220:in each' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:220:inwith_target_vms' from /home/ff/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/command/on.rb:19:in execute' from /home/ff/.vagrant.d/gems/gems/sahara-0.0.17/lib/sahara/command/root.rb:52:inexecute' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/cli.rb:42:in execute' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:301:incli' from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:174:in `

'