vagrant-hostmaster 0.6.12 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,14 @@ require 'vagrant/hostmaster/version'
2
2
  require 'vagrant/hostmaster/command/root'
3
3
  require 'vagrant/hostmaster/config'
4
4
  require 'vagrant/hostmaster/vm'
5
+ require 'vagrant/hostmaster/middleware/remove'
6
+ require 'vagrant/hostmaster/middleware/update'
5
7
 
6
8
  Vagrant.commands.register(:hosts) { Vagrant::Hostmaster::Command::Root }
7
- Vagrant.config_keys.register(:hosts) { Vagrant::Hostmaster::Config }
9
+ Vagrant.config_keys.register(:hosts) { Vagrant::Hostmaster::Config }
10
+ Vagrant.commands.register(:hosts) { Vagrant::Hostmaster::Command::Root }
11
+
12
+ Vagrant.actions[:destroy].insert_after(Vagrant::Action::VM::ProvisionerCleanup, Vagrant::Hostmaster::Middleware::Remove)
13
+
14
+ Vagrant.actions[:provision].insert(Vagrant::Action::VM::Provision, Vagrant::Hostmaster::Middleware::Update)
15
+ Vagrant.actions[:start].insert(Vagrant::Action::VM::Provision, Vagrant::Hostmaster::Middleware::Update)
@@ -12,7 +12,6 @@ module Vagrant
12
12
  return if !argv
13
13
 
14
14
  with_target_vms(argv) do |vm|
15
- @env.ui.info("Removing host entry for #{vm.name} VM. Administrator privileges will be required...", :prefix => false)
16
15
  Hostmaster::VM.new(vm).remove
17
16
  end
18
17
 
@@ -0,0 +1,21 @@
1
+ module Vagrant
2
+ module Hostmaster
3
+ module Middleware
4
+ class Remove
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ remove env[:vm]
11
+ @app.call(env)
12
+ end
13
+
14
+ protected
15
+ def remove(vm)
16
+ Hostmaster::VM.new(vm).remove
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Vagrant
2
+ module Hostmaster
3
+ module Middleware
4
+ class Update
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ update env[:vm]
11
+ @app.call(env)
12
+ end
13
+
14
+ protected
15
+ def update(vm)
16
+ Hostmaster::VM.new(vm).update
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Hostmaster
3
- VERSION = "0.6.12"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -11,20 +11,23 @@ module Vagrant
11
11
  @vm = vm
12
12
  end
13
13
 
14
- def add
14
+ def add(options = {})
15
+ env.ui.info("Adding host entry for #{name} VM. Administrator privileges will be required...") unless options[:quiet]
15
16
  sudo %Q(sh -c 'echo "#{host_entry}" >>/etc/hosts')
16
17
  end
17
18
 
18
- def list
19
+ def list(options = {})
19
20
  system %Q(grep '#{signature}$' /etc/hosts)
20
21
  end
21
22
 
22
- def remove
23
+ def remove(options = {})
24
+ env.ui.info("Removing host entry for #{name} VM. Administrator privileges will be required...") unless options[:quiet]
23
25
  sudo %Q(sed -e '/#{signature}$/ d' -ibak /etc/hosts)
24
26
  end
25
27
 
26
- def update
27
- remove && add
28
+ def update(options = {})
29
+ env.ui.info("Updating host entry for #{name} VM. Administrator privileges will be required...") unless options[:quiet]
30
+ remove(:quiet => true) && add(:quiet => true)
28
31
  end
29
32
 
30
33
  protected
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
8
- - 12
9
- version: 0.6.12
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - S. Brent Faulkner
@@ -64,6 +64,8 @@ files:
64
64
  - lib/vagrant/hostmaster/command/root.rb
65
65
  - lib/vagrant/hostmaster/command/update.rb
66
66
  - lib/vagrant/hostmaster/config.rb
67
+ - lib/vagrant/hostmaster/middleware/remove.rb
68
+ - lib/vagrant/hostmaster/middleware/update.rb
67
69
  - lib/vagrant/hostmaster/version.rb
68
70
  - lib/vagrant/hostmaster/vm.rb
69
71
  - lib/vagrant_init.rb