vagrant-winnfsd 1.0.5 → 1.0.6

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e53d68888b912d54bee041bb9d5529d5b24877eb
4
+ data.tar.gz: 514bc4778d3c8c36e10a2b6ef6f117c76bb7ee3d
5
+ SHA512:
6
+ metadata.gz: 08344c308000f6e04603f881d80465597215bb20933ad3f1c4647e4036150bbd4f5159f55b7608146e1c18ca58d02117c4492cace1fc03309fc27db30811726c
7
+ data.tar.gz: 390d49b9030e2646816f6e7dd32cff5d54aae5fb0636a362b4c5c2ea77654f2ca1d47f7d5d2f1765e0292a76c427f035a2c03ea942a094631bcab16e4ee55b41
data/.gitignore CHANGED
@@ -1,13 +1,13 @@
1
- # RubyMine
2
- .idea
3
-
4
- # Bundler/Rubygems
5
- *.gem
6
- .bundle
7
- pkg/*
8
- tags
9
- Gemfile.lock
10
-
11
- # Vagrant
12
- .vagrant
1
+ # RubyMine
2
+ .idea
3
+
4
+ # Bundler/Rubygems
5
+ *.gem
6
+ .bundle
7
+ pkg/*
8
+ tags
9
+ Gemfile.lock
10
+
11
+ # Vagrant
12
+ .vagrant
13
13
  Vagrantfile
data/CHANGELOG CHANGED
@@ -1,6 +1,14 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 1.0.6
5
+ -----
6
+
7
+ Add support for vagrant 1.5.0 and higher
8
+ Remove support for vagrant lower than 1.5.0
9
+ Improve error message
10
+
11
+
4
12
  1.0.5
5
13
  -----
6
14
 
data/Gemfile CHANGED
@@ -1,11 +1,15 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development do
6
- # We depend on Vagrant for development, but we don't add it as a
7
- # gem dependency because we expect to be installed within the
8
- # Vagrant environment itself using `vagrant plugin`.
9
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "master"
10
- gem "rspec"
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "master"
10
+ gem "rspec"
11
+ end
12
+
13
+ group :plugins do
14
+ gem "vagrant-winnfsd", path: "."
11
15
  end
data/Rakefile CHANGED
@@ -1,21 +1,21 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- #require 'rspec/core/rake_task'
4
-
5
- # Immediately sync all stdout so that tools like buildbot can
6
- # immediately load in the output.
7
- $stdout.sync = true
8
- $stderr.sync = true
9
-
10
- # Change to the directory of this file.
11
- Dir.chdir(File.expand_path("../", __FILE__))
12
-
13
- # This installs the tasks that help with gem creation and
14
- # publishing.
15
- Bundler::GemHelper.install_tasks
16
-
17
- # Install the `spec` task so that we can run tests.
18
- #RSpec::Core::RakeTask.new
19
-
20
- # Default task is to run the unit tests
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ #require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ #RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
21
  #task :default => "spec"
@@ -1,4 +1,4 @@
1
- Set UAC = CreateObject("Shell.Application")
2
- For count = 0 to (WScript.Arguments.Count - 1)
3
- UAC.ShellExecute "netsh", Replace(WScript.Arguments(count), "'", Chr(34)), "", "runas", 1
1
+ Set UAC = CreateObject("Shell.Application")
2
+ For count = 0 to (WScript.Arguments.Count - 1)
3
+ UAC.ShellExecute "netsh", Replace(WScript.Arguments(count), "'", Chr(34)), "", "runas", 1
4
4
  Next
@@ -0,0 +1,58 @@
1
+ require Vagrant.source_root.join("plugins/hosts/windows/cap/nfs")
2
+
3
+ module VagrantPlugins
4
+ module VagrantWinNFSd
5
+ module Cap
6
+ class NFS < Vagrant.plugin("2", :host)
7
+ @logger = Log4r::Logger.new("vagrant::hosts::windows")
8
+
9
+ executable = VagrantWinNFSd.get_path_for_file("nfsservice.bat")
10
+ @nfs_check_command = "\"#{executable}\" status"
11
+ @nfs_start_command = "\"#{executable}\" start"
12
+ @nfs_stop_command = "\"#{executable}\" halt"
13
+ @nfs_path_file = ".vagrant\\nfspaths"
14
+
15
+ def self.nfs_export(env, ui, id, ips, folders)
16
+ ui.info I18n.t("vagrant_winnfsd.hosts.windows.nfs_export")
17
+ sleep 0.5
18
+
19
+ folders.each do |k, opts|
20
+ hostpath = opts[:hostpath].dup
21
+ hostpath.gsub!("'", "'\\\\''")
22
+ hostpath.gsub('/', '\\')
23
+ system("echo #{hostpath} >>#@nfs_path_file")
24
+ end
25
+
26
+ system("#@nfs_start_command .\\#@nfs_path_file")
27
+ sleep 2
28
+ end
29
+
30
+ def self.nfs_prune(environment, ui, valid_ids)
31
+ ui.info I18n.t("vagrant_winnfsd.hosts.windows.nfs_prune")
32
+ @logger.info("Pruning invalid NFS entries...")
33
+ self.nfs_cleanup
34
+ end
35
+
36
+ def self.nfs_installed(env)
37
+ true
38
+ end
39
+
40
+ protected
41
+
42
+ def self.nfs_running?
43
+ system("#@nfs_check_command")
44
+ end
45
+
46
+ def self.nfs_cleanup
47
+ if nfs_running?
48
+ system("#@nfs_stop_command")
49
+ end
50
+
51
+ if !nfs_running? && File.exist?(@nfs_path_file)
52
+ File.delete(@nfs_path_file)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -4,8 +4,8 @@ rescue LoadError
4
4
  raise "The Vagrant WinNFSd plugin must be run within Vagrant."
5
5
  end
6
6
 
7
- if Vagrant::VERSION < "1.4.0"
8
- raise "The Vagrant AWS plugin is only compatible with Vagrant 1.4.0+"
7
+ if Vagrant::VERSION < "1.5.0"
8
+ raise "The Vagrant AWS plugin is only compatible with Vagrant 1.5.0+"
9
9
  end
10
10
 
11
11
  module VagrantPlugins
@@ -29,9 +29,19 @@ module VagrantPlugins
29
29
  SyncedFolder
30
30
  end
31
31
 
32
- host("windows") do
33
- require_relative "host"
34
- Host
32
+ host_capability("windows", "nfs_export") do
33
+ require_relative "cap/nfs"
34
+ Cap::NFS
35
+ end
36
+
37
+ host_capability("windows", "nfs_installed") do
38
+ require_relative "cap/nfs"
39
+ Cap::NFS
40
+ end
41
+
42
+ host_capability("windows", "nfs_prune") do
43
+ require_relative "cap/nfs"
44
+ Cap::NFS
35
45
  end
36
46
 
37
47
  def self.init_plugin
@@ -43,8 +53,8 @@ module VagrantPlugins
43
53
  rule_exist = "netsh advfirewall firewall show rule name=\"%s\">nul"
44
54
 
45
55
  unless system(sprintf(rule_exist, rule_name))
46
- cleanup_rule = "advfirewall firewall delete rule name='winnfsd.exe'"
47
- rule = "advfirewall firewall add rule name='%s' dir='%s' action=allow protocol=any program='%s' profile=any"
56
+ cleanup_rule = "advfirewall firewall delete rule name=\"winnfsd.exe\""
57
+ rule = "advfirewall firewall add rule name=\"%s\" dir=\"%s\" action=allow protocol=any program=\"%s\" profile=any"
48
58
  in_rule = sprintf(rule, rule_name, 'in', program)
49
59
  out_rule = sprintf(rule, rule_name, 'out', program)
50
60
 
@@ -53,8 +63,8 @@ module VagrantPlugins
53
63
 
54
64
  unless system(firewall_rule)
55
65
  puts I18n.t("vagrant_winnfsd.firewall.error")
56
- puts "#{in_rule}\n"
57
- puts "#{out_rule}\n"
66
+ puts "netsh #{in_rule}\n"
67
+ puts "netsh #{out_rule}\n"
58
68
  end
59
69
  end
60
70
  end
@@ -1,48 +1,80 @@
1
- require 'vagrant'
2
- require Vagrant.source_root.join("plugins/synced_folders/nfs/synced_folder")
3
-
4
- module VagrantPlugins
5
- module VagrantWinNFSd
6
- class SyncedFolder < VagrantPlugins::SyncedFolderNFS::SyncedFolder
7
- def enable(machine, folders, nfsopts)
8
- raise Vagrant::Errors::NFSNoHostIP if !nfsopts[:nfs_host_ip]
9
- raise Vagrant::Errors::NFSNoGuestIP if !nfsopts[:nfs_machine_ip]
10
-
11
- machine_ip = nfsopts[:nfs_machine_ip]
12
- machine_ip = [machine_ip] if !machine_ip.is_a?(Array)
13
-
14
- # Prepare the folder, this means setting up various options
15
- # and such on the folder itself.
16
- folders.each { |id, opts| prepare_folder(machine, opts) }
17
-
18
- # Export the folders
19
- machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
20
- machine.env.host.nfs_export(machine.id, machine_ip, folders)
21
-
22
- # Mount
23
- machine.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
24
-
25
- # Only mount folders that have a guest path specified.
26
- mount_folders = {}
27
- folders.each do |id, opts|
28
- if Vagrant::Util::Platform.windows?
29
- unless opts[:mount_options]
30
- mount_opts = ["vers=#{opts[:nfs_version]}"]
31
- mount_opts << "udp" if opts[:nfs_udp]
32
- mount_opts << "nolock"
33
-
34
- opts[:mount_options] = mount_opts
35
- end
36
-
37
- opts[:hostpath] = '/' + opts[:hostpath].gsub(':', '').gsub('\\', '/')
38
- end
39
- mount_folders[id] = opts.dup if opts[:guestpath]
40
- end
41
-
42
- # Mount them!
43
- machine.guest.capability(
44
- :mount_nfs_folder, nfsopts[:nfs_host_ip], mount_folders)
45
- end
46
- end
47
- end
1
+ require 'vagrant'
2
+ require Vagrant.source_root.join("plugins/synced_folders/nfs/synced_folder")
3
+
4
+ module VagrantPlugins
5
+ module VagrantWinNFSd
6
+ class SyncedFolder < VagrantPlugins::SyncedFolderNFS::SyncedFolder
7
+ def enable(machine, folders, nfsopts)
8
+ raise Vagrant::Errors::NFSNoHostIP if !nfsopts[:nfs_host_ip]
9
+ raise Vagrant::Errors::NFSNoGuestIP if !nfsopts[:nfs_machine_ip]
10
+
11
+ if machine.guest.capability?(:nfs_client_installed)
12
+ installed = machine.guest.capability(:nfs_client_installed)
13
+ if !installed
14
+ can_install = machine.guest.capability?(:nfs_client_install)
15
+ raise Vagrant::Errors::NFSClientNotInstalledInGuest if !can_install
16
+ machine.ui.info I18n.t("vagrant.actions.vm.nfs.installing")
17
+ machine.guest.capability(:nfs_client_install)
18
+ end
19
+ end
20
+
21
+ machine_ip = nfsopts[:nfs_machine_ip]
22
+ machine_ip = [machine_ip] if !machine_ip.is_a?(Array)
23
+
24
+ # Prepare the folder, this means setting up various options
25
+ # and such on the folder itself.
26
+ folders.each { |id, opts| prepare_folder(machine, opts) }
27
+
28
+ # Determine what folders we'll export
29
+ export_folders = folders.dup
30
+ export_folders.keys.each do |id|
31
+ opts = export_folders[id]
32
+ if opts.has_key?(:nfs_export) && !opts[:nfs_export]
33
+ export_folders.delete(id)
34
+ end
35
+ end
36
+
37
+ # Export the folders. We do this with a class-wide lock because
38
+ # NFS exporting often requires sudo privilege and we don't want
39
+ # overlapping input requests. [GH-2680]
40
+ @@lock.synchronize do
41
+ begin
42
+ machine.env.lock("nfs-export") do
43
+ machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
44
+ machine.env.host.capability(
45
+ :nfs_export,
46
+ machine.ui, machine.id, machine_ip, export_folders)
47
+ end
48
+ rescue Vagrant::Errors::EnvironmentLockedError
49
+ sleep 1
50
+ retry
51
+ end
52
+ end
53
+
54
+ # Mount
55
+ machine.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
56
+
57
+ # Only mount folders that have a guest path specified.
58
+ mount_folders = {}
59
+ folders.each do |id, opts|
60
+ if Vagrant::Util::Platform.windows?
61
+ unless opts[:mount_options]
62
+ mount_opts = ["vers=#{opts[:nfs_version]}"]
63
+ mount_opts << "udp" if opts[:nfs_udp]
64
+ mount_opts << "nolock"
65
+
66
+ opts[:mount_options] = mount_opts
67
+ end
68
+
69
+ opts[:hostpath] = '/' + opts[:hostpath].gsub(':', '').gsub('\\', '/')
70
+ end
71
+ mount_folders[id] = opts.dup if opts[:guestpath]
72
+ end
73
+
74
+ # Mount them!
75
+ machine.guest.capability(
76
+ :mount_nfs_folder, nfsopts[:nfs_host_ip], mount_folders)
77
+ end
78
+ end
79
+ end
48
80
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VagrantWinNFSd
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,19 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-winnfsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
5
- prerelease:
4
+ version: 1.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alexander Schneider
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-06-08 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! ' Manage and adds support for NFS on windows.
15
-
16
- '
13
+ description: |2
14
+ Manage and adds support for NFS on windows.
17
15
  email: alexander.schneider@jankowfsky.com
18
16
  executables: []
19
17
  extensions: []
@@ -24,8 +22,8 @@ files:
24
22
  - bin/winnfsd.exe
25
23
  - CHANGELOG
26
24
  - Gemfile
25
+ - lib/vagrant-winnfsd/cap/nfs.rb
27
26
  - lib/vagrant-winnfsd/config.rb
28
- - lib/vagrant-winnfsd/host.rb
29
27
  - lib/vagrant-winnfsd/plugin.rb
30
28
  - lib/vagrant-winnfsd/synced_folder.rb
31
29
  - lib/vagrant-winnfsd/version.rb
@@ -40,32 +38,25 @@ files:
40
38
  homepage: https://github.com/gm-alex/vagrant-winnfsd
41
39
  licenses:
42
40
  - Apache 2.0
41
+ metadata: {}
43
42
  post_install_message:
44
43
  rdoc_options: []
45
44
  require_paths:
46
45
  - lib
47
46
  required_ruby_version: !ruby/object:Gem::Requirement
48
- none: false
49
47
  requirements:
50
- - - ! '>='
48
+ - - '>='
51
49
  - !ruby/object:Gem::Version
52
50
  version: '0'
53
- segments:
54
- - 0
55
- hash: -598002623
56
51
  required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ! '>='
53
+ - - '>='
60
54
  - !ruby/object:Gem::Version
61
55
  version: '0'
62
- segments:
63
- - 0
64
- hash: -598002623
65
56
  requirements: []
66
57
  rubyforge_project:
67
- rubygems_version: 1.8.28
58
+ rubygems_version: 2.0.14
68
59
  signing_key:
69
- specification_version: 3
60
+ specification_version: 4
70
61
  summary: Adds NFS support for Windows
71
62
  test_files: []
@@ -1,65 +0,0 @@
1
- require Vagrant.source_root.join("plugins/hosts/windows/host")
2
-
3
- module VagrantPlugins
4
- module VagrantWinNFSd
5
- class Host < Vagrant.plugin("2", :host)
6
- def self.match?
7
- Vagrant::Util::Platform.windows?
8
- end
9
-
10
- def initialize(*args)
11
- super
12
-
13
- @logger = Log4r::Logger.new("vagrant::hosts::windows")
14
-
15
- executable = VagrantWinNFSd.get_path_for_file("nfsservice.bat")
16
- @nfs_check_command = "\"#{executable}\" status"
17
- @nfs_start_command = "\"#{executable}\" start"
18
- @nfs_stop_command = "\"#{executable}\" halt"
19
- @nfs_path_file = ".vagrant\\nfspaths"
20
- end
21
-
22
- # Windows does not support NFS
23
- def nfs?
24
- true
25
- end
26
-
27
- def nfs_export(id, ips, folders)
28
- @ui.info I18n.t("vagrant_winnfsd.hosts.windows.nfs_export")
29
- sleep 0.5
30
-
31
- folders.each do |k, opts|
32
- hostpath = opts[:hostpath].dup
33
- hostpath.gsub!("'", "'\\\\''")
34
- hostpath.gsub('/', '\\')
35
- system("echo #{hostpath} >>#@nfs_path_file")
36
- end
37
-
38
- system("#@nfs_start_command .\\#@nfs_path_file")
39
- sleep 2
40
- end
41
-
42
- def nfs_prune(valid_ids)
43
- @ui.info I18n.t("vagrant_winnfsd.hosts.windows.nfs_prune")
44
- @logger.info("Pruning invalid NFS entries...")
45
- nfs_cleanup()
46
- end
47
-
48
- protected
49
-
50
- def nfs_running?
51
- system("#@nfs_check_command")
52
- end
53
-
54
- def nfs_cleanup()
55
- if nfs_running?
56
- system("#@nfs_stop_command")
57
- end
58
-
59
- if !nfs_running? && File.exist?(@nfs_path_file)
60
- File.delete(@nfs_path_file)
61
- end
62
- end
63
- end
64
- end
65
- end