]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
added vagrant version check, so it works with vagrant > 1.0.x
authorvarac <varacanero@zeromail.org>
Mon, 8 Jul 2013 16:09:28 +0000 (18:09 +0200)
committervarac <varacanero@zeromail.org>
Mon, 8 Jul 2013 16:09:28 +0000 (18:09 +0200)
see http://docs.vagrantup.com/v2/vagrantfile/version.html for
details on vagrant command line option and config differences.

lib/leap_cli/commands/vagrant.rb

index a60e176a9f5683437ab5b6a573a4d0bd70c8e849..032fa36cbde4ff672b19451b8939d304c63a3368 100644 (file)
@@ -111,13 +111,33 @@ module LeapCli; module Commands
 
   def vagrant_setup
     assert_bin! 'vagrant', 'Vagrant is required for running local virtual machines. Run "sudo apt-get install vagrant".'
-    unless assert_run!('vagrant gem which sahara').chars.any?
-      log :installing, "vagrant plugin 'sahara'"
-      assert_run! 'vagrant gem install sahara'
+
+    version = vagrant_version 
+    case version
+      when 0..1
+        unless assert_run!('vagrant gem which sahara').chars.any?
+          log :installing, "vagrant plugin 'sahara'"
+          assert_run! 'vagrant gem install sahara'
+        end
+      when 2
+        unless assert_run!('vagrant plugin list | grep sahara | cat').chars.any?
+          log :installing, "vagrant plugin 'sahara'"
+          assert_run! 'vagrant plugin install sahara'
+        end
     end
     create_vagrant_file
   end
 
+  def vagrant_version
+    minor_version = `vagrant --version|cut -d' ' -f 3 | cut -d'.' -f 2`.to_i
+    version = case minor_version
+      when 1..9 then 2 
+      when 0    then 1
+      else 0
+    end
+    return version
+  end
+
   def execute(cmd)
     log 2, :run, cmd
     exec cmd