train-core 2.1.13 → 2.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/train.rb +5 -3
- data/lib/train/extras/command_wrapper.rb +2 -0
- data/lib/train/extras/stat.rb +5 -1
- data/lib/train/file/local.rb +2 -0
- data/lib/train/file/local/windows.rb +8 -3
- data/lib/train/file/remote.rb +4 -0
- data/lib/train/file/remote/aix.rb +2 -0
- data/lib/train/file/remote/linux.rb +2 -0
- data/lib/train/file/remote/unix.rb +3 -1
- data/lib/train/file/remote/windows.rb +17 -5
- data/lib/train/options.rb +6 -5
- data/lib/train/platforms.rb +22 -22
- data/lib/train/platforms/detect/helpers/os_common.rb +9 -1
- data/lib/train/platforms/detect/helpers/os_linux.rb +2 -0
- data/lib/train/platforms/detect/helpers/os_windows.rb +8 -3
- data/lib/train/platforms/detect/scanner.rb +1 -0
- data/lib/train/platforms/detect/specifications/os.rb +395 -391
- data/lib/train/platforms/family.rb +5 -0
- data/lib/train/platforms/platform.rb +8 -6
- data/lib/train/plugins.rb +3 -3
- data/lib/train/plugins/base_connection.rb +6 -0
- data/lib/train/transports/cisco_ios_connection.rb +2 -0
- data/lib/train/transports/local.rb +1 -1
- data/lib/train/transports/mock.rb +5 -3
- data/lib/train/transports/ssh.rb +1 -1
- data/lib/train/transports/ssh_connection.rb +2 -0
- data/lib/train/transports/winrm.rb +1 -1
- data/lib/train/transports/winrm_connection.rb +4 -2
- data/lib/train/version.rb +1 -1
- metadata +2 -2
@@ -65,6 +65,7 @@ module Train::Platforms
|
|
65
65
|
|
66
66
|
def title(title = nil)
|
67
67
|
return @title if title.nil?
|
68
|
+
|
68
69
|
@title = title
|
69
70
|
self
|
70
71
|
end
|
@@ -73,10 +74,6 @@ module Train::Platforms
|
|
73
74
|
@platform
|
74
75
|
end
|
75
76
|
|
76
|
-
def cisco_ios? # TODO: kinda a hack. needed to prevent tests from corrupting.
|
77
|
-
false
|
78
|
-
end
|
79
|
-
|
80
77
|
# Add generic family? and platform methods to an existing platform
|
81
78
|
#
|
82
79
|
# This is done later to add any custom
|
@@ -88,8 +85,11 @@ module Train::Platforms
|
|
88
85
|
# Add in family methods
|
89
86
|
family_list = Train::Platforms.families
|
90
87
|
family_list.each_value do |k|
|
91
|
-
|
92
|
-
|
88
|
+
name = "#{k.name}?"
|
89
|
+
|
90
|
+
next if respond_to?(name)
|
91
|
+
|
92
|
+
define_singleton_method(name) do
|
93
93
|
family_hierarchy.include?(k.name)
|
94
94
|
end
|
95
95
|
end
|
@@ -97,6 +97,7 @@ module Train::Platforms
|
|
97
97
|
# Helper methods for direct platform info
|
98
98
|
@platform.each_key do |m|
|
99
99
|
next if respond_to?(m)
|
100
|
+
|
100
101
|
define_singleton_method(m) do
|
101
102
|
@platform[m]
|
102
103
|
end
|
@@ -105,6 +106,7 @@ module Train::Platforms
|
|
105
106
|
# Create method for name if its not already true
|
106
107
|
m = name + "?"
|
107
108
|
return if respond_to?(m)
|
109
|
+
|
108
110
|
define_singleton_method(m) do
|
109
111
|
true
|
110
112
|
end
|
data/lib/train/plugins.rb
CHANGED
@@ -31,9 +31,9 @@ module Train
|
|
31
31
|
def self.plugin(version = 1)
|
32
32
|
if version != 1
|
33
33
|
raise ClientError,
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
"Only understand train plugin version 1. You are trying to "\
|
35
|
+
"initialize a train plugin #{version}, which is not supported "\
|
36
|
+
"in the current release of train."
|
37
37
|
end
|
38
38
|
::Train::Plugins::Transport
|
39
39
|
end
|
@@ -65,11 +65,13 @@ class Train::Plugins::Transport
|
|
65
65
|
# :api_call, :file and :command types
|
66
66
|
def enable_cache(type)
|
67
67
|
raise Train::UnknownCacheType, "#{type} is not a valid cache type" unless @cache_enabled.keys.include?(type.to_sym)
|
68
|
+
|
68
69
|
@cache_enabled[type.to_sym] = true
|
69
70
|
end
|
70
71
|
|
71
72
|
def disable_cache(type)
|
72
73
|
raise Train::UnknownCacheType, "#{type} is not a valid cache type" unless @cache_enabled.keys.include?(type.to_sym)
|
74
|
+
|
73
75
|
@cache_enabled[type.to_sym] = false
|
74
76
|
clear_cache(type.to_sym)
|
75
77
|
end
|
@@ -101,6 +103,10 @@ class Train::Plugins::Transport
|
|
101
103
|
plat
|
102
104
|
end
|
103
105
|
|
106
|
+
def inspect
|
107
|
+
"%s[%s]" % [self.class, (@options[:backend] || "Unknown")]
|
108
|
+
end
|
109
|
+
|
104
110
|
alias direct_platform force_platform!
|
105
111
|
|
106
112
|
# Get information on the operating system which this transport connects to.
|
@@ -69,6 +69,7 @@ class Train::Transports::SSH
|
|
69
69
|
if @buf =~ /Bad (secrets|password)|Access denied/
|
70
70
|
raise BadEnablePassword
|
71
71
|
end
|
72
|
+
|
72
73
|
session.connection.process(0)
|
73
74
|
end
|
74
75
|
|
@@ -123,6 +124,7 @@ class Train::Transports::SSH
|
|
123
124
|
|
124
125
|
ch.send_channel_request("shell") do |_, success|
|
125
126
|
raise "Failed to open SSH shell" unless success
|
127
|
+
|
126
128
|
logger.debug("[SSH] shell opened")
|
127
129
|
end
|
128
130
|
end
|
@@ -42,7 +42,7 @@ module Train::Transports
|
|
42
42
|
if os.windows?
|
43
43
|
# Force a 64 bit poweshell if needed
|
44
44
|
if RUBY_PLATFORM == "i386-mingw32" && os.arch == "x86_64"
|
45
|
-
powershell_cmd = "#{ENV[
|
45
|
+
powershell_cmd = "#{ENV["SystemRoot"]}\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
|
46
46
|
else
|
47
47
|
powershell_cmd = "powershell"
|
48
48
|
end
|
@@ -40,10 +40,12 @@ module Train::Transports
|
|
40
40
|
interface_methods[classname.to_s].include?(id)
|
41
41
|
next
|
42
42
|
end
|
43
|
+
|
43
44
|
# kindly borrowed from the wonderful simple-tracer by matugm
|
44
45
|
arg_names = eval(
|
45
46
|
"method(__method__).parameters.map { |arg| arg[1].to_s }",
|
46
|
-
binding
|
47
|
+
binding
|
48
|
+
)
|
47
49
|
args = eval("#{arg_names}.map { |arg| eval(arg) }", binding).join(", ")
|
48
50
|
prefix = "-" * (classname.to_s.count(":") - 2) + "> "
|
49
51
|
puts("#{prefix}#{id} #{args}")
|
@@ -141,8 +143,8 @@ class Train::Transports::Mock::Connection
|
|
141
143
|
class File < Train::File
|
142
144
|
def self.from_json(json)
|
143
145
|
res = new(json["backend"],
|
144
|
-
|
145
|
-
|
146
|
+
json["path"],
|
147
|
+
json["follow_symlink"])
|
146
148
|
res.type = json["type"]
|
147
149
|
Train::File::DATA_FIELDS.each do |f|
|
148
150
|
m = (f.tr("?", "") + "=").to_sym
|
data/lib/train/transports/ssh.rb
CHANGED
@@ -104,7 +104,7 @@ module Train::Transports
|
|
104
104
|
if options[:auth_methods] == ["none"]
|
105
105
|
if ssh_known_identities.empty?
|
106
106
|
raise Train::ClientError,
|
107
|
-
|
107
|
+
"Your SSH Agent has no keys added, and you have not specified a password or a key file"
|
108
108
|
else
|
109
109
|
logger.debug("[SSH] Using Agent keys as no password or key file have been specified")
|
110
110
|
options[:auth_methods].push("publickey")
|
@@ -56,6 +56,7 @@ class Train::Transports::SSH
|
|
56
56
|
# (see Base::Connection#close)
|
57
57
|
def close
|
58
58
|
return if @session.nil?
|
59
|
+
|
59
60
|
logger.debug("[SSH] closing connection to #{self}")
|
60
61
|
session.close
|
61
62
|
ensure
|
@@ -84,6 +85,7 @@ class Train::Transports::SSH
|
|
84
85
|
|
85
86
|
def generate_proxy_command
|
86
87
|
return @proxy_command unless @proxy_command.nil?
|
88
|
+
|
87
89
|
args = %w{ ssh }
|
88
90
|
args += ssh_opts
|
89
91
|
args += %W{ #{@bastion_user}@#{@bastion_host} }
|
@@ -176,7 +176,7 @@ module Train::Transports
|
|
176
176
|
" `gem 'winrm-fs', '#{spec_version}'`."
|
177
177
|
)
|
178
178
|
raise Train::UserError,
|
179
|
-
|
179
|
+
"Could not load or activate WinRM::FS (#{e.message})"
|
180
180
|
end
|
181
181
|
|
182
182
|
# Load WinRM::Transport code.
|
@@ -42,6 +42,7 @@ class Train::Transports::WinRM
|
|
42
42
|
# (see Base::Connection#close)
|
43
43
|
def close
|
44
44
|
return if @session.nil?
|
45
|
+
|
45
46
|
session.close
|
46
47
|
ensure
|
47
48
|
@session = nil
|
@@ -58,8 +59,8 @@ class Train::Transports::WinRM
|
|
58
59
|
login_command_for_linux
|
59
60
|
else
|
60
61
|
raise ActionFailed,
|
61
|
-
|
62
|
-
|
62
|
+
"Remote login not supported in #{self.class} " \
|
63
|
+
"from host OS '#{RbConfig::CONFIG["host_os"]}'."
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
@@ -98,6 +99,7 @@ class Train::Transports::WinRM
|
|
98
99
|
|
99
100
|
def run_command_via_connection(command, &data_handler)
|
100
101
|
return if command.nil?
|
102
|
+
|
101
103
|
logger.debug("[WinRM] #{self} (#{command})")
|
102
104
|
out = ""
|
103
105
|
|
data/lib/train/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|