train-core 3.8.6 → 3.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 677b8d64465040ada12f33f5c2fe7689b81922b10482ca7c78e0b57e10b5139a
4
- data.tar.gz: 8c3f7518f0453329897de457e4ea4e6f24d6262dd77f5731b42b5cd44ea706c5
3
+ metadata.gz: 2d3eabbefcf1adac9f0d1142143709c390d4bac2b480ea26ab2b54b290d4c94b
4
+ data.tar.gz: dd7f3e0edf4f7c0fad07582d2bf895578b31ebd1cba881bb6e5e7b32c9f312fb
5
5
  SHA512:
6
- metadata.gz: 8998652d978144993b1768c71d25d8b06f6501c661e827576ecbb06d3e2d8748296d26d68578d6c451a2a20617c1750a5cb66c096adb020b5bc3c0e2ad6bfb4e
7
- data.tar.gz: 68cad9574d5282fea0d90fc00104506d0d33ecfd5e5d6879f33f88109aec9b881d0c9d49748e178c4b8ca05896827425d4bb283bb7d52aedbcc722d2817b6b27
6
+ metadata.gz: 91b758fd870fd5c4f32672a7e671d468fced308acc7f58754204e4e9beaa4baba6c798c25215c8112ed438ef0a5910725af4dcff1764a322d917f343af38996c
7
+ data.tar.gz: 48ccaea241788cf7d9aa7a682348781755a4e3cefcf95ae7134c8ede4b273acdc95eb2de109a5a169a00fc527364d74757c0506a98bef75cff44f786957f52c9
data/lib/train/errors.rb CHANGED
@@ -38,6 +38,9 @@ module Train
38
38
  # Exception for when no platform can be detected.
39
39
  class PlatformDetectionFailed < Error; end
40
40
 
41
+ # Exception for when no uuid for the platform can be detected.
42
+ class PlatformUuidDetectionFailed < Error; end
43
+
41
44
  # Exception for when a invalid cache type is passed.
42
45
  class UnknownCacheType < Error; end
43
46
 
@@ -97,6 +97,12 @@ module Train::Platforms::Detect::Helpers
97
97
  return @cache[:cisco] = { version: m[2], model: m[1], type: "ios-xe" }
98
98
  end
99
99
 
100
+ # CSR 1000V (for example) does not specify model
101
+ m = res.match(/Cisco IOS XE Software, Version (\d+\.\d+\.\d+[A-Z]*)/)
102
+ unless m.nil?
103
+ return @cache[:cisco] = { version: m[1], type: "ios-xe" }
104
+ end
105
+
100
106
  m = res.match(/Cisco Nexus Operating System \(NX-OS\) Software/)
101
107
  unless m.nil?
102
108
  v = res[/^\s*system:\s+version (\d+\.\d+)/, 1]
@@ -122,7 +128,6 @@ module Train::Platforms::Detect::Helpers
122
128
  end
123
129
 
124
130
  def unix_uuid_from_machine_file
125
- # require 'pry';binding.pry
126
131
  %W{
127
132
  /etc/chef/chef_guid
128
133
  #{ENV["HOME"]}/.chef/chef_guid
@@ -20,12 +20,13 @@ module Train::Platforms::Detect
20
20
  elsif @platform.windows?
21
21
  windows_uuid
22
22
  else
23
- if @platform[:uuid_command]
23
+ # Checking "unknown" :uuid_command which is set for mock transport.
24
+ if @platform[:uuid_command] && !@platform[:uuid_command] == "unknown"
24
25
  result = @backend.run_command(@platform[:uuid_command])
25
26
  return uuid_from_string(result.stdout.chomp) if result.exit_status == 0 && !result.stdout.empty?
26
27
  end
27
28
 
28
- raise "Could not find platform uuid! Please set a uuid_command for your platform."
29
+ raise Train::PlatformUuidDetectionFailed.new("Could not find platform uuid! Please set a uuid_command for your platform.")
29
30
  end
30
31
  end
31
32
  end
@@ -326,7 +326,16 @@ class Train::Transports::SSH
326
326
  cmd = @cmd_wrapper.run(cmd) if @cmd_wrapper
327
327
 
328
328
  # Timeout the command if requested and able
329
- cmd = "timeout #{timeout}s #{cmd}" if timeout && timeoutable?(cmd)
329
+ if timeout && timeoutable?(cmd)
330
+ # if cmd start with sudo then we need to make sure the timeout should be prepend with sudo else actual timeout is not working.
331
+ if cmd.strip.split[0] == "sudo"
332
+ split_cmd = cmd.strip.split
333
+ split_cmd[0] = "sudo timeout #{timeout}s"
334
+ cmd = split_cmd.join(" ")
335
+ else
336
+ cmd = "timeout #{timeout}s #{cmd}"
337
+ end
338
+ end
330
339
 
331
340
  logger.debug("[SSH] #{self} cmd = #{cmd}")
332
341
 
data/lib/train/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
3
3
 
4
4
  module Train
5
- VERSION = "3.8.6".freeze
5
+ VERSION = "3.9.2".freeze
6
6
  end
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: 3.8.6
4
+ version: 3.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-17 00:00:00.000000000 Z
11
+ date: 2022-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable