sahara icon indicating copy to clipboard operation
sahara copied to clipboard

Problem with fog when entering sandbox mode

Open mdimjasevic opened this issue 9 years ago • 7 comments

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?

mdimjasevic avatar Sep 04 '15 04:09 mdimjasevic

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

chekolyn avatar Oct 01 '15 15:10 chekolyn

Hi @chekolyn ,

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

mdimjasevic avatar Oct 01 '15 15:10 mdimjasevic

@mdimjasevic

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

chekolyn avatar Oct 01 '15 15:10 chekolyn

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.

tehsmyers avatar Nov 12 '15 21:11 tehsmyers

@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

chekolyn avatar Nov 13 '15 00:11 chekolyn

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.

tehsmyers avatar Nov 13 '15 16:11 tehsmyers

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 `

'

flavio-fernandes avatar Dec 20 '15 22:12 flavio-fernandes