vagrant-windows 1.3.0 → 1.3.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.
@@ -22,7 +22,7 @@ module VagrantPlugins
22
22
  windows_machine = VagrantWindows::WindowsMachine.new(@machine)
23
23
  wait_if_rebooting(windows_machine)
24
24
 
25
- with_script_file do |path|
25
+ with_windows_script_file do |path|
26
26
  # Upload the script to the machine
27
27
  @machine.communicate.tap do |comm|
28
28
  # Ensure the uploaded script has a file extension, by default
@@ -63,24 +63,38 @@ module VagrantPlugins
63
63
  # This method yields the path to a script to upload and execute
64
64
  # on the remote server. This method will properly clean up the
65
65
  # script file if needed.
66
- def with_script_file
67
- if config.path
66
+ def with_windows_script_file
67
+ script = nil
68
+
69
+ if config.remote?
70
+ download_path = @machine.env.tmp_path.join("#{@machine.id}-remote-script")
71
+ download_path.delete if download_path.file?
72
+
73
+ Vagrant::Util::Downloader.new(config.path, download_path).download!
74
+ script = download_path.read
75
+
76
+ download_path.delete
77
+ elsif config.path
68
78
  # Just yield the path to that file...
69
- yield config.path
79
+ root_path = @machine.env.root_path
80
+ script = Pathname.new(config.path).expand_path(root_path).read
70
81
  else
71
- # Otherwise we have an inline script, we need to Tempfile it,
72
- # and handle it specially...
73
- file = Tempfile.new(['vagrant-powershell', '.ps1'])
82
+ # The script is just the inline code...
83
+ script = config.inline
84
+ end
74
85
 
75
- begin
76
- file.write(config.inline)
77
- file.fsync
78
- file.close
79
- yield file.path
80
- ensure
81
- file.close
82
- file.unlink
83
- end
86
+ # Otherwise we have an inline script, we need to Tempfile it,
87
+ # and handle it specially...
88
+ file = Tempfile.new(['vagrant-powershell', '.ps1'])
89
+
90
+ begin
91
+ file.write(script)
92
+ file.fsync
93
+ file.close
94
+ yield file.path
95
+ ensure
96
+ file.close
97
+ file.unlink
84
98
  end
85
99
  end
86
100
 
@@ -1,3 +1,3 @@
1
1
  module VagrantWindows
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -26,6 +26,13 @@ module VagrantWindows
26
26
  @machine.provider_name.to_s().start_with?('vmware')
27
27
  end
28
28
 
29
+ # Checks to see if the machine is using Oracle VirtualBox.
30
+ #
31
+ # @return [Boolean]
32
+ def is_virtualbox?()
33
+ @machine.provider_name.to_s().start_with?('virtualbox')
34
+ end
35
+
29
36
  # Checks to see if the machine is rebooting or has a scheduled reboot.
30
37
  #
31
38
  # @return [Boolean] True if rebooting
@@ -50,11 +57,15 @@ module VagrantWindows
50
57
  end
51
58
 
52
59
  # Returns a list of forwarded ports for a VM.
53
- # NOTE: For VMWare this is currently unsupported.
60
+ # NOTE: Only the VBox provider currently supports this method
54
61
  #
55
62
  # @return [Array<Array>]
56
63
  def read_forwarded_ports()
57
- is_vmware?() ? [] : @machine.provider.driver.read_forwarded_ports
64
+ if is_virtualbox?()
65
+ @machine.provider.driver.read_forwarded_ports
66
+ else
67
+ []
68
+ end
58
69
  end
59
70
 
60
71
  # Returns the SSH config for this machine.
@@ -24,6 +24,20 @@ describe VagrantWindows::WindowsMachine , :unit => true do
24
24
  end
25
25
  end
26
26
 
27
+ describe "is_virtualbox?" do
28
+ it "should be true for virtualbox" do
29
+ machine = stub(:provider_name => :virtualbox)
30
+ windows_machine = VagrantWindows::WindowsMachine.new(machine)
31
+ expect(windows_machine.is_virtualbox?()).to be_true
32
+ end
33
+
34
+ it "should be false for vmware_workstation" do
35
+ machine = stub(:provider_name => :vmware_workstation)
36
+ windows_machine = VagrantWindows::WindowsMachine.new(machine)
37
+ expect(windows_machine.is_virtualbox?()).to be_false
38
+ end
39
+ end
40
+
27
41
  describe "is_windows?" do
28
42
  it "should return true when config vm guest is windows" do
29
43
  vm = stub(:guest => :windows)
@@ -38,7 +52,14 @@ describe VagrantWindows::WindowsMachine , :unit => true do
38
52
  machine = stub(:config => config)
39
53
  expect(VagrantWindows::WindowsMachine.is_windows?(machine)).to be_false
40
54
  end
41
-
55
+ end
56
+
57
+ describe "read_forwarded_ports" do
58
+ it "should return empty array for vmware provider" do
59
+ machine = stub(:provider_name => :vmware_fusion)
60
+ windows_machine = VagrantWindows::WindowsMachine.new(machine)
61
+ expect(windows_machine.read_forwarded_ports()).to eq([])
62
+ end
42
63
  end
43
64
 
44
65
  end
data/test.ps1 ADDED
@@ -0,0 +1 @@
1
+ echo 'hi'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-windows
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-14 00:00:00.000000000 Z
13
+ date: 2013-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: winrm
@@ -209,6 +209,7 @@ files:
209
209
  - spec/vagrant-windows/winrmcommunicator_spec.rb
210
210
  - spec/vagrant-windows/winrmfinder_spec.rb
211
211
  - spec/vagrant-windows/winrmshell_spec.rb
212
+ - test.ps1
212
213
  - vagrant-windows.gemspec
213
214
  - .DS_Store
214
215
  - .gitignore
@@ -230,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
231
  version: '0'
231
232
  segments:
232
233
  - 0
233
- hash: 3499483992626948935
234
+ hash: -417370087256644247
234
235
  required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  none: false
236
237
  requirements:
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
240
  version: '0'
240
241
  segments:
241
242
  - 0
242
- hash: 3499483992626948935
243
+ hash: -417370087256644247
243
244
  requirements: []
244
245
  rubyforge_project:
245
246
  rubygems_version: 1.8.23