vagrantup 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Rakefile +3 -3
  4. data/VERSION +1 -1
  5. data/bin/vagrant +5 -13
  6. data/config/default.rb +1 -0
  7. data/keys/README.md +8 -1
  8. data/keys/vagrant.ppk +26 -0
  9. data/lib/vagrant.rb +3 -3
  10. data/lib/vagrant/actions/base.rb +15 -4
  11. data/lib/vagrant/actions/box/add.rb +1 -1
  12. data/lib/vagrant/actions/box/download.rb +72 -66
  13. data/lib/vagrant/actions/box/unpackage.rb +1 -4
  14. data/lib/vagrant/actions/runner.rb +1 -1
  15. data/lib/vagrant/actions/vm/boot.rb +5 -7
  16. data/lib/vagrant/actions/vm/customize.rb +2 -2
  17. data/lib/vagrant/actions/vm/destroy.rb +2 -2
  18. data/lib/vagrant/actions/vm/down.rb +7 -0
  19. data/lib/vagrant/actions/vm/export.rb +10 -4
  20. data/lib/vagrant/actions/vm/forward_ports.rb +5 -15
  21. data/lib/vagrant/actions/vm/halt.rb +5 -3
  22. data/lib/vagrant/actions/vm/import.rb +10 -3
  23. data/lib/vagrant/actions/vm/move_hard_drive.rb +1 -3
  24. data/lib/vagrant/actions/vm/package.rb +33 -10
  25. data/lib/vagrant/actions/vm/provision.rb +4 -4
  26. data/lib/vagrant/actions/vm/reload.rb +1 -1
  27. data/lib/vagrant/actions/vm/resume.rb +1 -1
  28. data/lib/vagrant/actions/vm/shared_folders.rb +7 -7
  29. data/lib/vagrant/actions/vm/start.rb +3 -2
  30. data/lib/vagrant/actions/vm/suspend.rb +2 -2
  31. data/lib/vagrant/actions/vm/up.rb +7 -17
  32. data/lib/vagrant/active_list.rb +52 -45
  33. data/lib/vagrant/box.rb +18 -11
  34. data/lib/vagrant/busy.rb +7 -0
  35. data/lib/vagrant/command.rb +27 -0
  36. data/lib/vagrant/commands/base.rb +163 -0
  37. data/lib/vagrant/commands/box.rb +16 -0
  38. data/lib/vagrant/commands/box/add.rb +24 -0
  39. data/lib/vagrant/commands/box/list.rb +30 -0
  40. data/lib/vagrant/commands/box/remove.rb +31 -0
  41. data/lib/vagrant/commands/destroy.rb +23 -0
  42. data/lib/vagrant/commands/down.rb +16 -0
  43. data/lib/vagrant/commands/halt.rb +23 -0
  44. data/lib/vagrant/commands/init.rb +32 -0
  45. data/lib/vagrant/commands/package.rb +46 -0
  46. data/lib/vagrant/commands/reload.rb +22 -0
  47. data/lib/vagrant/commands/resume.rb +22 -0
  48. data/lib/vagrant/commands/ssh.rb +22 -0
  49. data/lib/vagrant/commands/ssh_config.rb +30 -0
  50. data/lib/vagrant/commands/status.rb +58 -0
  51. data/lib/vagrant/commands/suspend.rb +23 -0
  52. data/lib/vagrant/commands/up.rb +26 -0
  53. data/lib/vagrant/config.rb +21 -11
  54. data/lib/vagrant/downloaders/file.rb +5 -5
  55. data/lib/vagrant/downloaders/http.rb +10 -15
  56. data/lib/vagrant/environment.rb +259 -0
  57. data/lib/vagrant/provisioners/base.rb +7 -0
  58. data/lib/vagrant/provisioners/chef.rb +24 -9
  59. data/lib/vagrant/provisioners/chef_server.rb +23 -48
  60. data/lib/vagrant/provisioners/chef_solo.rb +48 -22
  61. data/lib/vagrant/ssh.rb +95 -46
  62. data/lib/vagrant/util.rb +2 -2
  63. data/lib/vagrant/util/errors.rb +36 -0
  64. data/lib/vagrant/util/platform.rb +12 -0
  65. data/lib/vagrant/util/progress_meter.rb +33 -0
  66. data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
  67. data/lib/vagrant/util/template_renderer.rb +83 -0
  68. data/lib/vagrant/vm.rb +1 -0
  69. data/templates/{Vagrantfile → Vagrantfile.erb} +2 -2
  70. data/templates/chef_server_client.erb +16 -0
  71. data/templates/chef_solo_solo.erb +4 -0
  72. data/templates/errors.yml +157 -0
  73. data/templates/package_Vagrantfile.erb +11 -0
  74. data/templates/ssh_config.erb +7 -0
  75. data/test/test_helper.rb +12 -15
  76. data/test/vagrant/actions/box/add_test.rb +1 -2
  77. data/test/vagrant/actions/box/destroy_test.rb +0 -1
  78. data/test/vagrant/actions/box/download_test.rb +40 -15
  79. data/test/vagrant/actions/box/unpackage_test.rb +2 -3
  80. data/test/vagrant/actions/collection_test.rb +8 -5
  81. data/test/vagrant/actions/runner_test.rb +8 -6
  82. data/test/vagrant/actions/vm/boot_test.rb +12 -11
  83. data/test/vagrant/actions/vm/customize_test.rb +2 -3
  84. data/test/vagrant/actions/vm/destroy_test.rb +2 -3
  85. data/test/vagrant/actions/vm/down_test.rb +16 -3
  86. data/test/vagrant/actions/vm/export_test.rb +4 -5
  87. data/test/vagrant/actions/vm/forward_ports_test.rb +6 -5
  88. data/test/vagrant/actions/vm/halt_test.rb +8 -2
  89. data/test/vagrant/actions/vm/import_test.rb +5 -5
  90. data/test/vagrant/actions/vm/move_hard_drive_test.rb +4 -6
  91. data/test/vagrant/actions/vm/package_test.rb +60 -22
  92. data/test/vagrant/actions/vm/provision_test.rb +7 -16
  93. data/test/vagrant/actions/vm/reload_test.rb +3 -2
  94. data/test/vagrant/actions/vm/resume_test.rb +0 -1
  95. data/test/vagrant/actions/vm/shared_folders_test.rb +17 -12
  96. data/test/vagrant/actions/vm/start_test.rb +10 -3
  97. data/test/vagrant/actions/vm/suspend_test.rb +1 -2
  98. data/test/vagrant/actions/vm/up_test.rb +19 -11
  99. data/test/vagrant/active_list_test.rb +148 -129
  100. data/test/vagrant/box_test.rb +26 -14
  101. data/test/vagrant/busy_test.rb +15 -6
  102. data/test/vagrant/command_test.rb +53 -0
  103. data/test/vagrant/commands/base_test.rb +118 -0
  104. data/test/vagrant/commands/box/add_test.rb +34 -0
  105. data/test/vagrant/commands/box/list_test.rb +32 -0
  106. data/test/vagrant/commands/box/remove_test.rb +41 -0
  107. data/test/vagrant/commands/destroy_test.rb +32 -0
  108. data/test/vagrant/commands/down_test.rb +17 -0
  109. data/test/vagrant/commands/halt_test.rb +28 -0
  110. data/test/vagrant/commands/init_test.rb +55 -0
  111. data/test/vagrant/commands/package_test.rb +84 -0
  112. data/test/vagrant/commands/reload_test.rb +28 -0
  113. data/test/vagrant/commands/resume_test.rb +33 -0
  114. data/test/vagrant/commands/ssh_config_test.rb +54 -0
  115. data/test/vagrant/commands/ssh_test.rb +32 -0
  116. data/test/vagrant/commands/status_test.rb +20 -0
  117. data/test/vagrant/commands/suspend_test.rb +33 -0
  118. data/test/vagrant/commands/up_test.rb +41 -0
  119. data/test/vagrant/config_test.rb +42 -17
  120. data/test/vagrant/downloaders/file_test.rb +7 -0
  121. data/test/vagrant/downloaders/http_test.rb +12 -0
  122. data/test/vagrant/environment_test.rb +595 -0
  123. data/test/vagrant/provisioners/base_test.rb +7 -1
  124. data/test/vagrant/provisioners/chef_server_test.rb +41 -51
  125. data/test/vagrant/provisioners/chef_solo_test.rb +93 -62
  126. data/test/vagrant/provisioners/chef_test.rb +61 -15
  127. data/test/vagrant/ssh_test.rb +166 -38
  128. data/test/vagrant/util/errors_test.rb +57 -0
  129. data/test/vagrant/util/progress_meter_test.rb +33 -0
  130. data/test/vagrant/{stacked_proc_runner_test.rb → util/stacked_proc_runner_test.rb} +3 -3
  131. data/test/vagrant/util/template_renderer_test.rb +138 -0
  132. data/test/vagrant/vm_test.rb +3 -2
  133. data/vagrant.gemspec +88 -33
  134. metadata +92 -49
  135. data/bin/vagrant-box +0 -34
  136. data/bin/vagrant-down +0 -27
  137. data/bin/vagrant-halt +0 -28
  138. data/bin/vagrant-init +0 -27
  139. data/bin/vagrant-package +0 -29
  140. data/bin/vagrant-reload +0 -29
  141. data/bin/vagrant-resume +0 -27
  142. data/bin/vagrant-ssh +0 -27
  143. data/bin/vagrant-status +0 -29
  144. data/bin/vagrant-suspend +0 -27
  145. data/bin/vagrant-up +0 -29
  146. data/lib/vagrant/commands.rb +0 -234
  147. data/lib/vagrant/env.rb +0 -189
  148. data/lib/vagrant/stacked_proc_runner.rb +0 -33
  149. data/test/vagrant/commands_test.rb +0 -269
  150. data/test/vagrant/env_test.rb +0 -418
@@ -7,19 +7,9 @@ module Vagrant
7
7
  next if !vm.running? || vm.uuid == @runner.uuid
8
8
 
9
9
  vm.forwarded_ports.each do |fp|
10
- Vagrant.config.vm.forwarded_ports.each do |name, options|
10
+ @runner.env.config.vm.forwarded_ports.each do |name, options|
11
11
  if fp.hostport.to_s == options[:hostport].to_s
12
- raise ActionException.new(<<-msg)
13
- Vagrant cannot forward the specified ports on this VM, since they
14
- would collide with another VirtualBox virtual machine's forwarded
15
- ports! The "#{name}" forwarded port (#{fp.hostport}) is already in use on the host
16
- machine.
17
-
18
- To fix this, modify your current projects Vagrantfile to use another
19
- port. Example, where '1234' would be replaced by a unique host port:
20
-
21
- config.vm.forward_port("#{name}", #{options[:guestport]}, 1234)
22
- msg
12
+ raise ActionException.new(:vm_port_collision, :name => name, :hostport => fp.hostport.to_s, :guestport => options[:guestport].to_s)
23
13
  end
24
14
  end
25
15
  end
@@ -33,13 +23,13 @@ msg
33
23
 
34
24
  def clear
35
25
  logger.info "Deleting any previously set forwarded ports..."
36
- @runner.vm.forwarded_ports.collect { |p| p.destroy(true) }
26
+ @runner.vm.forwarded_ports.collect { |p| p.destroy }
37
27
  end
38
28
 
39
29
  def forward_ports
40
30
  logger.info "Forwarding ports..."
41
31
 
42
- Vagrant.config.vm.forwarded_ports.each do |name, options|
32
+ @runner.env.config.vm.forwarded_ports.each do |name, options|
43
33
  logger.info "Forwarding \"#{name}\": #{options[:guestport]} => #{options[:hostport]}"
44
34
  port = VirtualBox::ForwardedPort.new
45
35
  port.name = name
@@ -48,7 +38,7 @@ msg
48
38
  @runner.vm.forwarded_ports << port
49
39
  end
50
40
 
51
- @runner.vm.save(true)
41
+ @runner.vm.save
52
42
  end
53
43
  end
54
44
  end
@@ -3,10 +3,12 @@ module Vagrant
3
3
  module VM
4
4
  class Halt < Base
5
5
  def execute!
6
- raise ActionException.new("VM is not running! Nothing to shut down!") unless @runner.vm.running?
6
+ raise ActionException.new(:vm_not_running) unless @runner.vm.running?
7
7
 
8
- logger.info "Forcing shutdown of VM..."
9
- @runner.vm.stop(true)
8
+ @runner.invoke_around_callback(:halt) do
9
+ logger.info "Forcing shutdown of VM..."
10
+ @runner.vm.stop
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -2,13 +2,20 @@ module Vagrant
2
2
  module Actions
3
3
  module VM
4
4
  class Import < Base
5
+ include Util::ProgressMeter
6
+
5
7
  def execute!
6
8
  @runner.invoke_around_callback(:import) do
7
9
  Busy.busy do
8
- logger.info "Importing base VM (#{Vagrant::Env.box.ovf_file})..."
10
+ logger.info "Importing base VM (#{@runner.env.box.ovf_file})..."
9
11
  # Use the first argument passed to the action
10
- @runner.vm = VirtualBox::VM.import(Vagrant::Env.box.ovf_file)
11
- raise ActionException.new("The VM import failed! Try running `VBoxManage import` on the box file manually for more verbose error output.") unless @runner.vm
12
+ @runner.vm = VirtualBox::VM.import(@runner.env.box.ovf_file) do |progress|
13
+ update_progress(progress, 100, false)
14
+ end
15
+
16
+ complete_progress
17
+
18
+ raise ActionException.new(:virtualbox_import_failure) unless @runner.vm
12
19
  end
13
20
  end
14
21
  end
@@ -4,9 +4,7 @@ module Vagrant
4
4
  class MoveHardDrive < Base
5
5
  def execute!
6
6
  unless @runner.powered_off?
7
- error_and_exit(<<-error)
8
- The virtual machine must be powered off to move its disk.
9
- error
7
+ error_and_exit(:vm_power_off_to_move_hd)
10
8
  return
11
9
  end
12
10
 
@@ -16,12 +16,12 @@ module Vagrant
16
16
  def prepare
17
17
  # Verify the existance of all the additional files, if any
18
18
  @include_files.each do |file|
19
- raise ActionException.new("#{file} does not exist") unless File.exists?(file)
19
+ raise ActionException.new(:package_include_file_doesnt_exist, :filename => file) unless File.exists?(file)
20
20
  end
21
21
 
22
22
  # Get the export action and store a reference to it
23
23
  @export_action = @runner.find_action(Export)
24
- raise ActionException.new("Package must be used in conjunction with export.") unless @export_action
24
+ raise ActionException.new(:packaged_requires_export) unless @export_action
25
25
  end
26
26
 
27
27
  def execute!
@@ -29,28 +29,51 @@ module Vagrant
29
29
  end
30
30
 
31
31
  def tar_path
32
- File.join(FileUtils.pwd, "#{out_path}#{Vagrant.config.package.extension}")
32
+ File.join(FileUtils.pwd, "#{out_path}#{@runner.env.config.package.extension}")
33
33
  end
34
34
 
35
35
  def temp_path
36
36
  export_action.temp_dir
37
37
  end
38
38
 
39
+ # This method copies the include files (passed in via command line)
40
+ # to the temporary directory so they are included in a sub-folder within
41
+ # the actual box
42
+ def copy_include_files
43
+ if include_files.length > 0
44
+ include_dir = File.join(temp_path, "include")
45
+ FileUtils.mkdir_p(include_dir)
46
+
47
+ include_files.each do |f|
48
+ logger.info "Packaging additional file: #{f}"
49
+ FileUtils.cp(f, include_dir)
50
+ end
51
+ end
52
+ end
53
+
54
+ # This method creates the auto-generated Vagrantfile at the root of the
55
+ # box. This Vagrantfile contains the MAC address so that the user doesn't
56
+ # have to worry about it.
57
+ def create_vagrantfile
58
+ File.open(File.join(temp_path, "Vagrantfile"), "w") do |f|
59
+ f.write(TemplateRenderer.render("package_Vagrantfile", {
60
+ :base_mac => @runner.vm.network_adapters.first.mac_address
61
+ }))
62
+ end
63
+ end
64
+
39
65
  def compress
40
- logger.info "Packaging VM into #{tar_path} ..."
66
+ logger.info "Packaging VM into #{tar_path}..."
41
67
  File.open(tar_path, File::CREAT | File::WRONLY, 0644) do |tar|
42
68
  Archive::Tar::Minitar::Output.open(tar) do |output|
43
69
  begin
44
70
  current_dir = FileUtils.pwd
45
71
 
46
- include_files.each do |f|
47
- logger.info "Packaging additional file: #{f}"
48
- Archive::Tar::Minitar.pack_file(f, output)
49
- end
72
+ copy_include_files
73
+ create_vagrantfile
50
74
 
51
75
  FileUtils.cd(temp_path)
52
-
53
- Dir.glob(File.join(".", "*")).each do |entry|
76
+ Dir.glob(File.join(".", "**", "*")).each do |entry|
54
77
  Archive::Tar::Minitar.pack_file(entry, output)
55
78
  end
56
79
  ensure
@@ -19,8 +19,8 @@ module Vagrant
19
19
  end
20
20
 
21
21
  if provisioner.is_a?(Class)
22
- @provisioner = provisioner.new
23
- raise ActionException.new("Provisioners must be an instance of Vagrant::Provisioners::Base") unless @provisioner.is_a?(Provisioners::Base)
22
+ @provisioner = provisioner.new(@runner.env)
23
+ raise ActionException.new(:provisioner_invalid_class) unless @provisioner.is_a?(Provisioners::Base)
24
24
  elsif provisioner.is_a?(Symbol)
25
25
  # We have a few hard coded provisioners for built-ins
26
26
  mapping = {
@@ -29,8 +29,8 @@ module Vagrant
29
29
  }
30
30
 
31
31
  provisioner_klass = mapping[provisioner]
32
- raise ActionException.new("Unknown provisioner type: #{provisioner}") if provisioner_klass.nil?
33
- @provisioner = provisioner_klass.new
32
+ raise ActionException.new(:provisioner_unknown_type, :provisioner => provisioner.to_s) if provisioner_klass.nil?
33
+ @provisioner = provisioner_klass.new(@runner.env)
34
34
  end
35
35
 
36
36
  logger.info "Provisioning enabled with #{@provisioner.class}"
@@ -5,7 +5,7 @@ module Vagrant
5
5
  def prepare
6
6
  steps = [Customize, ForwardPorts, SharedFolders, Boot]
7
7
  steps.unshift(Halt) if @runner.vm.running?
8
- steps << Provision if !Vagrant.config.vm.provisioner.nil?
8
+ steps << Provision if !@runner.env.config.vm.provisioner.nil?
9
9
 
10
10
  steps.each do |action_klass|
11
11
  @runner.add_action(action_klass)
@@ -4,7 +4,7 @@ module Vagrant
4
4
  class Resume < Base
5
5
  def execute!
6
6
  if !@runner.vm.saved?
7
- raise ActionException.new("The vagrant virtual environment you are trying to resume is not in a suspended state.")
7
+ raise ActionException.new(:vm_not_suspended)
8
8
  end
9
9
 
10
10
  logger.info "Resuming suspended VM..."
@@ -3,7 +3,7 @@ module Vagrant
3
3
  module VM
4
4
  class SharedFolders < Base
5
5
  def shared_folders
6
- Vagrant.config.vm.shared_folders.inject([]) do |acc, data|
6
+ @runner.env.config.vm.shared_folders.inject([]) do |acc, data|
7
7
  name, value = data
8
8
  acc << [name, File.expand_path(value[:hostpath]), value[:guestpath]]
9
9
  end
@@ -17,7 +17,7 @@ module Vagrant
17
17
  def after_boot
18
18
  logger.info "Mounting shared folders..."
19
19
 
20
- Vagrant::SSH.execute do |ssh|
20
+ @runner.env.ssh.execute do |ssh|
21
21
  shared_folders.each do |name, hostpath, guestpath|
22
22
  logger.info "-- #{name}: #{guestpath}"
23
23
  ssh.exec!("sudo mkdir -p #{guestpath}")
@@ -43,11 +43,11 @@ module Vagrant
43
43
  shared_folders.each do |name, hostpath, guestpath|
44
44
  folder = VirtualBox::SharedFolder.new
45
45
  folder.name = name
46
- folder.hostpath = hostpath
46
+ folder.host_path = hostpath
47
47
  @runner.vm.shared_folders << folder
48
48
  end
49
49
 
50
- @runner.vm.save(true)
50
+ @runner.vm.save
51
51
  end
52
52
 
53
53
  def mount_folder(ssh, name, guestpath, sleeptime=5)
@@ -57,8 +57,8 @@ module Vagrant
57
57
 
58
58
  # Determine the permission string to attach to the mount command
59
59
  perms = []
60
- perms << "uid=#{Vagrant.config.vm.shared_folder_uid}"
61
- perms << "gid=#{Vagrant.config.vm.shared_folder_gid}"
60
+ perms << "uid=#{@runner.env.config.vm.shared_folder_uid}"
61
+ perms << "gid=#{@runner.env.config.vm.shared_folder_gid}"
62
62
  perms = " -o #{perms.join(",")}" if !perms.empty?
63
63
 
64
64
  attempts = 0
@@ -71,7 +71,7 @@ module Vagrant
71
71
  break unless result
72
72
 
73
73
  attempts += 1
74
- raise ActionException.new("Failed to mount shared folders. vboxsf was not available.") if attempts >= 10
74
+ raise ActionException.new(:vm_mount_fail) if attempts >= 10
75
75
  sleep sleeptime
76
76
  end
77
77
  end
@@ -5,9 +5,10 @@ module Vagrant
5
5
  def prepare
6
6
  # Start is a "meta-action" so it really just queues up a bunch
7
7
  # of other actions in its place:
8
- steps = [ForwardPorts, SharedFolders, Boot]
8
+ steps = [Boot]
9
+ steps.unshift([Customize, ForwardPorts, SharedFolders]) unless @runner.vm.saved?
9
10
 
10
- steps.each do |action_klass|
11
+ steps.flatten.each do |action_klass|
11
12
  @runner.add_action(action_klass)
12
13
  end
13
14
  end
@@ -4,11 +4,11 @@ module Vagrant
4
4
  class Suspend < Base
5
5
  def execute!
6
6
  if !@runner.vm.running?
7
- raise ActionException.new("The vagrant virtual environment you are trying to suspend must be running to be suspended.")
7
+ raise ActionException.new(:vm_not_running_for_suspend)
8
8
  end
9
9
 
10
10
  logger.info "Saving VM state and suspending execution..."
11
- @runner.vm.save_state(true)
11
+ @runner.vm.save_state
12
12
  end
13
13
  end
14
14
  end
@@ -4,25 +4,15 @@ module Vagrant
4
4
  class Up < Base
5
5
  def prepare
6
6
  # If the dotfile is not a file, raise error
7
- if File.exist?(Env.dotfile_path) && !File.file?(Env.dotfile_path)
8
- raise ActionException.new(<<-msg)
9
- The dotfile which Vagrant uses to store the UUID of the project's
10
- virtual machine already exists and is not a file! The dotfile is
11
- currently configured to be `#{Env.dotfile_path}`
12
-
13
- To change this value, please see `config.vagrant.dotfile_name`
14
-
15
- This often exists if you're trying to create a Vagrant virtual
16
- environment from your home directory. To resolve this, you can either
17
- modify the configuration a bit, or simply use a different directory.
18
- msg
7
+ if File.exist?(@runner.env.dotfile_path) && !File.file?(@runner.env.dotfile_path)
8
+ raise ActionException.new(:dotfile_error, :env => @runner.env)
19
9
  end
20
10
 
21
11
  # Up is a "meta-action" so it really just queues up a bunch
22
12
  # of other actions in its place:
23
13
  steps = [Import, Customize, ForwardPorts, SharedFolders, Boot]
24
- steps << Provision if !Vagrant.config.vm.provisioner.nil?
25
- steps.insert(0, MoveHardDrive) if Vagrant.config.vm.hd_location
14
+ steps << Provision if !@runner.env.config.vm.provisioner.nil?
15
+ steps.insert(0, MoveHardDrive) if @runner.env.config.vm.hd_location
26
16
 
27
17
  steps.each do |action_klass|
28
18
  @runner.add_action(action_klass)
@@ -36,13 +26,13 @@ msg
36
26
 
37
27
  def persist
38
28
  logger.info "Persisting the VM UUID (#{@runner.uuid})..."
39
- Env.persist_vm(@runner)
29
+ @runner.env.persist_vm
40
30
  end
41
31
 
42
32
  def setup_mac_address
43
33
  logger.info "Matching MAC addresses..."
44
- @runner.vm.nics.first.macaddress = Vagrant.config[:vm][:base_mac]
45
- @runner.vm.save(true)
34
+ @runner.vm.network_adapters.first.mac_address = @runner.env.config.vm.base_mac
35
+ @runner.vm.save
46
36
  end
47
37
  end
48
38
  end
@@ -6,61 +6,68 @@ module Vagrant
6
6
 
7
7
  @@list = nil
8
8
 
9
- class <<self
10
- # Parses and returns the list of UUIDs from the active VM
11
- # JSON file. This will cache the result, which can be reloaded
12
- # by setting the `reload` parameter to true.
13
- #
14
- # @return [Array<String>]
15
- def list(reload = false)
16
- return @@list unless @@list.nil? || reload
9
+ # The environment this active list belongs to
10
+ attr_accessor :env
17
11
 
18
- @@list ||= []
19
- return @@list unless File.file?(path)
20
- File.open(path, "r") do |f|
21
- @@list = JSON.parse(f.read)
22
- end
12
+ # Creates the instance of the ActiveList, with the given environment
13
+ # if specified
14
+ def initialize(env=nil)
15
+ @env = env
16
+ end
23
17
 
24
- @@list
25
- end
18
+ # Parses and returns the list of UUIDs from the active VM
19
+ # JSON file. This will cache the result, which can be reloaded
20
+ # by setting the `reload` parameter to true.
21
+ #
22
+ # @return [Array<String>]
23
+ def list(reload=false)
24
+ return @list unless @list.nil? || reload
26
25
 
27
- # Returns an array of {Vagrant::VM} objects which are currently
28
- # active.
29
- def vms
30
- list.collect { |uuid| Vagrant::VM.find(uuid) }.compact
26
+ @list ||= []
27
+ return @list unless File.file?(path)
28
+ File.open(path, "r") do |f|
29
+ @list = JSON.parse(f.read)
31
30
  end
32
31
 
33
- # Returns an array of UUIDs filtered so each is verified to exist.
34
- def filtered_list
35
- vms.collect { |vm| vm.uuid }
36
- end
32
+ @list
33
+ end
37
34
 
38
- # Adds a virtual environment to the list of active virtual machines
39
- def add(vm)
40
- list << vm.uuid
41
- list.uniq!
42
- save
43
- end
35
+ # Returns an array of {Vagrant::VM} objects which are currently
36
+ # active.
37
+ def vms
38
+ list.collect { |uuid| Vagrant::VM.find(uuid) }.compact
39
+ end
44
40
 
45
- # Remove a virtual environment from the list of active virtual machines
46
- def remove(vm)
47
- vm = vm.uuid if vm.is_a?(Vagrant::VM)
48
- list.delete(vm)
49
- save
50
- end
41
+ # Returns an array of UUIDs filtered so each is verified to exist.
42
+ def filtered_list
43
+ vms.collect { |vm| vm.uuid }
44
+ end
51
45
 
52
- # Persists the list down to the JSON file.
53
- def save
54
- File.open(path, "w+") do |f|
55
- f.write(filtered_list.to_json)
56
- end
57
- end
46
+ # Adds a virtual environment to the list of active virtual machines
47
+ def add(vm)
48
+ list << vm.uuid
49
+ list.uniq!
50
+ save
51
+ end
58
52
 
59
- # Returns the path to the JSON file which holds the UUIDs of the
60
- # active virtual machines managed by Vagrant.
61
- def path
62
- File.join(Env.home_path, FILENAME)
53
+ # Remove a virtual environment from the list of active virtual machines
54
+ def remove(vm)
55
+ vm = vm.uuid if vm.is_a?(Vagrant::VM)
56
+ list.delete(vm)
57
+ save
58
+ end
59
+
60
+ # Persists the list down to the JSON file.
61
+ def save
62
+ File.open(path, "w+") do |f|
63
+ f.write(filtered_list.to_json)
63
64
  end
64
65
  end
66
+
67
+ # Returns the path to the JSON file which holds the UUIDs of the
68
+ # active virtual machines managed by Vagrant.
69
+ def path
70
+ File.join(env.home_path, FILENAME)
71
+ end
65
72
  end
66
73
  end