vagrant-ssh 2.0.0 → 2.1.0
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 +4 -4
- data/lib/vagrant-ssh/shell.rb +9 -9
- data/lib/vagrant-ssh/version.rb +1 -1
- data/spec/vagrant_ssh_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0af5558194fc3997641c12db6b3ae1c001cc5440
|
4
|
+
data.tar.gz: 08d8eb176faffe7f2c96496794aae9d094bd0676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfbd59884b411347ff8a57880e0b3e8c813fe643e226748c526707490ff0ee30a6fa5fe47c1d6db3074952d5d2003978f628694c4e63ca05a9c789e2c1b9949
|
7
|
+
data.tar.gz: ebf4701ac94a1e815fbd3a1c57f6c6fda328e9ef1ee6fe624dd052c824d9c2004d59953b8887567488121394d566d3cc06610b4e4b8e1079ac26bc89aba853de
|
data/lib/vagrant-ssh/shell.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module VagrantSsh
|
2
2
|
class Shell
|
3
|
-
attr_reader :options
|
3
|
+
attr_reader :options, :exit_code, :exit_signal
|
4
4
|
|
5
5
|
def initialize(hostname, logger: Logger.new(STDOUT), options: {})
|
6
6
|
@options = { user: 'vagrant',
|
7
7
|
password: 'vagrant' }.merge(options)
|
8
|
-
@user = options[:user]
|
8
|
+
@user = @options[:user]
|
9
9
|
@hostname = hostname
|
10
10
|
@logger = logger # left out of options so it does not conflict with Net::SSH own options hash
|
11
11
|
end
|
@@ -15,23 +15,23 @@ module VagrantSsh
|
|
15
15
|
@logger.info "Executing SSH command: #{command}"
|
16
16
|
stdout = ''
|
17
17
|
stderr = ''
|
18
|
-
exit_code = nil
|
19
|
-
exit_signal = nil
|
18
|
+
@exit_code = nil
|
19
|
+
@exit_signal = nil
|
20
20
|
ssh.open_channel do |channel|
|
21
21
|
channel.exec(command) do |_ch, success|
|
22
22
|
abort "FAILED: couldn't execute command: (#{command})" unless success
|
23
23
|
channel.on_data { |_ch, data| stdout += data }
|
24
24
|
channel.on_extended_data { |_ch, _type, data| stderr += data }
|
25
|
-
channel.on_request('exit-status') { |_ch, data| exit_code = data.read_long }
|
26
|
-
channel.on_request('exit-signal') { |_ch, data| exit_signal = data.read_long }
|
25
|
+
channel.on_request('exit-status') { |_ch, data| @exit_code = data.read_long }
|
26
|
+
channel.on_request('exit-signal') { |_ch, data| @exit_signal = data.read_long }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
ssh.loop
|
30
30
|
|
31
31
|
if stderr.size > 0
|
32
|
-
@logger.error "#{exit_code} #{stderr}"
|
33
|
-
elsif exit_code != 0
|
34
|
-
@logger.info "SSH Completed with non-zero exit code '#{exit_code}'"
|
32
|
+
@logger.error "#{@exit_code} #{stderr}"
|
33
|
+
elsif @exit_code != 0
|
34
|
+
@logger.info "SSH Completed with non-zero exit code '#{@exit_code}'"
|
35
35
|
end
|
36
36
|
if stdout.size > 0
|
37
37
|
@logger.info "#{stdout}"
|
data/lib/vagrant-ssh/version.rb
CHANGED
data/spec/vagrant_ssh_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
1
3
|
describe VagrantSsh::Shell do
|
2
4
|
subject(:vagrant_ssh) { VagrantSsh::Shell.new(host, logger: nil_logger) }
|
3
5
|
|
@@ -12,4 +14,19 @@ describe VagrantSsh::Shell do
|
|
12
14
|
it 'should interface with a Vagrant VM correctly' do
|
13
15
|
expect(vagrant_ssh.execute('whoami').strip).to eq 'vagrant'
|
14
16
|
end
|
17
|
+
|
18
|
+
context 'when modifying the defaults' do
|
19
|
+
let(:non_default_credentials) { { user: 'foo', password: 'bar' } }
|
20
|
+
|
21
|
+
it 'uses the provided credentials' do
|
22
|
+
vagrant_ssh = VagrantSsh::Shell.new(host, logger: nil_logger, options: non_default_credentials)
|
23
|
+
expect(vagrant_ssh.options[:user]).to eq 'foo'
|
24
|
+
expect(vagrant_ssh.options[:password]).to eq 'bar'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'provides the last exit code' do
|
29
|
+
vagrant_ssh.execute('exit 1')
|
30
|
+
expect(vagrant_ssh.exit_code).to eq 1
|
31
|
+
end
|
15
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Snape
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|