vagrant-notify 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3f06401113919234836bb523fe7c76febdde45b
4
- data.tar.gz: f7cb2652a42a65b648adbfda7eb700e769a8d28b
3
+ metadata.gz: 147e8cd55fe84bc3a668961b660d1390ed5d7e34
4
+ data.tar.gz: 315a4ec49f89f72c9a73b5ac03df91274ea56289
5
5
  SHA512:
6
- metadata.gz: 42f8ed1ad51e9de58df011dc50d5949d852fd852d19248f708558e119ee6f9a25ecd2895c0727671a3dbdb9913dd0650635febb1b8a65034cc3c359e73e4c92d
7
- data.tar.gz: 809382012aaf777f192da1152bc360254d142f5b178540256b1f7e342781bfdd4dda55cf92cd32b36e8c767ed0a29ebcf5d893dec8d8feae311cacaffb0cbcc6
6
+ metadata.gz: ed87d3c11b85beea60b89d4d6a7982ccd2f5a93ddafe85497914bce996220b15a6921364d1d9d9e966fda3e84641c71e02eeb53454e5a738bfa220950a1dba1a
7
+ data.tar.gz: aeb2356140cf699eb676b461ec6e2ba9f972b0f1cded0bce2d1e97988ad8fcaead4fa8d90e584e7fa0f1c7399d724d19f613f5b120781fe8aa2d640a5e36b68c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
+ ## [0.5.1](https://github.com/fgrehm/vagrant-notify/compare/v0.5.0...v0.5.1) (July 23, 2016)
2
+ IMPROVEMENTS
3
+ - New config option to disable plugin. [[GH-6]]
4
+ - Plugin will automatically be disabled for cloud providers. [[GH-15]]
5
+ - Solaris 11 and BSD guests are now supported.
6
+ - Windows snarl wrapper script.
7
+ - OS X growlnotify 1.2.2 wrapper script.
8
+
9
+ BUG FIXES
1
10
 
11
+ - All single quotes that are part of the title or message get removed.
2
12
 
3
13
  ## [0.5.0](https://github.com/fgrehm/vagrant-notify/compare/v0.4.0...v0.5.0) (June 21, 2016)
4
14
 
data/Gemfile.lock CHANGED
@@ -19,7 +19,7 @@ GIT
19
19
  PATH
20
20
  remote: .
21
21
  specs:
22
- vagrant-notify (0.5.0)
22
+ vagrant-notify (0.5.1)
23
23
 
24
24
  GEM
25
25
  remote: https://rubygems.org/
@@ -91,4 +91,4 @@ DEPENDENCIES
91
91
  vagrant-notify!
92
92
 
93
93
  BUNDLED WITH
94
- 1.10.6
94
+ 1.12.2
data/README.md CHANGED
@@ -55,14 +55,24 @@ A (too) primitive script integrating with Growl:
55
55
  growlnotify -t "Vagrant VM" -m "$*"
56
56
  ```
57
57
 
58
- See example [scripts](https://github.com/fgrehm/vagrant-notify/tree/master/examples).
58
+ Check out our OS X notify-send compatible [scripts](https://github.com/fgrehm/vagrant-notify/tree/master/examples).
59
59
 
60
60
  ### Windows (beta)
61
61
 
62
62
  You can use the freeware application [notify-send for Windows](http://vaskovsky.net/notify-send/), make sure the notify-send binary is available on `Path`.
63
63
 
64
- See example [scripts](https://github.com/fgrehm/vagrant-notify/tree/master/examples).
64
+ Check out our Windows notify-send compatible [scripts](https://github.com/fgrehm/vagrant-notify/tree/master/examples).
65
65
 
66
+ ## Configuration
67
+
68
+ Notifcation server is enabled by default on all VMs. You can individually disable the plugin by adding the following to your `Vagrantfile`
69
+
70
+ ```ruby
71
+ config.notify.enable = false
72
+ ```
73
+
74
+ _Please note that as of v0.5.1, the notification server will automatically be disabled for any of the following
75
+ [cloud providers](lib/vagrant-notify/plugin.rb#L72-74)_
66
76
 
67
77
  ## Demo
68
78
 
@@ -5,9 +5,10 @@ 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 = "raring64"
8
+ config.vm.box = "ubuntu/trusty64"
9
9
  config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
10
10
 
11
11
  config.vm.define :vm1
12
12
  config.vm.define :vm2
13
+ config.notify.enable = true
13
14
  end
data/examples/README.md CHANGED
@@ -3,14 +3,20 @@
3
3
  ## OS X
4
4
 
5
5
  * [terminal-notifier](https://github.com/alloy/terminal-notifier) [wrapper script](https://github.com/fgrehm/vagrant-notify/blob/master/examples/osx/notify-send_terminal-notifier)
6
+ * [growlnotify](http://growl.info/downloads) [wrapper script](https://github.com/fgrehm/vagrant-notify/blob/master/examples/osx/notify-send_growl_for_mac)
6
7
 
7
8
 
8
9
  ## Windows
9
10
 
11
+ **IMPORTANT:** In addition of `notify-send` being in your `path`, the `notify-send` wrapper script has to be binary executable.
12
+ Compiling using ocra:
13
+
14
+ ocra --output notify-send windows/notify-send_growl_for_snarl
15
+
16
+
10
17
  * [Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx) [wrapper script](https://github.com/fgrehm/vagrant-notify/blob/master/examples/windows/notify-send_growl_for_windows)
11
18
 
12
- **IMPORTANT:** `notify-send` wrapper script has to be binary executable. Also as with `notify-send`, `growlnotify.exe` needs to be is in your `path`.
19
+ `growlnotify.exe` needs to be is in your `path`.
13
20
 
14
- Compiling using ocra:
15
21
 
16
- ocra --output notify-send windows/notify-send_growl_for_windows
22
+ * [Snarl](http://snarl.fullphat.net/) [wrapper script](https://github.com/fgrehm/vagrant-notify/blob/master/examples/windows/notify-send_snarl)
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ # Example OS X growlnotify 1.2.2 notify-send wrapper script.
6
+
7
+ require 'optparse'
8
+
9
+
10
+ options = {}
11
+ OptionParser.new do |opts|
12
+ opts.on('-u', '--urgency LEVEL') { |v| options[:u] = v } # TO DO: set to --priority
13
+ opts.on('-t', '--expire-time TIME') { |v| options[:t] = v } # Option gets removed
14
+ opts.on('-a', '--app-name APP_NAME') { |v| options[:a] = v } # Set to --name
15
+ opts.on('-i', '--icon ICON[,ICON...]') { |v| options[:i] = v } # Set to --image
16
+ opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:c] = v } # Option gets removed
17
+ opts.on('-h', '--hint TYPE:NAME:VALUE') { |v| options[:h] = v } # Option gets removed
18
+ opts.on('-v', '--version') { |v| options[:v] = v } # Option gets removed
19
+ end.parse!
20
+
21
+
22
+ if ARGV.length == 0
23
+ puts "No summary specified"
24
+ exit 1
25
+ elsif ARGV.length == 1
26
+ message = "--message '#{ARGV[0]}'"
27
+ message << " --name #{options[:a]}" if options.include?(:a)
28
+ message << " --image #{options[:i]}" if options.include?(:i)
29
+ elsif ARGV.length == 2
30
+ message = "--title '#{ARGV[0]}' --message '#{ARGV[1]}'"
31
+ message << " --name #{options[:a]}" if options.include?(:a)
32
+ message << " --image #{options[:i]}" if options.include?(:i)
33
+ else
34
+ puts "Invalid number of options."
35
+ exit 1
36
+ end
37
+
38
+ system("growlnotify #{message} 2>/dev/null")
@@ -27,7 +27,8 @@ elsif ARGV.length == 1
27
27
  elsif ARGV.length == 2
28
28
  message = "-title '\\#{ARGV[0]}' -message '\\#{ARGV[1]}'"
29
29
  else
30
- message = ARGV.map{|a| a =~ /-(title|message)/ ? a : "'\\#{a}'"}.join(' ')
30
+ puts "Invalid number of options."
31
+ exit 1
31
32
  end
32
33
 
33
34
  system("terminal-notifier -sound default #{message}")
@@ -25,12 +25,12 @@ if ARGV.length == 0
25
25
  puts "No summary specified"
26
26
  elsif ARGV.length == 1
27
27
  message = "'#{ARGV[0]}'"
28
- system("growlnotify.exe \"#{message}\"")
29
28
  elsif ARGV.length == 2
30
29
  title = "/t:'#{ARGV[0]}'"
31
30
  message = "'#{ARGV[1]}'"
32
- system("growlnotify.exe \"#{title}\" \"#{message}\"")
33
31
  else
34
- message = ARGV.map{|a| "'#{a}'"}.join(' ')
35
- system("growlnotify.exe \"#{message}\"")
32
+ puts "Invalid number of options."
33
+ exit 1
36
34
  end
35
+
36
+ system("growlnotify.exe \"#{message}\"")
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ # Example MS-Windows Snarl SNP/HTTP notify-send wrapper script.
6
+
7
+ require 'optparse'
8
+ require 'uri'
9
+ require "net/http"
10
+
11
+
12
+ options = {}
13
+ OptionParser.new do |opts|
14
+ opts.on('-u', '--urgency LEVEL') { |v| options[:u] = v } # TO DO: set to priority
15
+ opts.on('-t', '--expire-time TIME') { |v| options[:t] = v } # Set to timeout (notify-send milliseconds to snarl seconds)
16
+ opts.on('-a', '--app-name APP_NAME') { |v| options[:a] = v } # Option gets removed
17
+ opts.on('-i', '--icon ICON[,ICON...]') { |v| options[:i] = v } # Option gets removed (Snarl does not properly handle masked git-bash/cygwin absoute paths)
18
+ opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:c] = v } # Option gets removed
19
+ opts.on('-h', '--hint TYPE:NAME:VALUE') { |v| options[:h] = v } # Option gets removed
20
+ opts.on('-v', '--version') { |v| options[:v] = v } # Option gets removed
21
+ end.parse!
22
+
23
+
24
+ if ARGV.length == 0
25
+ puts "No summary specified"
26
+ exit 1
27
+ elsif ARGV.length == 1
28
+ message = "notify?text='#{ARGV[0]}'"
29
+ message << "&timeout=#{options[:t].to_i / 1000}'" if options.include?(:t)
30
+ elsif ARGV.length == 2
31
+ message = "notify?title='#{ARGV[0]}'&text='#{ARGV[1]}'"
32
+ message << "&timeout=#{options[:t].to_i / 1000}'" if options.include?(:t)
33
+ else
34
+ puts "Invalid number of options."
35
+ exit 1
36
+ end
37
+
38
+ enc_uri = URI.escape(message)
39
+ uri = URI.parse("http://127.0.0.1/#{enc_uri}")
40
+ #puts uri
41
+
42
+ Net::HTTP.get_response(uri)
43
+
44
+
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  # -*- mode: ruby -*-
3
3
  # vi: set ft=ruby :
4
4
 
@@ -36,10 +36,15 @@ end.join(' ')
36
36
 
37
37
  # TODO: Need to escape values
38
38
  unless ARGV.empty?
39
- cmd << ARGV.map{|a| " '#{a}'"}.join(' ')
39
+ cmd << ARGV.map{|a| " '#{a.gsub(/'/, "")}'"}.join(' ')
40
+ end
41
+
42
+ if RUBY_PLATFORM =~ /linux/
43
+ client_ip = `ip route|awk '/default/ {print $3}'`
44
+ elsif RUBY_PLATFORM =~ /solaris|freebsd|openbsd|netbsd/
45
+ client_ip = `netstat -r|awk '/default/ {print $2}'`
40
46
  end
41
47
 
42
- client_ip = `ip route|grep default|awk '{print $3}'`
43
48
  TCPSocket.open client_ip, <%= host_port %> do |s|
44
49
  s.send cmd, 0
45
50
  end
@@ -7,6 +7,8 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
+ return if env[:machine].config.notify.enable == false
11
+
10
12
  path = compile_command(env, 'notify-send.erb')
11
13
  install_command_on_guest(env, path)
12
14
 
@@ -6,11 +6,17 @@ module Vagrant
6
6
  @app = app
7
7
  end
8
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)
9
+ def call(env)
10
+ begin
11
+ unless env[:machine].config.notify.enable == false
12
+ host_dir = Pathname("/tmp/vagrant-notify/#{env[:machine].id}")
13
+ FileUtils.mkdir_p host_dir.to_s unless host_dir.exist?
14
+ env[:machine].config.vm.synced_folder host_dir, "/tmp/vagrant-notify", id: "vagrant-notify"
15
+ end
16
+ @app.call(env)
17
+ rescue
18
+ env[:machine].ui.warn("vagrant-notify: guest does not support the shared folder capability.")
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -17,6 +17,8 @@ module Vagrant
17
17
  port = next_available_port
18
18
  id = env[:machine].id
19
19
  dir = File.expand_path('../../', __FILE__)
20
+
21
+ return if env[:machine].config.notify.enable == false
20
22
 
21
23
  if which('ruby')
22
24
  env[:notify_data][:pid] = Process.spawn("ruby #{dir}/server.rb #{id} #{port}")
@@ -29,6 +31,7 @@ module Vagrant
29
31
  end
30
32
 
31
33
  @app.call env
34
+
32
35
  end
33
36
 
34
37
  def next_available_port
@@ -7,6 +7,9 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
+
11
+ return if env[:machine].config.notify.enable == false
12
+
10
13
  if env[:machine].state.id == :running
11
14
  env[:machine].communicate.sudo('rm /usr/bin/notify-send; exit 0')
12
15
  env[:machine].communicate.sudo('mv /usr/bin/{notify-send.bkp,notify-send}; exit 0')
@@ -63,7 +63,11 @@ module Vagrant
63
63
  if env2[:result]
64
64
  env[:machine].ui.success("vagrant-notify-server pid: #{env2[:notify_data][:pid]}")
65
65
  else
66
- env[:machine].ui.error("No vagrant-notify server detected.")
66
+ if env[:machine].config.notify.enable == false
67
+ env[:machine].ui.error("No vagrant-notify server detected. Disabled in Vagrantfile")
68
+ else
69
+ env[:machine].ui.error("No vagrant-notify server detected.")
70
+ end
67
71
  end
68
72
  end
69
73
  end
@@ -0,0 +1,39 @@
1
+ module Vagrant
2
+ module Notify
3
+ class Config < Vagrant.plugin(2, :config)
4
+ attr_accessor :enable
5
+
6
+ def initialize()
7
+ @enable = UNSET_VALUE
8
+ end
9
+
10
+ def validate(machine)
11
+ errors = _detected_errors
12
+
13
+ if backed_by_cloud_provider?(machine)
14
+ machine.ui.warn("Disabling vagrant-notify, cloud provider #{machine.provider_name} in use.")
15
+
16
+ @enable = false
17
+ end
18
+
19
+ if @enable != 0
20
+ if @enable != false && @enable != true
21
+ errors << "Unknown option: #{@enable}"
22
+
23
+ { "notify" => errors }
24
+ end
25
+ end
26
+ end
27
+
28
+ def finalize!
29
+ @enable = 0 if @enable == UNSET_VALUE
30
+ end
31
+
32
+ private
33
+
34
+ def backed_by_cloud_provider?(machine)
35
+ CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -59,6 +59,17 @@ module Vagrant
59
59
  require_relative 'command'
60
60
  Vagrant::Notify::Command
61
61
  end
62
+
63
+ config(:notify) do
64
+ require_relative 'config'
65
+ Vagrant::Notify::Config
66
+ end
62
67
  end
63
68
  end
69
+
70
+ # Keep an eye on https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins#wiki-providers
71
+ # for more.
72
+ CLOUD_PROVIDERS = %w( aws cloudstack digital_ocean hp joyent openstack rackspace
73
+ softlayer proxmox managed azure brightbox cloudstack vcloud
74
+ vsphere )
64
75
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Notify
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -5,9 +5,10 @@ require 'vagrant-notify/action/install_command'
5
5
 
6
6
  describe Vagrant::Notify::Action::InstallCommand do
7
7
  let(:app) { lambda { |env| } }
8
+ let(:config) { mock(notify: stub(enable: true)) }
8
9
  let(:env) { {notify_data: {port: host_port}, machine: machine, tmp_path: tmp_path} }
9
10
  let(:host_port) { 12345 }
10
- let(:machine) { mock(communicate: communicator) }
11
+ let(:machine) { mock(communicate: communicator, config: config) }
11
12
  let(:communicator) { mock(upload: true, sudo: true) }
12
13
  let(:host_ip) { '192.168.1.2' }
13
14
  let(:tmp_path) { Pathname.new(Dir.mktmpdir) }
@@ -6,9 +6,10 @@ require 'vagrant-notify/server'
6
6
 
7
7
  describe Vagrant::Notify::Action::StartServer do
8
8
  let(:app) { lambda { |env| } }
9
+ let(:config) { mock(notify: stub(enable: true)) }
9
10
  let(:ui) { mock(success: true)}
10
11
  let(:id) { '425e799c-1293-4939-bo39-263lcc7457e8' }
11
- let(:machine) { mock(state: stub(id: :stopped), ui: ui, id: id) }
12
+ let(:machine) { mock(state: stub(id: :stopped), ui: ui, id: id, config: config) }
12
13
  let(:env) { {notify_data: {}, machine: machine} }
13
14
  let(:pid) { '42' }
14
15
  let(:port) { '1234' }
@@ -4,9 +4,10 @@ require 'vagrant-notify/action/stop_server'
4
4
 
5
5
  describe Vagrant::Notify::Action::StopServer do
6
6
  let(:app) { lambda { |env| } }
7
+ let(:config) { mock(notify: stub(enable: true)) }
7
8
  let(:communicator) { mock(sudo: true) }
8
- let(:ui) { mock(success: true)}
9
- let(:machine) { mock(communicate: communicator, state: stub(id: :running), ui: ui) }
9
+ let(:ui) { mock(success: true) }
10
+ let(:machine) { mock(communicate: communicator, state: stub(id: :running), ui: ui, config: config) }
10
11
  let(:env) { {notify_data: {pid: pid, port: 1234}, machine: machine} }
11
12
  let(:pid) { '42' }
12
13
  let(:port) { described_class::PORT }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rehm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-22 00:00:00.000000000 Z
12
+ date: 2016-07-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Vagrant plugin that forwards `notify-send` from guest to host machine
15
15
  and notifies provisioning status
@@ -32,8 +32,10 @@ files:
32
32
  - Rakefile
33
33
  - development/Vagrantfile
34
34
  - examples/README.md
35
+ - examples/osx/notify-send_growl_for_mac
35
36
  - examples/osx/notify-send_terminal-notifier
36
37
  - examples/windows/notify-send_growl_for_windows
38
+ - examples/windows/notify-send_snarl
37
39
  - files/notify-send.erb
38
40
  - lib/vagrant-notify.rb
39
41
  - lib/vagrant-notify/action.rb
@@ -47,6 +49,7 @@ files:
47
49
  - lib/vagrant-notify/action/stop_server.rb
48
50
  - lib/vagrant-notify/action/windows/process_info.rb
49
51
  - lib/vagrant-notify/command.rb
52
+ - lib/vagrant-notify/config.rb
50
53
  - lib/vagrant-notify/data.rb
51
54
  - lib/vagrant-notify/plugin.rb
52
55
  - lib/vagrant-notify/server.rb