diff options
author | varac <varacanero@zeromail.org> | 2013-07-23 23:06:12 +0200 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2013-07-25 20:01:33 +0200 |
commit | 7b8ae68306108498ce9ea736a9e102c3ce103393 (patch) | |
tree | ec31529aa5facdc3bff36cb06a541e0defac0957 | |
parent | d6150c32cd970a2d8e7af126ac48cb752f6a79e3 (diff) | |
download | leap_cli-7b8ae68306108498ce9ea736a9e102c3ce103393.tar.gz leap_cli-7b8ae68306108498ce9ea736a9e102c3ce103393.tar.bz2 |
Fix Vagrant 1.2.x warnings (Feature #3241)
-rw-r--r-- | lib/leap_cli/commands/vagrant.rb | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/lib/leap_cli/commands/vagrant.rb b/lib/leap_cli/commands/vagrant.rb index f24cfb1..610574d 100644 --- a/lib/leap_cli/commands/vagrant.rb +++ b/lib/leap_cli/commands/vagrant.rb @@ -146,19 +146,41 @@ module LeapCli; module Commands def create_vagrant_file lines = [] netmask = IPAddr.new('255.255.255.255').mask(LeapCli.leapfile.vagrant_network.split('/').last).to_s - lines << %[Vagrant::Config.run do |config|] - manager.each_node do |node| - if node.vagrant? - lines << %[ config.vm.define :#{node.name} do |config|] - lines << %[ config.vm.box = "leap-wheezy"] - lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] - lines << %[ config.vm.network :hostonly, "#{node.ip_address}", :netmask => "#{netmask}"] - lines << %[ config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] - lines << %[ config.vm.customize ["modifyvm", :id, "--name", "#{node.name}"]] - lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line - lines << %[ end] - end - end + + version = vagrant_version + case version + when 0..1 + lines << %[Vagrant::Config.run do |config|] + manager.each_node do |node| + if node.vagrant? + lines << %[ config.vm.define :#{node.name} do |config|] + lines << %[ config.vm.box = "leap-wheezy"] + lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] + lines << %[ config.vm.network :hostonly, "#{node.ip_address}", :netmask => "#{netmask}"] + lines << %[ config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] + lines << %[ config.vm.customize ["modifyvm", :id, "--name", "#{node.name}"]] + lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line + lines << %[ end] + end + end + when 2 + lines << %[Vagrant.configure("2") do |config|] + manager.each_node do |node| + if node.vagrant? + lines << %[ config.vm.define :#{node.name} do |config|] + lines << %[ config.vm.box = "leap-wheezy"] + lines << %[ config.vm.box_url = "http://download.leap.se/leap-debian.box"] + lines << %[ config.vm.network :private_network, ip: "#{node.ip_address}"] + lines << %[ config.vm.provider "virtualbox" do |v|] + lines << %[ v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]] + lines << %[ v.name = "#{node.name}"] + lines << %[ end] + lines << %[ #{leapfile.custom_vagrant_vm_line}] if leapfile.custom_vagrant_vm_line + lines << %[ end] + end + end + end + lines << %[end] lines << "" write_file! :vagrantfile, lines.join("\n") |