vagrant-notify 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c08a1c58a9fcfa0470ad77a737f52f2b60cf7971
4
- data.tar.gz: b2a3093c5a9dce8a52c28aa8dc90b2e95ef68f07
3
+ metadata.gz: ba4fc9493cec21bcfb25014ba736fb42b5fec41f
4
+ data.tar.gz: a8d46b48d1b215007f65ad3fb5278d4a6810f244
5
5
  SHA512:
6
- metadata.gz: 479ab1f5e182e41f8e15ed05e3f91ecd66e044276c3eb6b60059f175babf5c42447ed2de497827abd3f482d83db67d543596ce73235adbfaeb1e5efd067c696e
7
- data.tar.gz: e91676a8f4795be0f42f442091c7e7fe25902f45448355c33b7b96da0ea798c9a0e696cd66d873d4654cd89a1ad499185b72dec7761921579bbecad68041862f
6
+ metadata.gz: af4894a0012437cbd6a81c13a3ada7fa8a2e8dbfe270c0f44732c23b15a92248382fa61300c3bee07bf93edcd827b5d24a417d7cfef9f3ddd14eb56b84602dad
7
+ data.tar.gz: 2f82cfb35c78298f9de96d417d23fad6060a0c292ec5005940e6b5e5c4173a7dc6545f91fc7729d45c672711df5f50057c36aeb067b69ffeb292ed8c320b110c
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ ## [0.4.0](https://github.com/fgrehm/vagrant-notify/compare/v0.3.0...master) (Feb 26, 2014)
2
+
3
+ IMPROVEMENTS
4
+
5
+ - Notify provisioning status on Vagrant 1.4+ [[GH-5]]
6
+ - Make use of `$SSH_CLIENT` when identifying host's IP to connect
7
+
8
+ BUG FIXES
9
+
10
+ - Fix "rm: cannot remove ‘/usr/bin/notify-send’: No such file or directory" [[GH-11]]
11
+
12
+ ## Previous
13
+
14
+ The changelog began with version 0.4.0 so any changes prior to that
15
+ can be seen by checking the tagged releases and reading git commit
16
+ messages.
17
+
18
+
19
+ [GH-5]:https://github.com/fgrehm/vagrant-notify/issues/5
20
+ [GH-11]:https://github.com/fgrehm/vagrant-notify/issues/11
data/Gemfile.lock CHANGED
@@ -1,25 +1,25 @@
1
1
  GIT
2
2
  remote: git://github.com/fgrehm/vagrant-lxc.git
3
- revision: d2e354839f404ef426bdee38e50c9b3256e1e3c2
3
+ revision: c19bc91e708f7a69b62e35f465b5246bf5706cc3
4
4
  specs:
5
- vagrant-lxc (0.4.1.dev)
5
+ vagrant-lxc (0.7.1.dev)
6
6
 
7
7
  GIT
8
8
  remote: git://github.com/mitchellh/vagrant.git
9
- revision: e98e8bf9d768cc9be244fb61883a907253b11f08
9
+ revision: e3734a7a46c39cd73e79538980dd98aeaeca9656
10
10
  specs:
11
- vagrant (1.2.7.dev)
11
+ vagrant (1.4.2.dev)
12
12
  childprocess (~> 0.3.7)
13
13
  erubis (~> 2.7.0)
14
14
  i18n (~> 0.6.0)
15
15
  log4r (~> 1.1.9)
16
16
  net-scp (~> 1.1.0)
17
- net-ssh (~> 2.6.6)
17
+ net-ssh (>= 2.6.6, < 2.8.0)
18
18
 
19
19
  PATH
20
20
  remote: .
21
21
  specs:
22
- vagrant-notify (0.3.0)
22
+ vagrant-notify (0.4.0)
23
23
 
24
24
  GEM
25
25
  remote: https://rubygems.org/
@@ -29,7 +29,7 @@ GEM
29
29
  coderay (1.0.9)
30
30
  diff-lcs (1.2.4)
31
31
  erubis (2.7.0)
32
- ffi (1.9.0)
32
+ ffi (1.9.3)
33
33
  formatador (0.2.4)
34
34
  guard (1.8.1)
35
35
  formatador (>= 0.2.4)
@@ -40,7 +40,7 @@ GEM
40
40
  guard-rspec (3.0.2)
41
41
  guard (>= 1.8)
42
42
  rspec (~> 2.13)
43
- i18n (0.6.4)
43
+ i18n (0.6.9)
44
44
  listen (1.2.2)
45
45
  rb-fsevent (>= 0.9.3)
46
46
  rb-inotify (>= 0.9)
@@ -50,7 +50,7 @@ GEM
50
50
  method_source (0.8.2)
51
51
  net-scp (1.1.2)
52
52
  net-ssh (>= 2.6.5)
53
- net-ssh (2.6.8)
53
+ net-ssh (2.7.0)
54
54
  pry (0.9.12.2)
55
55
  coderay (~> 1.0.5)
56
56
  method_source (~> 0.8)
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Fabio Rehm
1
+ Copyright (c) 2012-2014 Fabio Rehm
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,31 +1,65 @@
1
- # Vagrant::Notify
1
+ # vagrant-notify
2
2
 
3
3
  [![Build Status](https://travis-ci.org/fgrehm/vagrant-notify.png)](https://travis-ci.org/fgrehm/vagrant-notify)
4
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/fgrehm/vagrant-notify)
4
+ [![Gem Version](https://badge.fury.io/rb/vagrant-notify.png)](http://badge.fury.io/rb/vagrant-notify)
5
+ [![Gittip](http://img.shields.io/gittip/fgrehm.svg)](https://www.gittip.com/fgrehm/)
6
+
7
+ A Vagrant plugin that forwards `notify-send` from guest to host machine and
8
+ notifies provisioning status. [See it in action](#demo)
5
9
 
6
- A Vagrant plugin that forwards `notify-send` from guest to host machine, tested
7
- using Ubuntu as guest and host machine.
8
10
 
9
11
  ## Installation
10
12
 
11
- Make sure you have Vagrant >= 1.1 around and run:
13
+ Make sure you have Vagrant 1.4+ around and run:
12
14
 
13
15
  ```terminal
14
16
  $ vagrant plugin install vagrant-notify
15
17
  ```
16
18
 
17
19
 
18
-
19
20
  ## Usage
20
21
 
22
+ ### `notify-send` from guest VMs
23
+
21
24
  Whenever you run `vagrant up`, a Ruby [TCPServer](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/TCPServer.html)
22
25
  will fire up on a port within the [usable port range](https://github.com/mitchellh/vagrant/blob/master/config/default.rb#L14)
23
26
  and a [script](https://github.com/fgrehm/vagrant-notify/blob/master/files/notify-send.erb)
24
27
  will be copied over to the guest machine to replace the original `notify-send`
25
28
  command.
26
29
 
27
- If by any chance your IP changes, you can run `vagrant provision` in order to
28
- update the guest script with the new IP.
30
+ ### Provisioning notification
31
+
32
+ Apart from redirecting `notify-send` from the guest VM to the host, whenever
33
+ a Vagrant provisioner completes running you'll also receive a notification
34
+ like:
35
+
36
+ ![provisioning](http://i.imgur.com/DgKjDgr.png)
37
+
38
+ ![provisioned](http://i.imgur.com/UGhOAzV.png)
39
+
40
+
41
+ ### Linux
42
+
43
+ Since Linux distributions have `notify-send` pre-installed, everything should work out of the box.
44
+
45
+ ### OS X
46
+
47
+ You will need to create a `notify-send` script, available on `$PATH`. The script can forward the message to either
48
+ [Growl](http://growl.info/) with [GrowlNotify](http://growl.info/downloads) (version 1.2.2 is free but unreliable)
49
+ or to the [Notification Center](http://support.apple.com/kb/HT5362) available on OS X 10.8+
50
+ using f.ex. [terminal-notifier](https://github.com/alloy/terminal-notifier).
51
+
52
+ A (too) primitive script integrating with Growl:
53
+
54
+ ```bash
55
+ #!/bin/bash
56
+ growlnotify -t "Vagrant VM" -m "$*"
57
+ ```
58
+
59
+ ## Demo
60
+
61
+ ![Demo](http://i.imgur.com/tzOLvGY.gif)
62
+
29
63
 
30
64
  ## Known issues
31
65
 
@@ -5,8 +5,8 @@ Vagrant.require_plugin 'vagrant-notify'
5
5
  Vagrant.require_plugin 'vagrant-lxc'
6
6
 
7
7
  Vagrant.configure("2") do |config|
8
- config.vm.box = "base"
9
- config.vm.box = "quantal64"
8
+ config.vm.box = "raring64"
9
+ config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
10
10
 
11
11
  config.vm.define :vm1
12
12
  config.vm.define :vm2
@@ -40,6 +40,7 @@ unless ARGV.empty?
40
40
  cmd << ARGV.map{|a| "'#{a}'"}.join(' ')
41
41
  end
42
42
 
43
- TCPSocket.open "<%= host_ip %>", <%= host_port %> do |s|
43
+ client_ip = ENV['SSH_CLIENT'].split(' ')[0]
44
+ TCPSocket.open ENV['SSH_CLIENT'], <%= host_port %> do |s|
44
45
  s.send cmd, 0
45
46
  end
@@ -1,26 +1,15 @@
1
1
  require_relative 'action/check_provider'
2
2
  require_relative 'action/install_command'
3
+ require_relative 'action/notify_provisioning_status'
3
4
  require_relative 'action/prepare_data'
4
5
  require_relative 'action/server_is_running'
6
+ require_relative 'action/set_shared_folder'
5
7
  require_relative 'action/start_server'
6
8
  require_relative 'action/stop_server'
7
9
 
8
10
  module Vagrant
9
11
  module Notify
10
12
  module Action
11
- class SetSharedFolder
12
- def initialize(app, env)
13
- @app = app
14
- end
15
-
16
- def call(env)
17
- host_dir = Pathname("/tmp/vagrant-notify/#{env[:machine].id}")
18
- FileUtils.mkdir_p host_dir.to_s unless host_dir.exist?
19
- env[:machine].config.vm.synced_folder host_dir, "/tmp/vagrant-notify", id: "vagrant-notify"
20
- @app.call(env)
21
- end
22
- end
23
-
24
13
  class << self
25
14
  Call = Vagrant::Action::Builtin::Call
26
15
 
@@ -17,7 +17,7 @@ module Vagrant
17
17
 
18
18
  def compile_command(env)
19
19
  host_port = env[:notify_data][:port]
20
- template_binding = OpenStruct.new(:host_ip => local_ip, :host_port => host_port, :shared_folder => '/tmp/vagrant-notify')
20
+ template_binding = OpenStruct.new(:host_port => host_port, :shared_folder => '/tmp/vagrant-notify')
21
21
  command_template = ERB.new(Vagrant::Notify.files_path.join('notify-send.erb').read)
22
22
  command = command_template.result(template_binding.instance_eval { binding })
23
23
 
@@ -30,29 +30,6 @@ module Vagrant
30
30
  env[:machine].communicate.sudo('mv /usr/bin/{notify-send,notify-send.bkp}; exit 0')
31
31
  env[:machine].communicate.sudo('mv /tmp/notify-send /usr/bin/notify-send && chmod +x /usr/bin/notify-send')
32
32
  end
33
-
34
- ##
35
- # Returns the local IP address of the host running the vagrant VMs.
36
- #
37
- # Thanks to:
38
- # https://github.com/fnichol/vagrant-butter/blob/master/lib/vagrant/butter/helpers.rb
39
- # https://github.com/jedi4ever/veewee/blob/c75a5b175c5b8ac7e5aa3341e93493923d0c7af0/lib/veewee/session.rb#L622
40
- #
41
- # @return [String] the local IP address
42
- def local_ip
43
- @local_ip ||= begin
44
- # turn off reverse DNS resolution temporarily
45
- orig, Socket.do_not_reverse_lookup =
46
- Socket.do_not_reverse_lookup, true
47
-
48
- UDPSocket.open do |s|
49
- s.connect '64.233.187.99', 1
50
- s.addr.last
51
- end
52
- ensure
53
- Socket.do_not_reverse_lookup = orig
54
- end
55
- end
56
33
  end
57
34
  end
58
35
  end
@@ -0,0 +1,17 @@
1
+ module Vagrant
2
+ module Notify
3
+ module Action
4
+ class NotifyProvisioningStatus
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ system("notify-send '[#{env[:machine].name}] Provisioning with \"#{env[:provisioner_name]}\"...'")
11
+ @app.call(env)
12
+ system("notify-send '[#{env[:machine].name}] Finished provisioning with \"#{env[:provisioner_name]}\"'")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Vagrant
2
+ module Notify
3
+ module Action
4
+ class SetSharedFolder
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ host_dir = Pathname("/tmp/vagrant-notify/#{env[:machine].id}")
11
+ FileUtils.mkdir_p host_dir.to_s unless host_dir.exist?
12
+ env[:machine].config.vm.synced_folder host_dir, "/tmp/vagrant-notify", id: "vagrant-notify"
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,8 +7,10 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:machine].communicate.sudo('rm /usr/bin/notify-send')
11
- env[:machine].communicate.sudo('mv /usr/bin/{notify-send.bkp,notify-send}; exit 0')
10
+ if env[:machine].state.id == :running
11
+ env[:machine].communicate.sudo('rm /usr/bin/notify-send; exit 0')
12
+ env[:machine].communicate.sudo('mv /usr/bin/{notify-send.bkp,notify-send}; exit 0')
13
+ end
12
14
 
13
15
  @app.call env
14
16
 
@@ -4,19 +4,26 @@ module Vagrant
4
4
  name 'vagrant notify'
5
5
  description 'Forwards notify-send from guest to host machine'
6
6
 
7
+ action_hook 'notify-provisioning-status', :provisioner_run do |hook|
8
+ require_relative './action'
9
+ hook.before :run_provisioner, Vagrant::Notify::Action::NotifyProvisioningStatus
10
+ end
11
+
7
12
  # TODO: This should be generic, we don't want to hard code every single
8
13
  # possible provider action class that Vagrant might have
9
- action_hook 'start-server-after-boot' do |hook|
14
+ start_server_hook = lambda do |hook|
10
15
  require_relative './action'
11
16
  hook.after VagrantPlugins::ProviderVirtualBox::Action::Boot, Vagrant::Notify::Action.action_start_server
12
17
 
13
18
  if defined?(Vagrant::LXC)
14
- # TODO: Require just the boot action file once its "require dependencies" are sorted out
15
19
  require 'vagrant-lxc/action'
16
20
  hook.after Vagrant::LXC::Action::Boot, Vagrant::Notify::Action.action_start_server
17
21
  end
18
22
  end
19
23
 
24
+ action_hook 'start-server-after-boot-on-machine-up', :machine_action_up, &start_server_hook
25
+ action_hook 'start-server-after-boot-on-machine-reload', :machine_action_reload, &start_server_hook
26
+
20
27
  share_folder_hook = lambda do |hook|
21
28
  require_relative './action'
22
29
  hook.after Vagrant::Action::Builtin::Provision, Vagrant::Notify::Action::SetSharedFolder
@@ -24,7 +31,7 @@ module Vagrant
24
31
  action_hook 'set-shared-folder-and-start-notify-server-on-machine-up', :machine_action_up, &share_folder_hook
25
32
  action_hook 'set-shared-folder-and-start-notify-server-on-machine-reload', :machine_action_reload, &share_folder_hook
26
33
 
27
- action_hook 'stop-server-after-halt' do |hook|
34
+ action_hook 'stop-server-after-halt', :machine_action_halt do |hook|
28
35
  require_relative './action'
29
36
  hook.before Vagrant::Action::Builtin::GracefulHalt, Vagrant::Notify::Action.action_stop_server
30
37
  end
@@ -36,7 +43,6 @@ module Vagrant
36
43
  hook.before VagrantPlugins::ProviderVirtualBox::Action::Destroy, Vagrant::Notify::Action.action_stop_server
37
44
 
38
45
  if defined?(Vagrant::LXC)
39
- # TODO: Require just the destroy action file once its "require dependencies" are sorted out
40
46
  require 'vagrant-lxc/action'
41
47
  hook.before Vagrant::LXC::Action::Destroy, Vagrant::Notify::Action.action_stop_server
42
48
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Notify
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -14,20 +14,19 @@ describe Vagrant::Notify::Action::InstallCommand do
14
14
  let(:tmp_cmd_path) { tmp_path.join('vagrant-notify-send') }
15
15
  let(:guest_tmp_path) { '/tmp/notify-send' }
16
16
  let(:guest_path) { '/usr/bin/notify-send' }
17
- let(:stubbed_template) { ERB.new('<%= host_ip %> <%= host_port %>') }
17
+ let(:stubbed_template) { ERB.new('<%= host_port %>') }
18
18
 
19
19
  subject { described_class.new(app, env) }
20
20
 
21
21
  before do
22
22
  ERB.stub(:new => stubbed_template)
23
- subject.stub(local_ip: host_ip)
24
23
  subject.call(env)
25
24
  end
26
25
 
27
26
  after { FileUtils.rm_rf tmp_path.to_s }
28
27
 
29
- it 'compiles command script passing host ip and server port' do
30
- tmp_cmd_path.read.should == "#{host_ip} #{host_port}"
28
+ it 'compiles command script passing server port' do
29
+ tmp_cmd_path.read.should == "#{host_port}"
31
30
  end
32
31
 
33
32
  it 'uploads compiled command script over to guest machine' do
@@ -5,7 +5,7 @@ require 'vagrant-notify/action/stop_server'
5
5
  describe Vagrant::Notify::Action::StopServer do
6
6
  let(:app) { lambda { |env| } }
7
7
  let(:communicator) { mock(sudo: true) }
8
- let(:machine) { mock(communicate: communicator) }
8
+ let(:machine) { mock(communicate: communicator, state: stub(id: :running)) }
9
9
  let(:env) { {notify_data: {pid: pid, port: 1234}, machine: machine} }
10
10
  let(:pid) { '42' }
11
11
  let(:port) { described_class::PORT }
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Vagrant::Notify::VERSION
9
9
  gem.authors = ["Fabio Rehm"]
10
10
  gem.email = ["fgrehm@gmail.com"]
11
- gem.description = 'A Vagrant plugin that redirects system notifications from guest to host machine.'
11
+ gem.description = 'A Vagrant plugin that forwards `notify-send` from guest to host machine and notifies provisioning status'
12
12
  gem.summary = gem.description
13
13
  gem.homepage = "https://github.com/fgrehm/vagrant-notify"
14
14
 
metadata CHANGED
@@ -1,26 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rehm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-29 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A Vagrant plugin that redirects system notifications from guest to host
14
- machine.
13
+ description: A Vagrant plugin that forwards `notify-send` from guest to host machine
14
+ and notifies provisioning status
15
15
  email:
16
16
  - fgrehm@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - .gitignore
22
- - .rspec
23
- - .travis.yml
21
+ - ".gitignore"
22
+ - ".rspec"
23
+ - ".travis.yml"
24
+ - CHANGELOG.md
24
25
  - Gemfile
25
26
  - Gemfile.lock
26
27
  - Guardfile
@@ -33,8 +34,10 @@ files:
33
34
  - lib/vagrant-notify/action.rb
34
35
  - lib/vagrant-notify/action/check_provider.rb
35
36
  - lib/vagrant-notify/action/install_command.rb
37
+ - lib/vagrant-notify/action/notify_provisioning_status.rb
36
38
  - lib/vagrant-notify/action/prepare_data.rb
37
39
  - lib/vagrant-notify/action/server_is_running.rb
40
+ - lib/vagrant-notify/action/set_shared_folder.rb
38
41
  - lib/vagrant-notify/action/start_server.rb
39
42
  - lib/vagrant-notify/action/stop_server.rb
40
43
  - lib/vagrant-notify/data.rb
@@ -59,20 +62,21 @@ require_paths:
59
62
  - lib
60
63
  required_ruby_version: !ruby/object:Gem::Requirement
61
64
  requirements:
62
- - - '>='
65
+ - - ">="
63
66
  - !ruby/object:Gem::Version
64
67
  version: '0'
65
68
  required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements:
67
- - - '>='
70
+ - - ">="
68
71
  - !ruby/object:Gem::Version
69
72
  version: '0'
70
73
  requirements: []
71
74
  rubyforge_project:
72
- rubygems_version: 2.0.0
75
+ rubygems_version: 2.2.2
73
76
  signing_key:
74
77
  specification_version: 4
75
- summary: A Vagrant plugin that redirects system notifications from guest to host machine.
78
+ summary: A Vagrant plugin that forwards `notify-send` from guest to host machine and
79
+ notifies provisioning status
76
80
  test_files:
77
81
  - spec/action/install_command_spec.rb
78
82
  - spec/action/prepare_data_spec.rb