manageiq-smartstate 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +34 -35
  3. data/.rubocop.yml +3 -3
  4. data/.rubocop_cc.yml +3 -4
  5. data/.rubocop_local.yml +1 -1
  6. data/.travis.yml +0 -1
  7. data/lib/disk/modules/MSCommon.rb +3 -1
  8. data/lib/disk/modules/VhdxDisk.rb +3 -1
  9. data/lib/fs/MiqMountManager.rb +2 -29
  10. data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +1 -6
  11. data/lib/fs/fat32/directory_entry.rb +60 -60
  12. data/lib/fs/iso9660/boot_sector.rb +3 -2
  13. data/lib/fs/iso9660/directory_entry.rb +3 -2
  14. data/lib/fs/iso9660/rock_ridge.rb +3 -1
  15. data/lib/fs/ntfs/attrib_attribute_list.rb +3 -1
  16. data/lib/fs/ntfs/attrib_file_name.rb +3 -1
  17. data/lib/fs/ntfs/attrib_header.rb +3 -1
  18. data/lib/fs/ntfs/attrib_index_root.rb +3 -1
  19. data/lib/fs/ntfs/attrib_volume_name.rb +3 -1
  20. data/lib/manageiq/smartstate/util.rb +18 -0
  21. data/lib/manageiq/smartstate/version.rb +1 -1
  22. data/lib/metadata/VmConfig/GetNativeCfg.rb +2 -4
  23. data/lib/metadata/VmConfig/VmConfig.rb +3 -1
  24. data/lib/metadata/VmConfig/cfgConfig.rb +4 -0
  25. data/lib/metadata/VmConfig/xmlConfig.rb +3 -3
  26. data/lib/metadata/linux/MiqRpmPackages.rb +3 -1
  27. data/lib/metadata/util/win32/Win32Accounts.rb +3 -0
  28. data/lib/metadata/util/win32/Win32EventLog.rb +3 -1
  29. data/lib/metadata/util/win32/Win32Software.rb +5 -3
  30. data/lib/metadata/util/win32/decode.rb +0 -0
  31. data/lib/metadata/util/win32/fleece_hives.rb +0 -8
  32. data/lib/metadata/util/win32/ms-registry.rb +3 -1
  33. data/lib/metadata/util/win32/peheader.rb +3 -2
  34. data/lib/miq_unicode.rb +45 -0
  35. data/manageiq-smartstate.gemspec +5 -5
  36. metadata +39 -24
  37. data/lib/fs/MetakitFS/MetakitFS.rb +0 -530
@@ -1,11 +1,12 @@
1
1
  require 'fs/iso9660/util'
2
-
3
2
  require 'sys-uname'
4
3
  require 'binary_struct'
5
- require 'util/miq-unicode'
4
+ require 'miq_unicode'
6
5
 
7
6
  module Iso9660
8
7
  class BootSector
8
+ using ManageIQ::UnicodeString
9
+
9
10
  # Universal Volume Descriptor ID.
10
11
  DESCRIPTOR_ID = "CD001"
11
12
 
@@ -1,10 +1,11 @@
1
1
  require 'fs/iso9660/util'
2
2
  require 'fs/iso9660/rock_ridge'
3
-
4
3
  require 'binary_struct'
5
- require 'util/miq-unicode'
4
+ require 'miq_unicode'
6
5
 
7
6
  module Iso9660
7
+ using ManageIQ::UnicodeString
8
+
8
9
  # FlagBits: FB_
9
10
  FB_HIDDEN = 0x01 # 0 if not hidden.
10
11
  FB_DIRECTORY = 0x02 # 0 if file.
@@ -1,7 +1,9 @@
1
1
  require 'binary_struct'
2
- require 'util/miq-unicode'
2
+ require 'miq_unicode'
3
3
 
4
4
  module Iso9660
5
+ using ManageIQ::UnicodeString
6
+
5
7
  # SUSP extensions are present if the first two characters of the SUA of
6
8
  # the first directory entry are "SP". After SUSP is identified, if the
7
9
  # first two characters of any directory entry's SUA are "RR" a Rock Ridge
@@ -1,8 +1,10 @@
1
1
  require 'fs/ntfs/utils'
2
2
  require 'binary_struct'
3
- require 'util/miq-unicode'
3
+ require 'miq_unicode'
4
4
 
5
5
  module NTFS
6
+ using ManageIQ::UnicodeString
7
+
6
8
  #
7
9
  # ATTR_LIST_ENTRY - Attribute: Attribute list (0x20).
8
10
  #
@@ -1,10 +1,12 @@
1
1
  require 'fs/ntfs/utils'
2
2
  require 'util/win32/nt_util'
3
3
  require 'binary_struct'
4
- require 'util/miq-unicode'
4
+ require 'miq_unicode'
5
5
  require 'fs/ntfs/attrib_standard_information'
6
6
 
7
7
  module NTFS
8
+ using ManageIQ::UnicodeString
9
+
8
10
  #
9
11
  # FILE_NAME_ATTR - Attribute: Filename (0x30)
10
12
  #
@@ -1,9 +1,11 @@
1
1
  require 'binary_struct'
2
- require 'util/miq-unicode'
2
+ require 'miq_unicode'
3
3
  require 'fs/ntfs/utils'
4
4
  require 'fs/ntfs/attrib_type'
5
5
 
6
6
  module NTFS
7
+ using ManageIQ::UnicodeString
8
+
7
9
  # Standard attribute header.
8
10
  # Each attribute begins with one of these.
9
11
  STANDARD_ATTRIBUTE_HEADER = BinaryStruct.new([
@@ -1,10 +1,12 @@
1
1
  require 'binary_struct'
2
- require 'util/miq-unicode'
2
+ require 'miq_unicode'
3
3
  require 'fs/ntfs/index_node_header'
4
4
  require 'fs/ntfs/directory_index_node'
5
5
  require 'fs/ntfs/index_record_header'
6
6
 
7
7
  module NTFS
8
+ using ManageIQ::UnicodeString
9
+
8
10
  #
9
11
  # INDEX_ROOT - Attribute: Index root (0x90).
10
12
  #
@@ -1,6 +1,8 @@
1
- require 'util/miq-unicode'
1
+ require 'miq_unicode'
2
2
 
3
3
  module NTFS
4
+ using ManageIQ::UnicodeString
5
+
4
6
  #
5
7
  # VOLUME_NAME - Attribute: Volume name (0x60).
6
8
  #
@@ -13,6 +13,24 @@ module ManageIQ
13
13
  rescue
14
14
  return uri_path
15
15
  end
16
+
17
+ def self.base24_decode(byte_array)
18
+ digits = %w(B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9)
19
+ out = " " * 29
20
+ out.length.downto(0) do |i|
21
+ if i.modulo(6) == 0
22
+ out[i, 1] = "-"
23
+ else
24
+ map_index = 0
25
+ 15.downto(0) do |j|
26
+ byte_value = (map_index << 8) | byte_array[j]
27
+ byte_array[j], map_index = byte_value.divmod(24)
28
+ out[i, 1] = digits[map_index]
29
+ end
30
+ end
31
+ end
32
+ out[1..-1]
33
+ end
16
34
  end
17
35
  end
18
36
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module Smartstate
3
- VERSION = "0.6.2".freeze
3
+ VERSION = "0.7.0".freeze
4
4
  end
5
5
  end
@@ -1,12 +1,10 @@
1
1
  require 'util/miq-xml'
2
- require 'util/runcmd'
3
2
  require 'metadata/VmConfig/VmConfig'
3
+ require 'awesome_spawn'
4
4
 
5
5
  class GetNativeCfg
6
- LSHW = "lshw"
7
-
8
6
  def self.new
9
- lshwXml = MiqUtil.runcmd("#{LSHW} -xml")
7
+ lshwXml = AwesomeSpawn.run!("lshw", :params => ["-xml"], :combined_output => true).output
10
8
  nodeHash = Hash.new { |h, k| h[k] = [] }
11
9
  doc = MiqXml.load(lshwXml)
12
10
  doc.find_match("//node").each { |n| nodeHash[n.attributes["id"].split(':', 2)[0]] << n }
@@ -1,6 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'metadata/VMMount/VMMount'
3
- require 'util/miq-unicode'
3
+ require 'miq_unicode'
4
4
  require 'util/miq-xml'
5
5
  require 'VMwareWebService/MiqVimInventory'
6
6
  require 'timeout'
@@ -8,6 +8,8 @@ require 'util/miq-extensions'
8
8
  require 'VMwareWebService/MiqVimBroker'
9
9
 
10
10
  class VmConfig
11
+ using ManageIQ::UnicodeString
12
+
11
13
  attr_reader :configFile
12
14
 
13
15
  def initialize(filename)
@@ -1,4 +1,8 @@
1
+ require 'miq_unicode'
2
+
1
3
  module CfgConfig
4
+ using ManageIQ::UnicodeString
5
+
2
6
  def convert(filename)
3
7
  @convertText = ""
4
8
  $log.debug "Processing Windows Configuration file [#{filename}]"
@@ -1,5 +1,5 @@
1
1
  require 'util/miq-xml'
2
- require 'util/runcmd'
2
+ require 'awesome_spawn'
3
3
 
4
4
  module XmlConfig
5
5
  def convert(filename)
@@ -12,9 +12,9 @@ module XmlConfig
12
12
  if Sys::Platform::IMPL == :linux
13
13
  begin
14
14
  # First check to see if the command is available
15
- MiqUtil.runcmd("virsh list")
15
+ AwesomeSpawn.run!("virsh", :params => ["list"])
16
16
  begin
17
- xml_data = MiqUtil.runcmd("virsh dumpxml #{File.basename(filename, ".*")}")
17
+ xml_data = AwesomeSpawn.run!("virsh", :params => ["dumpxml", File.basename(filename, ".*")], :combined_output => true).output
18
18
  rescue => err
19
19
  $log.error "#{err}\n#{err.backtrace.join("\n")}"
20
20
  end
@@ -1,11 +1,13 @@
1
1
  require 'binary_struct'
2
2
  require 'util/miq-hash_struct'
3
3
  require 'db/MiqBdb/MiqBdb'
4
- require 'util/miq-unicode'
4
+ require 'miq_unicode'
5
5
 
6
6
  # RPM Specification located at: http://jrpm.sourceforge.net/rpmspec/index.html
7
7
 
8
8
  class MiqRpmPackages
9
+ using ManageIQ::UnicodeString
10
+
9
11
  #
10
12
  # The data types we support.
11
13
  #
@@ -2,8 +2,11 @@
2
2
 
3
3
  require 'util/miq-xml'
4
4
  require 'enumerator'
5
+ require 'miq_unicode'
5
6
 
6
7
  module MiqWin32
8
+ using ManageIQ::UnicodeString
9
+
7
10
  class Accounts
8
11
  attr_reader :users, :groups
9
12
 
@@ -19,13 +19,15 @@ require 'digest/md5'
19
19
 
20
20
  # Common utilities.
21
21
  require 'binary_struct'
22
- require 'util/miq-unicode'
22
+ require 'miq_unicode'
23
23
  require 'util/miq-xml'
24
24
  require 'util/miq-exception'
25
25
 
26
26
  require 'metadata/util/event_log_filter'
27
27
 
28
28
  class Win32EventLog
29
+ using ManageIQ::UnicodeString
30
+
29
31
  # Standard file log names
30
32
  SYSTEM_LOGS = %w(Application System Security)
31
33
  BUFFER_READ_SIZE = 10485760 # 10 MB buffer
@@ -251,11 +251,13 @@ module MiqWin32
251
251
  end
252
252
 
253
253
  def self.DecodeProductKey(product_key)
254
- return if product_key.blank? || product_key.length < 67
255
- y = []; product_key.split(",")[52..67].each { |b| y << b.hex }
256
- return MIQEncode.base24Decode(y)
254
+ parts = product_key.to_s.split(",")
255
+ return if parts.length < 67
256
+
257
+ ManageIQ::Smartstate::Util.base24_decode(parts[52..67].map(&:hex))
257
258
  rescue => err
258
259
  $log.error "MIQ(DecodeProductKey): [#{err}]"
260
+ nil
259
261
  end
260
262
 
261
263
  private
File without changes
@@ -92,14 +92,6 @@ class FleeceHives
92
92
  xmlCol
93
93
  end
94
94
 
95
- def self.DecodeProductKey(product_key)
96
- return if product_key.blank? || product_key.length < 67
97
- y = []; product_key.split(",")[52..67].each { |b| y << b.hex }
98
- return MIQEncode.base24Decode(y)
99
- rescue => err
100
- $log.error "MIQ(OS-DecodeProductKey): [#{err}]"
101
- end
102
-
103
95
  def self.collectProductKeys(_xml, xmlCol, regHnd)
104
96
  prodKeys = MIQRexml.findElement("software/productkeys", xmlCol.root)
105
97
  regHnd.digitalProductKeys.each do |e|
@@ -1,7 +1,7 @@
1
1
  # encoding: US-ASCII
2
2
 
3
3
  require 'binary_struct'
4
- require 'util/miq-unicode'
4
+ require 'miq_unicode'
5
5
  require 'enumerator'
6
6
  require 'util/miq-xml'
7
7
  require 'util/xml/xml_hash'
@@ -13,6 +13,8 @@ DEBUG_LOG_PERFORMANCE = false
13
13
  DEBUG_FILE_READS = false
14
14
 
15
15
  class MSRegHive
16
+ using ManageIQ::UnicodeString
17
+
16
18
  attr_reader :fileLoadTime, :fileParseTime, :digitalProductKeys, :xmlNode
17
19
 
18
20
  # Size of the HBIN data (as well as initiale REGF) segments
@@ -1,9 +1,8 @@
1
1
  # encoding: US-ASCII
2
2
 
3
3
  require 'stringio'
4
-
5
4
  require 'binary_struct'
6
- require 'util/miq-unicode'
5
+ require 'miq_unicode'
7
6
 
8
7
  # Notes:
9
8
  # The peheader object member 'icons' is an array of icons in the file. Sub 0 is the application
@@ -12,6 +11,8 @@ require 'util/miq-unicode'
12
11
  # to open them and display each resolution contained in the icon (if more than one).
13
12
 
14
13
  class PEheader
14
+ using ManageIQ::UnicodeString
15
+
15
16
  IMAGE_NT_SIGNATURE = "PE\0\0"
16
17
  IMAGE_DOS_SIGNATURE = "MZ"
17
18
 
@@ -0,0 +1,45 @@
1
+ module ManageIQ
2
+ module UnicodeString
3
+ refine String do
4
+ def UnicodeToUtf8
5
+ dup.UnicodeToUtf8!
6
+ end
7
+
8
+ def UnicodeToUtf8!
9
+ force_encoding("UTF-16LE").encode!("UTF-8")
10
+ end
11
+
12
+ def Utf8ToUnicode
13
+ dup.Utf8ToUnicode!
14
+ end
15
+
16
+ def Utf8ToUnicode!
17
+ force_encoding("UTF-8").encode!("UTF-16LE")
18
+ end
19
+
20
+ def AsciiToUtf8
21
+ dup.AsciiToUtf8!
22
+ end
23
+
24
+ def AsciiToUtf8!
25
+ force_encoding("ISO-8859-1").encode!("UTF-8")
26
+ end
27
+
28
+ def Utf8ToAscii
29
+ dup.Utf8ToAscii!
30
+ end
31
+
32
+ def Utf8ToAscii!
33
+ force_encoding("UTF-8").encode!("ISO-8859-1")
34
+ end
35
+
36
+ def Ucs2ToAscii
37
+ dup.Ucs2ToAscii!
38
+ end
39
+
40
+ def Ucs2ToAscii!
41
+ force_encoding("UTF-16LE").encode!("ISO-8859-1")
42
+ end
43
+ end
44
+ end
45
+ end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_dependency "activesupport"
24
+ spec.add_dependency "awesome_spawn", "~> 1.5"
24
25
  spec.add_dependency "azure-armrest", "~> 0.9"
25
26
  spec.add_dependency "binary_struct", "~> 2.1"
26
27
  spec.add_dependency "iniparse"
@@ -33,13 +34,12 @@ Gem::Specification.new do |spec|
33
34
  spec.add_dependency "vmware_web_service", "~>2.0"
34
35
 
35
36
  spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "camcorder"
38
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
39
+ spec.add_development_dependency "manageiq-style"
36
40
  spec.add_development_dependency "rake"
37
41
  spec.add_development_dependency "rspec", "~> 3.0"
38
- spec.add_development_dependency "camcorder"
42
+ spec.add_development_dependency "simplecov"
39
43
  spec.add_development_dependency "vcr", "~>3.0.2"
40
44
  spec.add_development_dependency "webmock", "~>2.3.1"
41
- spec.add_development_dependency "simplecov"
42
- spec.add_development_dependency "rubocop"
43
- spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
44
-
45
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-smartstate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-21 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_spawn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: azure-armrest
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +193,7 @@ dependencies:
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
- name: rake
196
+ name: camcorder
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
@@ -193,21 +207,21 @@ dependencies:
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
- name: rspec
210
+ name: codeclimate-test-reporter
197
211
  requirement: !ruby/object:Gem::Requirement
198
212
  requirements:
199
213
  - - "~>"
200
214
  - !ruby/object:Gem::Version
201
- version: '3.0'
215
+ version: 1.0.0
202
216
  type: :development
203
217
  prerelease: false
204
218
  version_requirements: !ruby/object:Gem::Requirement
205
219
  requirements:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
- version: '3.0'
222
+ version: 1.0.0
209
223
  - !ruby/object:Gem::Dependency
210
- name: camcorder
224
+ name: manageiq-style
211
225
  requirement: !ruby/object:Gem::Requirement
212
226
  requirements:
213
227
  - - ">="
@@ -221,33 +235,33 @@ dependencies:
221
235
  - !ruby/object:Gem::Version
222
236
  version: '0'
223
237
  - !ruby/object:Gem::Dependency
224
- name: vcr
238
+ name: rake
225
239
  requirement: !ruby/object:Gem::Requirement
226
240
  requirements:
227
- - - "~>"
241
+ - - ">="
228
242
  - !ruby/object:Gem::Version
229
- version: 3.0.2
243
+ version: '0'
230
244
  type: :development
231
245
  prerelease: false
232
246
  version_requirements: !ruby/object:Gem::Requirement
233
247
  requirements:
234
- - - "~>"
248
+ - - ">="
235
249
  - !ruby/object:Gem::Version
236
- version: 3.0.2
250
+ version: '0'
237
251
  - !ruby/object:Gem::Dependency
238
- name: webmock
252
+ name: rspec
239
253
  requirement: !ruby/object:Gem::Requirement
240
254
  requirements:
241
255
  - - "~>"
242
256
  - !ruby/object:Gem::Version
243
- version: 2.3.1
257
+ version: '3.0'
244
258
  type: :development
245
259
  prerelease: false
246
260
  version_requirements: !ruby/object:Gem::Requirement
247
261
  requirements:
248
262
  - - "~>"
249
263
  - !ruby/object:Gem::Version
250
- version: 2.3.1
264
+ version: '3.0'
251
265
  - !ruby/object:Gem::Dependency
252
266
  name: simplecov
253
267
  requirement: !ruby/object:Gem::Requirement
@@ -263,33 +277,33 @@ dependencies:
263
277
  - !ruby/object:Gem::Version
264
278
  version: '0'
265
279
  - !ruby/object:Gem::Dependency
266
- name: rubocop
280
+ name: vcr
267
281
  requirement: !ruby/object:Gem::Requirement
268
282
  requirements:
269
- - - ">="
283
+ - - "~>"
270
284
  - !ruby/object:Gem::Version
271
- version: '0'
285
+ version: 3.0.2
272
286
  type: :development
273
287
  prerelease: false
274
288
  version_requirements: !ruby/object:Gem::Requirement
275
289
  requirements:
276
- - - ">="
290
+ - - "~>"
277
291
  - !ruby/object:Gem::Version
278
- version: '0'
292
+ version: 3.0.2
279
293
  - !ruby/object:Gem::Dependency
280
- name: codeclimate-test-reporter
294
+ name: webmock
281
295
  requirement: !ruby/object:Gem::Requirement
282
296
  requirements:
283
297
  - - "~>"
284
298
  - !ruby/object:Gem::Version
285
- version: 1.0.0
299
+ version: 2.3.1
286
300
  type: :development
287
301
  prerelease: false
288
302
  version_requirements: !ruby/object:Gem::Requirement
289
303
  requirements:
290
304
  - - "~>"
291
305
  - !ruby/object:Gem::Version
292
- version: 1.0.0
306
+ version: 2.3.1
293
307
  description: ManageIQ SmartState Analysis
294
308
  email:
295
309
  executables: []
@@ -390,7 +404,6 @@ files:
390
404
  - lib/disk/modules/miq_dummy_disk.rb
391
405
  - lib/disk/modules/vhdx_bat_entry.rb
392
406
  - lib/disk/test.rb
393
- - lib/fs/MetakitFS/MetakitFS.rb
394
407
  - lib/fs/MiqFS/FsProbe.rb
395
408
  - lib/fs/MiqFS/MiqFS.rb
396
409
  - lib/fs/MiqFS/modules/AUFSProbe.rb
@@ -560,6 +573,7 @@ files:
560
573
  - lib/metadata/util/win32/Win32Software.rb
561
574
  - lib/metadata/util/win32/Win32System.rb
562
575
  - lib/metadata/util/win32/boot_info_win.rb
576
+ - lib/metadata/util/win32/decode.rb
563
577
  - lib/metadata/util/win32/fleece_hives.rb
564
578
  - lib/metadata/util/win32/ms-registry.rb
565
579
  - lib/metadata/util/win32/peheader.rb
@@ -567,6 +581,7 @@ files:
567
581
  - lib/metadata/util/win32/system_path_win.rb
568
582
  - lib/metadata/util/win32/versioninfo.rb
569
583
  - lib/miq_tempfile.rb
584
+ - lib/miq_unicode.rb
570
585
  - lib/tasks/azure.rake
571
586
  - log/.gitkeep
572
587
  - manageiq-smartstate.gemspec