r-train 0.9.7 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -3
- data/CHANGELOG.md +24 -5
- data/Gemfile +2 -2
- data/Rakefile +1 -1
- data/lib/train.rb +0 -2
- data/lib/train/extras/command_wrapper.rb +1 -0
- data/lib/train/extras/file_aix.rb +4 -5
- data/lib/train/extras/file_common.rb +2 -2
- data/lib/train/extras/file_unix.rb +2 -4
- data/lib/train/extras/os_common.rb +2 -3
- data/lib/train/extras/os_detect_linux.rb +1 -1
- data/lib/train/extras/os_detect_unix.rb +4 -4
- data/lib/train/extras/os_detect_windows.rb +37 -64
- data/lib/train/extras/stat.rb +1 -1
- data/lib/train/transports/docker.rb +4 -3
- data/lib/train/transports/mock.rb +27 -10
- data/lib/train/transports/ssh.rb +2 -2
- data/lib/train/transports/ssh_connection.rb +1 -1
- data/lib/train/transports/winrm.rb +3 -2
- data/lib/train/transports/winrm_connection.rb +1 -1
- data/lib/train/version.rb +1 -1
- data/test/unit/extras/os_detect_linux_test.rb +1 -0
- data/test/unit/extras/os_detect_windows_test.rb +99 -0
- data/test/windows/local_test.rb +3 -3
- data/test/windows/winrm_test.rb +4 -4
- data/train.gemspec +1 -4
- metadata +4 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fd25048f1db2b7fe16bbdfc8cbbf0bc37378a07
|
4
|
+
data.tar.gz: 1aa813741c5d080c00e74790af38d1fee7b23a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109add699ff0d357e8d930d792434f0787778d5447b34771a879e389e7ff42930251fa29fa0d54a0c04551226992e08a210b41a6d21266bd4b199cc5aaa13ec8
|
7
|
+
data.tar.gz: 4b564895054b589201d8021ca735c21174350516a97a1c799332ca7b0ee9038b84b7100dd2f2b5545be99331f0282ba57e0eaf46be8c9cf66e8d488f5bc84b3f
|
data/.rubocop.yml
CHANGED
@@ -16,14 +16,18 @@ HashSyntax:
|
|
16
16
|
Enabled: true
|
17
17
|
LineLength:
|
18
18
|
Enabled: false
|
19
|
+
EmptyLinesAroundBlockBody:
|
20
|
+
Enabled: false
|
19
21
|
MethodLength:
|
20
22
|
Max: 40
|
23
|
+
NumericLiterals:
|
24
|
+
MinDigits: 10
|
21
25
|
Metrics/CyclomaticComplexity:
|
22
26
|
Max: 10
|
23
27
|
Metrics/PerceivedComplexity:
|
24
28
|
Max: 10
|
25
29
|
Metrics/AbcSize:
|
26
|
-
Max:
|
30
|
+
Max: 33
|
27
31
|
Style/PercentLiteralDelimiters:
|
28
32
|
PreferredDelimiters:
|
29
33
|
'%': '{}'
|
@@ -35,11 +39,33 @@ Style/PercentLiteralDelimiters:
|
|
35
39
|
'%w': '{}'
|
36
40
|
'%W': ()
|
37
41
|
'%x': ()
|
42
|
+
Style/AlignHash:
|
43
|
+
Enabled: false
|
44
|
+
Style/PredicateName:
|
45
|
+
Enabled: false
|
38
46
|
Style/ClassAndModuleChildren:
|
39
47
|
Enabled: false
|
48
|
+
Style/ConditionalAssignment:
|
49
|
+
Enabled: false
|
50
|
+
Style/BracesAroundHashParameters:
|
51
|
+
Enabled: false
|
40
52
|
Style/AndOr:
|
41
53
|
Enabled: false
|
42
|
-
Style/
|
54
|
+
Style/Not:
|
55
|
+
Enabled: false
|
56
|
+
Style/FileName:
|
57
|
+
Enabled: false
|
58
|
+
Style/TrailingCommaInLiteral:
|
43
59
|
EnforcedStyleForMultiline: comma
|
60
|
+
Style/TrailingCommaInArguments:
|
61
|
+
EnforcedStyleForMultiline: comma
|
62
|
+
Style/NegatedIf:
|
63
|
+
Enabled: false
|
64
|
+
Style/UnlessElse:
|
65
|
+
Enabled: false
|
66
|
+
BlockDelimiters:
|
67
|
+
Enabled: false
|
44
68
|
Style/SpaceAroundOperators:
|
45
|
-
|
69
|
+
Enabled: false
|
70
|
+
Style/IfUnlessModifier:
|
71
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,43 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.
|
4
|
-
[Full Changelog](https://github.com/chef/train/compare/v0.9.
|
3
|
+
## [0.10.0](https://github.com/chef/train/tree/0.10.0) (2016-02-19)
|
4
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.9.7...0.10.0)
|
5
5
|
|
6
6
|
**Implemented enhancements:**
|
7
7
|
|
8
|
+
- show mock failures for commands [\#69](https://github.com/chef/train/pull/69) ([arlimus](https://github.com/arlimus))
|
9
|
+
- update gems and rubocop [\#68](https://github.com/chef/train/pull/68) ([arlimus](https://github.com/arlimus))
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- complete rewrite of windows version detection [\#70](https://github.com/chef/train/pull/70) ([chris-rock](https://github.com/chris-rock))
|
14
|
+
|
15
|
+
## [v0.9.7](https://github.com/chef/train/tree/v0.9.7) (2016-02-05)
|
16
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.9.6...v0.9.7)
|
17
|
+
|
18
|
+
**Implemented enhancements:**
|
19
|
+
|
20
|
+
- feature: add file.basename [\#64](https://github.com/chef/train/pull/64) ([arlimus](https://github.com/arlimus))
|
8
21
|
- add `requiretty` workaround measures [\#63](https://github.com/chef/train/pull/63) ([srenatus](https://github.com/srenatus))
|
9
22
|
|
10
|
-
**
|
23
|
+
**Fixed bugs:**
|
11
24
|
|
12
25
|
- ensure bundler is installed on travis [\#66](https://github.com/chef/train/pull/66) ([chris-rock](https://github.com/chris-rock))
|
13
|
-
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- 0.9.7 [\#67](https://github.com/chef/train/pull/67) ([chris-rock](https://github.com/chris-rock))
|
14
30
|
|
15
31
|
## [v0.9.6](https://github.com/chef/train/tree/v0.9.6) (2016-01-29)
|
16
32
|
[Full Changelog](https://github.com/chef/train/compare/v0.9.5...v0.9.6)
|
17
33
|
|
34
|
+
**Implemented enhancements:**
|
35
|
+
|
36
|
+
- add solaris support [\#61](https://github.com/chef/train/pull/61) ([chris-rock](https://github.com/chris-rock))
|
37
|
+
|
18
38
|
**Merged pull requests:**
|
19
39
|
|
20
40
|
- 0.9.6 [\#62](https://github.com/chef/train/pull/62) ([chris-rock](https://github.com/chris-rock))
|
21
|
-
- add solaris support [\#61](https://github.com/chef/train/pull/61) ([chris-rock](https://github.com/chris-rock))
|
22
41
|
|
23
42
|
## [v0.9.5](https://github.com/chef/train/tree/v0.9.5) (2016-01-25)
|
24
43
|
[Full Changelog](https://github.com/chef/train/compare/v0.9.4...v0.9.5)
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/train.rb
CHANGED
@@ -7,15 +7,14 @@ module Train::Extras
|
|
7
7
|
class AixFile < UnixFile
|
8
8
|
def link_path
|
9
9
|
return nil unless symlink?
|
10
|
-
@link_path ||=
|
11
|
-
@backend.run_command("perl -e 'print readlink shift' #{@spath}")
|
12
|
-
|
10
|
+
@link_path ||=
|
11
|
+
@backend.run_command("perl -e 'print readlink shift' #{@spath}")
|
12
|
+
.stdout.chomp
|
13
13
|
end
|
14
14
|
|
15
15
|
def mounted
|
16
|
-
@mounted ||=
|
16
|
+
@mounted ||=
|
17
17
|
@backend.run_command("lsfs -c #{@spath}")
|
18
|
-
)
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -40,15 +40,13 @@ module Train::Extras
|
|
40
40
|
|
41
41
|
def link_path
|
42
42
|
return nil unless symlink?
|
43
|
-
@link_path ||=
|
43
|
+
@link_path ||=
|
44
44
|
@backend.run_command("readlink #{@spath}").stdout.chomp
|
45
|
-
)
|
46
45
|
end
|
47
46
|
|
48
47
|
def mounted
|
49
|
-
@mounted ||=
|
48
|
+
@mounted ||=
|
50
49
|
@backend.run_command("mount | grep -- ' on #{@spath}'")
|
51
|
-
)
|
52
50
|
end
|
53
51
|
|
54
52
|
%w{
|
@@ -34,7 +34,7 @@ module Train::Extras
|
|
34
34
|
@platform
|
35
35
|
end
|
36
36
|
|
37
|
-
OS = {
|
37
|
+
OS = { # rubocop:disable Style/MutableConstant
|
38
38
|
'redhat' => %w{
|
39
39
|
redhat oracle centos fedora amazon scientific xenserver wrlinux
|
40
40
|
},
|
@@ -58,8 +58,7 @@ module Train::Extras
|
|
58
58
|
},
|
59
59
|
}
|
60
60
|
|
61
|
-
OS['linux'] = %w{linux alpine arch coreos exherbo gentoo slackware} +
|
62
|
-
OS['redhat'] + OS['debian'] + OS['suse']
|
61
|
+
OS['linux'] = %w{linux alpine arch coreos exherbo gentoo slackware} + OS['redhat'] + OS['debian'] + OS['suse']
|
63
62
|
|
64
63
|
OS['unix'] = %w{unix aix} + OS['linux'] + OS['solaris'] + OS['bsd']
|
65
64
|
|
@@ -80,7 +80,7 @@ module Train::Extras
|
|
80
80
|
meta = lsb_config(raw)
|
81
81
|
@platform[:release] = meta[:release]
|
82
82
|
elsif !(os_info = fetch_os_release).nil?
|
83
|
-
if os_info['ID_LIKE']
|
83
|
+
if os_info['ID_LIKE'] =~ /wrlinux/
|
84
84
|
@platform[:family] = 'wrlinux'
|
85
85
|
@platform[:release] = os_info['VERSION']
|
86
86
|
end
|
@@ -50,7 +50,7 @@ module Train::Extras
|
|
50
50
|
# read specific os name
|
51
51
|
# DEPRECATED: os[:family] is going to be deprecated, use os.solaris?
|
52
52
|
rel = get_config('/etc/release')
|
53
|
-
if /^.*(SmartOS)
|
53
|
+
if /^.*(SmartOS).*$/ =~ rel
|
54
54
|
@platform[:name] = 'smartos'
|
55
55
|
@platform[:family] = 'smartos'
|
56
56
|
elsif !(m = /^\s*(OmniOS).*r(\d+).*$/.match(rel)).nil?
|
@@ -61,7 +61,7 @@ module Train::Extras
|
|
61
61
|
@platform[:name] = 'openindiana'
|
62
62
|
@platform[:family] = 'openindiana'
|
63
63
|
@platform[:release] = m[2]
|
64
|
-
elsif /^\s*(OpenSolaris).*snv_(\d+)
|
64
|
+
elsif /^\s*(OpenSolaris).*snv_(\d+).*$/ =~ rel
|
65
65
|
@platform[:name] = 'opensolaris'
|
66
66
|
@platform[:family] = 'opensolaris'
|
67
67
|
@platform[:release] = m[2]
|
@@ -70,10 +70,10 @@ module Train::Extras
|
|
70
70
|
@platform[:release] = m[1]
|
71
71
|
@platform[:name] = 'solaris'
|
72
72
|
@platform[:family] = 'solaris'
|
73
|
-
elsif /^\s*(Solaris)\s
|
73
|
+
elsif /^\s*(Solaris)\s.*$/ =~ rel
|
74
74
|
@platform[:name] = 'solaris'
|
75
75
|
@platform[:family] = 'solaris'
|
76
|
-
elsif /^\s*(NexentaCore)\s
|
76
|
+
elsif /^\s*(NexentaCore)\s.*$/ =~ rel
|
77
77
|
@platform[:name] = 'nexentacore'
|
78
78
|
@platform[:family] = 'nexentacore'
|
79
79
|
else
|
@@ -7,78 +7,51 @@
|
|
7
7
|
# OHAI https://github.com/chef/ohai
|
8
8
|
# by Adam Jacob, Chef Software Inc
|
9
9
|
#
|
10
|
-
|
11
|
-
require 'json'
|
12
|
-
require 'winrm'
|
13
|
-
|
14
10
|
module Train::Extras
|
15
11
|
module DetectWindows
|
16
|
-
# See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832%28v=vs.85%29.aspx
|
17
|
-
# Product Type:
|
18
|
-
# Work Station (1)
|
19
|
-
# Domain Controller (2)
|
20
|
-
# Server (3)
|
21
|
-
WINDOWS_VERSIONS = {
|
22
|
-
'0' => '3.1',
|
23
|
-
'140' => '95',
|
24
|
-
'1410' => '98',
|
25
|
-
'1490' => 'ME',
|
26
|
-
'1351' => 'NT 3.51',
|
27
|
-
'3351' => 'NT 3.51 Server',
|
28
|
-
'1240' => 'NT 4.0',
|
29
|
-
'3240' => 'NT 4.0 Server',
|
30
|
-
'1250' => '2000',
|
31
|
-
'1251' => 'XP',
|
32
|
-
'3252' => 'Server 2003',
|
33
|
-
'1252' => 'Vista',
|
34
|
-
'3260' => 'Server 2008',
|
35
|
-
'1261' => '7',
|
36
|
-
'3261' => 'Server 2008 R2',
|
37
|
-
'1262' => '8',
|
38
|
-
'3262' => 'Server 2012',
|
39
|
-
'1263' => '8.1',
|
40
|
-
'3263' => 'Server 2012 R2',
|
41
|
-
'12100' => '10',
|
42
|
-
'32100' => 'Server 2016',
|
43
|
-
}
|
44
|
-
|
45
|
-
def windows_version(json)
|
46
|
-
producttype = json['OS']['ProductType'].to_s
|
47
|
-
# do not distigush between domain controller and server
|
48
|
-
producttype = '3' if producttype == '2'
|
49
|
-
platform = json['OSVersion']['Platform'].to_s
|
50
|
-
major = json['OSVersion']['Version']['Major'].to_s
|
51
|
-
minor = json['OSVersion']['Version']['Minor'].to_s
|
52
|
-
# construct it
|
53
|
-
producttype + platform + major + minor
|
54
|
-
end
|
55
|
-
|
56
12
|
def detect_windows
|
57
|
-
|
58
|
-
'-Name OS -Value (Get-WmiObject -Class Win32_OperatingSystem) '\
|
59
|
-
'-PassThru | Add-Member -MemberType NoteProperty -Name OSVersion '\
|
60
|
-
'-Value ([Environment]::OSVersion) -PassThru | ConvertTo-Json'
|
61
|
-
|
62
|
-
# wrap the script to ensure we always run it via powershell
|
63
|
-
# especially in local mode, we cannot be sure that we get a Powershell
|
64
|
-
# we may just get a `cmd`. os detection and powershell command wrapper is
|
65
|
-
# not available when this code is executed
|
66
|
-
script = WinRM::PowershellScript.new(cmd)
|
67
|
-
cmd = "powershell -encodedCommand #{script.encoded}"
|
68
|
-
|
69
|
-
res = @backend.run_command(cmd)
|
70
|
-
|
71
|
-
# TODO: error as this shouldnt be happening at this point
|
13
|
+
res = @backend.run_command('cmd /c ver')
|
72
14
|
return false if res.exit_status != 0 or res.stdout.empty?
|
73
15
|
|
74
|
-
|
75
|
-
|
76
|
-
version
|
77
|
-
|
16
|
+
# if the ver contains `Windows`, we know its a Windows system
|
17
|
+
version = res.stdout.strip
|
18
|
+
return false unless version.downcase =~ /windows/
|
78
19
|
@platform[:family] = 'windows'
|
79
|
-
|
20
|
+
|
21
|
+
# try to extract release from eg. `Microsoft Windows [Version 6.3.9600]`
|
22
|
+
release = /\[(?<name>.*)\]/.match(version)
|
23
|
+
unless release[:name].nil?
|
24
|
+
# release is 6.3.9600 now
|
25
|
+
@platform[:release] = release[:name].downcase.gsub('version', '').strip
|
26
|
+
# fallback, if we are not able to extract the name from wmic later
|
27
|
+
@platform[:name] = "Windows #{@platform[:release]}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# try to use wmic, but lets keep it optional
|
31
|
+
read_wmic
|
80
32
|
|
81
33
|
true
|
82
34
|
end
|
35
|
+
|
36
|
+
# reads os name and version from wmic
|
37
|
+
# @see https://msdn.microsoft.com/en-us/library/bb742610.aspx#EEAA
|
38
|
+
# Thanks to Matt Wrock (https://github.com/mwrock) for this hint
|
39
|
+
def read_wmic
|
40
|
+
res = @backend.run_command('wmic os get * /format:list')
|
41
|
+
if res.exit_status == 0
|
42
|
+
sys_info = {}
|
43
|
+
res.stdout.lines.each { |line|
|
44
|
+
m = /^\s*([^=]*?)\s*=\s*(.*?)\s*$/.match(line)
|
45
|
+
sys_info[m[1].to_sym] = m[2] unless m.nil? || m[1].nil?
|
46
|
+
}
|
47
|
+
|
48
|
+
@platform[:release] = sys_info[:Version]
|
49
|
+
# additional info on windows
|
50
|
+
@platform[:build] = sys_info[:BuildNumber]
|
51
|
+
@platform[:name] = sys_info[:Caption]
|
52
|
+
@platform[:name] = @platform[:name].gsub('Microsoft', '').strip unless @platform[:name].empty?
|
53
|
+
@platform[:arch] = sys_info[:OSArchitecture]
|
54
|
+
end
|
55
|
+
end
|
83
56
|
end
|
84
57
|
end
|
data/lib/train/extras/stat.rb
CHANGED
@@ -80,9 +80,10 @@ class Train::Transports::Docker
|
|
80
80
|
|
81
81
|
def run_command(cmd)
|
82
82
|
cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil?
|
83
|
-
stdout, stderr, exit_status = @container.exec(
|
84
|
-
|
85
|
-
|
83
|
+
stdout, stderr, exit_status = @container.exec(
|
84
|
+
[
|
85
|
+
'/bin/sh', '-c', cmd
|
86
|
+
])
|
86
87
|
CommandResult.new(stdout.join, stderr.join, exit_status)
|
87
88
|
rescue ::Docker::Error::DockerError => _
|
88
89
|
raise
|
@@ -12,11 +12,11 @@ module Train::Transports
|
|
12
12
|
|
13
13
|
def initialize(conf = nil)
|
14
14
|
@conf = conf || {}
|
15
|
-
trace_calls if @conf[:
|
15
|
+
trace_calls if @conf[:trace]
|
16
16
|
end
|
17
17
|
|
18
18
|
def connection
|
19
|
-
@connection ||= Connection.new
|
19
|
+
@connection ||= Connection.new(@conf)
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_s
|
@@ -27,9 +27,14 @@ module Train::Transports
|
|
27
27
|
|
28
28
|
def trace_calls
|
29
29
|
interface_methods = {
|
30
|
-
'Train::Transports::Mock' =>
|
31
|
-
|
32
|
-
'Train::Transports::Mock::
|
30
|
+
'Train::Transports::Mock' =>
|
31
|
+
Train::Transports::Mock.instance_methods(false),
|
32
|
+
'Train::Transports::Mock::Connection' =>
|
33
|
+
Connection.instance_methods(false),
|
34
|
+
'Train::Transports::Mock::Connection::File' =>
|
35
|
+
Connection::FileCommon.instance_methods(false),
|
36
|
+
'Train::Transports::Mock::Connection::OS' =>
|
37
|
+
Connection::OSCommon.instance_methods(false),
|
33
38
|
}
|
34
39
|
|
35
40
|
# rubocop:disable Metrics/ParameterLists
|
@@ -63,7 +68,6 @@ class Train::Transports::Mock
|
|
63
68
|
@files = {}
|
64
69
|
@os = OS.new(self, family: 'unknown')
|
65
70
|
@commands = {}
|
66
|
-
trace_calls if @conf[:verbose]
|
67
71
|
end
|
68
72
|
|
69
73
|
def mock_os(value)
|
@@ -74,14 +78,28 @@ class Train::Transports::Mock
|
|
74
78
|
@commands[cmd] = Command.new(stdout || '', stderr || '', exit_status)
|
75
79
|
end
|
76
80
|
|
81
|
+
def command_not_found(cmd)
|
82
|
+
if @conf[:verbose]
|
83
|
+
STDERR.puts('Command not mocked:')
|
84
|
+
STDERR.puts(' '+cmd.split("\n").join("\n "))
|
85
|
+
STDERR.puts(' SHA: ' + Digest::SHA256.hexdigest(cmd))
|
86
|
+
end
|
87
|
+
mock_command(cmd)
|
88
|
+
end
|
89
|
+
|
77
90
|
def run_command(cmd)
|
78
91
|
@commands[cmd] ||
|
79
92
|
@commands[Digest::SHA256.hexdigest cmd] ||
|
80
|
-
|
93
|
+
command_not_found(cmd)
|
94
|
+
end
|
95
|
+
|
96
|
+
def file_not_found(path)
|
97
|
+
STDERR.puts('File not mocked: '+path.to_s) if @conf[:verbose]
|
98
|
+
File.new(self, path)
|
81
99
|
end
|
82
100
|
|
83
101
|
def file(path)
|
84
|
-
@files[path] ||=
|
102
|
+
@files[path] ||= file_not_found(path)
|
85
103
|
end
|
86
104
|
|
87
105
|
def to_s
|
@@ -123,9 +141,8 @@ class Train::Transports::Mock::Connection
|
|
123
141
|
end
|
124
142
|
|
125
143
|
def mounted
|
126
|
-
@mounted ||=
|
144
|
+
@mounted ||=
|
127
145
|
@runtime.run_command("mount | grep -- ' on #{@path}'")
|
128
|
-
)
|
129
146
|
end
|
130
147
|
end
|
131
148
|
end
|
data/lib/train/transports/ssh.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
4
|
# Author:: Dominik Richter (<dominik.richter@gmail.com>)
|
@@ -94,7 +94,7 @@ module Train::Transports
|
|
94
94
|
options[:key_files] = key_files
|
95
95
|
end
|
96
96
|
|
97
|
-
unless options[:password].nil?
|
97
|
+
unless options[:password].nil?
|
98
98
|
options[:auth_methods].push('password')
|
99
99
|
end
|
100
100
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Author:: Salim Afiune (<salim@afiunemaya.com.mx>)
|
4
4
|
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
@@ -174,7 +174,8 @@ module Train::Transports
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def silence_warnings
|
177
|
-
old_verbose
|
177
|
+
old_verbose = $VERBOSE
|
178
|
+
$VERBOSE = nil
|
178
179
|
yield
|
179
180
|
ensure
|
180
181
|
$VERBOSE = old_verbose
|
data/lib/train/version.rb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'train/extras'
|
2
|
+
|
3
|
+
class OsDetectWindowsTester
|
4
|
+
attr_reader :platform, :backend
|
5
|
+
include Train::Extras::DetectWindows
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@platform = {}
|
9
|
+
@backend = Train::Transports::Mock.new.connection
|
10
|
+
@backend.mock_os({ family: 'windows' })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'os_detect_windows' do
|
15
|
+
describe 'windows 2012' do
|
16
|
+
let(:detector) {
|
17
|
+
detector = OsDetectWindowsTester.new
|
18
|
+
detector.backend.mock_command('cmd /c ver', "\r\nMicrosoft Windows [Version 6.3.9600]\r\n", '', 0)
|
19
|
+
detector.backend.mock_command('wmic os get * /format:list',"\r\r\nBuildNumber=9600\r\r\nCaption=Microsoft Windows Server 2012 R2 Standard\r\r\nOSArchitecture=64-bit\r\r\nVersion=6.3.9600\r\r\n" , '', 0)
|
20
|
+
detector
|
21
|
+
}
|
22
|
+
|
23
|
+
it 'sets the correct family/release for windows' do
|
24
|
+
detector.detect_windows
|
25
|
+
detector.platform[:family].must_equal('windows')
|
26
|
+
detector.platform[:name].must_equal('Windows Server 2012 R2 Standard')
|
27
|
+
detector.platform[:arch].must_equal('64-bit')
|
28
|
+
detector.platform[:release].must_equal('6.3.9600')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'windows 2008' do
|
33
|
+
let(:detector) {
|
34
|
+
detector = OsDetectWindowsTester.new
|
35
|
+
detector.backend.mock_command('cmd /c ver', "\r\nMicrosoft Windows [Version 6.1.7601]\r\n", '', 0)
|
36
|
+
detector.backend.mock_command('wmic os get * /format:list',"\r\r\nBuildNumber=7601\r\r\nCaption=Microsoft Windows Server 2008 R2 Standard \r\r\nOSArchitecture=64-bit\r\r\nVersion=6.1.7601\r\r\n" , '', 0)
|
37
|
+
detector
|
38
|
+
}
|
39
|
+
|
40
|
+
it 'sets the correct family/release for windows' do
|
41
|
+
detector.detect_windows
|
42
|
+
detector.platform[:family].must_equal('windows')
|
43
|
+
detector.platform[:name].must_equal('Windows Server 2008 R2 Standard')
|
44
|
+
detector.platform[:arch].must_equal('64-bit')
|
45
|
+
detector.platform[:release].must_equal('6.1.7601')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'windows 7' do
|
50
|
+
let(:detector) {
|
51
|
+
detector = OsDetectWindowsTester.new
|
52
|
+
detector.backend.mock_command('cmd /c ver', "\r\nMicrosoft Windows [Version 6.1.7601]\r\n", '', 0)
|
53
|
+
detector.backend.mock_command('wmic os get * /format:list',"\r\r\nBuildNumber=7601\r\r\nCaption=Microsoft Windows 7 Enterprise \r\r\nOSArchitecture=32-bit\r\r\nVersion=6.1.7601\r\r\n\r\r\n" , '', 0)
|
54
|
+
detector
|
55
|
+
}
|
56
|
+
|
57
|
+
it 'sets the correct family/release for windows' do
|
58
|
+
detector.detect_windows
|
59
|
+
detector.platform[:family].must_equal('windows')
|
60
|
+
detector.platform[:name].must_equal('Windows 7 Enterprise')
|
61
|
+
detector.platform[:arch].must_equal('32-bit')
|
62
|
+
detector.platform[:release].must_equal('6.1.7601')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'windows 10' do
|
67
|
+
let(:detector) {
|
68
|
+
detector = OsDetectWindowsTester.new
|
69
|
+
detector.backend.mock_command('cmd /c ver', "\r\nMicrosoft Windows [Version 10.0.10240]\r\n", '', 0)
|
70
|
+
detector.backend.mock_command('wmic os get * /format:list',"\r\r\nBuildNumber=10240\r\r\nCaption=Microsoft Windows 10 Pro\r\r\nOSArchitecture=64-bit\r\r\nVersion=10.0.10240\r\r\n\r\r\n" , '', 0)
|
71
|
+
detector
|
72
|
+
}
|
73
|
+
|
74
|
+
it 'sets the correct family/release for windows' do
|
75
|
+
detector.detect_windows
|
76
|
+
detector.platform[:family].must_equal('windows')
|
77
|
+
detector.platform[:name].must_equal('Windows 10 Pro')
|
78
|
+
detector.platform[:arch].must_equal('64-bit')
|
79
|
+
detector.platform[:release].must_equal('10.0.10240')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'windows 98' do
|
84
|
+
let(:detector) {
|
85
|
+
detector = OsDetectWindowsTester.new
|
86
|
+
detector.backend.mock_command('cmd /c ver', "\r\nMicrosoft Windows [Version 4.10.1998]\r\n", '', 0)
|
87
|
+
detector.backend.mock_command('wmic os get * /format:list', nil , '', 1)
|
88
|
+
detector
|
89
|
+
}
|
90
|
+
|
91
|
+
it 'fallback to version number if wmic is not available' do
|
92
|
+
detector.detect_windows
|
93
|
+
detector.platform[:family].must_equal('windows')
|
94
|
+
detector.platform[:name].must_equal('Windows 4.10.1998')
|
95
|
+
detector.platform[:arch].must_equal(nil)
|
96
|
+
detector.platform[:release].must_equal('4.10.1998')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/test/windows/local_test.rb
CHANGED
@@ -21,10 +21,10 @@ describe 'windows local command' do
|
|
21
21
|
|
22
22
|
it 'verify os' do
|
23
23
|
os = conn.os
|
24
|
-
os[:name].must_equal
|
24
|
+
os[:name].must_equal 'Windows Server 2012 R2 Datacenter'
|
25
25
|
os[:family].must_equal "windows"
|
26
|
-
os[:release].must_equal
|
27
|
-
os[:arch].must_equal
|
26
|
+
os[:release].must_equal '6.3.9600'
|
27
|
+
os[:arch].must_equal '64-bit'
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'run echo test' do
|
data/test/windows/winrm_test.rb
CHANGED
@@ -27,10 +27,10 @@ describe 'windows local command' do
|
|
27
27
|
|
28
28
|
it 'verify os' do
|
29
29
|
os = conn.os
|
30
|
-
os[:name].must_equal
|
31
|
-
os[:family].must_equal
|
32
|
-
os[:release].must_equal
|
33
|
-
os[:arch].must_equal
|
30
|
+
os[:name].must_equal 'Windows Server 2012 R2 Datacenter'
|
31
|
+
os[:family].must_equal 'windows'
|
32
|
+
os[:release].must_equal '6.3.9600'
|
33
|
+
os[:arch].must_equal '64-bit'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'run echo test' do
|
data/train.gemspec
CHANGED
@@ -33,8 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'winrm-fs', '~> 0.3'
|
34
34
|
spec.add_dependency 'docker-api', '~> 1.22'
|
35
35
|
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency 'minitest', '~> 5.8'
|
38
|
-
spec.add_development_dependency 'mocha', '~> 1.1'
|
39
|
-
spec.add_development_dependency 'rubocop', '~> 0.34'
|
36
|
+
spec.add_development_dependency 'mocha', '~> 1.1'
|
40
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r-train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -114,34 +114,6 @@ dependencies:
|
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '1.22'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rake
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '10.4'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '10.4'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: minitest
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '5.8'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '5.8'
|
145
117
|
- !ruby/object:Gem::Dependency
|
146
118
|
name: mocha
|
147
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,20 +128,6 @@ dependencies:
|
|
156
128
|
- - "~>"
|
157
129
|
- !ruby/object:Gem::Version
|
158
130
|
version: '1.1'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rubocop
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - "~>"
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0.34'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0.34'
|
173
131
|
description: Transport interface to talk to different backends.
|
174
132
|
email:
|
175
133
|
- dominik.richter@gmail.com
|
@@ -295,6 +253,7 @@ files:
|
|
295
253
|
- test/unit/extras/linux_file_test.rb
|
296
254
|
- test/unit/extras/os_common_test.rb
|
297
255
|
- test/unit/extras/os_detect_linux_test.rb
|
256
|
+
- test/unit/extras/os_detect_windows_test.rb
|
298
257
|
- test/unit/extras/stat_test.rb
|
299
258
|
- test/unit/extras/windows_file_test.rb
|
300
259
|
- test/unit/helper.rb
|
@@ -417,6 +376,7 @@ test_files:
|
|
417
376
|
- test/unit/extras/linux_file_test.rb
|
418
377
|
- test/unit/extras/os_common_test.rb
|
419
378
|
- test/unit/extras/os_detect_linux_test.rb
|
379
|
+
- test/unit/extras/os_detect_windows_test.rb
|
420
380
|
- test/unit/extras/stat_test.rb
|
421
381
|
- test/unit/extras/windows_file_test.rb
|
422
382
|
- test/unit/helper.rb
|