manageiq-smartstate 0.5.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) 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 +2 -3
  7. data/lib/MiqVm/MiqRhevmVm.rb +1 -1
  8. data/lib/MiqVm/MiqVm.rb +0 -140
  9. data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +0 -1
  10. data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +0 -1
  11. data/lib/VolumeManager/MiqLdm.rb +1 -1
  12. data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +2 -3
  13. data/lib/disk/modules/MSCommon.rb +3 -1
  14. data/lib/disk/modules/VhdxDisk.rb +3 -1
  15. data/lib/fs/MiqMountManager.rb +2 -29
  16. data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +1 -6
  17. data/lib/fs/ext3/superblock.rb +1 -1
  18. data/lib/fs/ext4/superblock.rb +2 -2
  19. data/lib/fs/fat32/directory_entry.rb +60 -60
  20. data/lib/fs/iso9660/boot_sector.rb +3 -2
  21. data/lib/fs/iso9660/directory_entry.rb +3 -2
  22. data/lib/fs/iso9660/rock_ridge.rb +3 -1
  23. data/lib/fs/modules/LinuxMount.rb +3 -3
  24. data/lib/fs/ntfs/attrib_attribute_list.rb +3 -1
  25. data/lib/fs/ntfs/attrib_file_name.rb +3 -1
  26. data/lib/fs/ntfs/attrib_header.rb +3 -1
  27. data/lib/fs/ntfs/attrib_index_root.rb +3 -1
  28. data/lib/fs/ntfs/attrib_object_id.rb +1 -1
  29. data/lib/fs/ntfs/attrib_volume_name.rb +3 -1
  30. data/lib/fs/xfs/allocation_group.rb +1 -1
  31. data/lib/fs/xfs/bmap_btree_block.rb +1 -1
  32. data/lib/fs/xfs/superblock.rb +1 -1
  33. data/lib/manageiq/smartstate/util.rb +18 -0
  34. data/lib/manageiq/smartstate/version.rb +1 -1
  35. data/lib/metadata/MIQExtract/MIQExtract.rb +2 -3
  36. data/lib/metadata/VmConfig/GetNativeCfg.rb +2 -4
  37. data/lib/metadata/VmConfig/VmConfig.rb +7 -5
  38. data/lib/metadata/VmConfig/cfgConfig.rb +4 -0
  39. data/lib/metadata/VmConfig/xmlConfig.rb +3 -3
  40. data/lib/metadata/linux/MiqRpmPackages.rb +3 -1
  41. data/lib/metadata/util/md5deep.rb +4 -2
  42. data/lib/metadata/util/win32/Win32Accounts.rb +3 -0
  43. data/lib/metadata/util/win32/Win32EventLog.rb +5 -3
  44. data/lib/metadata/util/win32/Win32Software.rb +5 -3
  45. data/lib/metadata/util/win32/decode.rb +0 -0
  46. data/lib/metadata/util/win32/fleece_hives.rb +0 -8
  47. data/lib/metadata/util/win32/ms-registry.rb +3 -1
  48. data/lib/metadata/util/win32/peheader.rb +7 -8
  49. data/lib/miq_unicode.rb +45 -0
  50. data/manageiq-smartstate.gemspec +9 -7
  51. metadata +76 -33
  52. data/lib/fs/MetakitFS/MetakitFS.rb +0 -530
@@ -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
  # ////////////////////////////////////////////////////////////////////////////
9
8
  # // Data definitions.
@@ -13,6 +12,7 @@ require 'util/miq-unicode'
13
12
  # (which yields uppercase names on XP).
14
13
 
15
14
  module Fat32
15
+ using ManageIQ::UnicodeString
16
16
 
17
17
  DIR_ENT_SFN = BinaryStruct.new([
18
18
  'a11', 'name', # If name[0] = 0, unallocated; if name[0] = 0xe5, deleted. DOES NOT INCLUDE DOT.
@@ -39,17 +39,17 @@ module Fat32
39
39
  'S', 'reserved2', # Reserved.
40
40
  'a4', 'name3' # UNICODE chars 12-13 of name.
41
41
  ])
42
-
42
+
43
43
  CHARS_PER_LFN = 13
44
44
  LFN_NAME_MAXLEN = 260
45
45
  DIR_ENT_SIZE = 32
46
46
  ATTRIB_OFFSET = 11
47
-
47
+
48
48
  # ////////////////////////////////////////////////////////////////////////////
49
49
  # // Class.
50
50
 
51
51
  class DirectoryEntry
52
-
52
+
53
53
  # From the UTF-8 perspective.
54
54
  # LFN name components: entry hash name, char offset, length.
55
55
  LFN_NAME_COMPONENTS = [
@@ -61,19 +61,19 @@ module Fat32
61
61
  LFN_NC_HASHNAME = 0
62
62
  LFN_NC_OFFSET = 1
63
63
  LFN_NC_LENGTH = 2
64
-
64
+
65
65
  # SFN failure cases.
66
66
  SFN_NAME_LENGTH = 1
67
67
  SFN_EXT_LENGTH = 2
68
68
  SFN_NAME_NULL = 3
69
69
  SFN_NAME_DEVICE = 4
70
70
  SFN_ILLEGAL_CHARS = 5
71
-
71
+
72
72
  # LFN failure cases.
73
73
  LFN_NAME_LENGTH = 1
74
74
  LFN_NAME_DEVICE = 2
75
75
  LFN_ILLEGAL_CHARS = 3
76
-
76
+
77
77
  # FileAttributes
78
78
  FA_READONLY = 0x01
79
79
  FA_HIDDEN = 0x02
@@ -82,7 +82,7 @@ module Fat32
82
82
  FA_DIRECTORY = 0x10
83
83
  FA_ARCHIVE = 0x20
84
84
  FA_LFN = 0x0f
85
-
85
+
86
86
  # DOS time masks.
87
87
  MSK_DAY = 0x001f # Range: 1 - 31
88
88
  MSK_MONTH = 0x01e0 # Right shift 5, Range: 1 - 12
@@ -90,18 +90,18 @@ module Fat32
90
90
  MSK_SEC = 0x001f # Range: 0 - 29 WARNING: 2 second granularity on this.
91
91
  MSK_MIN = 0x07e0 # Right shift 5, Range: 0 - 59
92
92
  MSK_HOUR = 0xf800 # Right shift 11, Range: 0 - 23
93
-
93
+
94
94
  # AllocationFlags
95
95
  AF_NOT_ALLOCATED = 0x00
96
96
  AF_DELETED = 0xe5
97
97
  AF_LFN_LAST = 0x40
98
-
98
+
99
99
  # Members.
100
100
  attr_reader :unused, :name, :dirty
101
101
  attr_accessor :parentCluster, :parentOffset
102
102
  # NOTE: Directory is responsible for setting parent.
103
103
  # These describe the cluster & offset of the START of the directory entry.
104
-
104
+
105
105
  # Initialization
106
106
  def initialize(buf = nil)
107
107
  # Create for write.
@@ -109,7 +109,7 @@ module Fat32
109
109
  self.create
110
110
  return
111
111
  end
112
-
112
+
113
113
  # Handle possibly multiple LFN records.
114
114
  data = StringIO.new(buf); @lfn_ents = []
115
115
  checksum = 0; @name = ""
@@ -119,12 +119,12 @@ module Fat32
119
119
  @unused = ""
120
120
  return
121
121
  end
122
-
122
+
123
123
  # If attribute contains 0x0f then LFN entry.
124
124
  isLfn = buf[ATTRIB_OFFSET] == FA_LFN
125
125
  @dir_ent = isLfn ? DIR_ENT_LFN.decode(buf) : DIR_ENT_SFN.decode(buf)
126
126
  break if !isLfn
127
-
127
+
128
128
  # Ignore this entry if deleted or not allocated.
129
129
  af = @dir_ent['seq_num']
130
130
  if af == AF_DELETED || af == AF_NOT_ALLOCATED
@@ -132,19 +132,19 @@ module Fat32
132
132
  @unused = data.read()
133
133
  return
134
134
  end
135
-
135
+
136
136
  # Set checksum or make sure it's the same
137
137
  checksum = @dir_ent['checksum'] if checksum == 0
138
138
  raise "Directory entry LFN checksum mismatch." if @dir_ent['checksum'] != checksum
139
-
139
+
140
140
  # Track LFN entry, gather names & prepend to name.
141
141
  @lfn_ents << @dir_ent
142
142
  @name = getLongNameFromEntry(@dir_ent) + @name
143
143
  end #LFN loop
144
-
144
+
145
145
  # Push the rest of the data back.
146
146
  @unused = data.read()
147
-
147
+
148
148
  # If this is the last record of an LFN chain, check the checksum.
149
149
  if checksum != 0
150
150
  csum = calcChecksum
@@ -156,7 +156,7 @@ module Fat32
156
156
  raise "Checksum error"
157
157
  end
158
158
  end
159
-
159
+
160
160
  # Populate name if not LFN.
161
161
  if @name == "" && !@dir_ent['name'].empty?
162
162
  @name = @dir_ent['name'][0, 8].strip
@@ -167,21 +167,21 @@ module Fat32
167
167
 
168
168
  # ////////////////////////////////////////////////////////////////////////////
169
169
  # // Class helpers & accessors.
170
-
170
+
171
171
  # Return this entry as a raw string.
172
172
  def raw
173
173
  out = ""
174
174
  @lfn_ents.each {|ent| out += BinaryStruct.encode(ent, DIR_ENT_LFN)} if @lfn_ents
175
175
  out += BinaryStruct.encode(@dir_ent, DIR_ENT_SFN)
176
176
  end
177
-
177
+
178
178
  # Number of dir ent structures (both sfn and lfn).
179
179
  def numEnts
180
180
  num = 1
181
181
  num += @lfn_ents.size if @lfn_ents
182
182
  return num
183
183
  end
184
-
184
+
185
185
  # Return normalized 8.3 name.
186
186
  def shortName
187
187
  name = @dir_ent['name'][0, 8].strip
@@ -189,7 +189,7 @@ module Fat32
189
189
  name += "." + ext if ext != ""
190
190
  return name
191
191
  end
192
-
192
+
193
193
  # Construct & return long name from lfn entries.
194
194
  def longName
195
195
  return nil if @lfn_ents == nil
@@ -197,7 +197,7 @@ module Fat32
197
197
  @lfn_ents.reverse.each {|ent| name += getLongNameFromEntry(ent)}
198
198
  return name
199
199
  end
200
-
200
+
201
201
  # WRITE: change filename.
202
202
  def name=(filename)
203
203
  @dirty = true
@@ -215,17 +215,17 @@ module Fat32
215
215
  @name = filename
216
216
  end
217
217
  end
218
-
218
+
219
219
  # WRITE: change magic number.
220
220
  def magic=(magic)
221
221
  @dirty = true
222
222
  @dir_ent['reserved1'] = magic
223
223
  end
224
-
224
+
225
225
  def magic
226
226
  return @dir_ent['reserved1']
227
227
  end
228
-
228
+
229
229
  # WRITE: change attribs.
230
230
  def setAttribute(attrib, set = true)
231
231
  @dirty = true
@@ -235,27 +235,27 @@ module Fat32
235
235
  @dir_ent['attributes'] &= (~attrib)
236
236
  end
237
237
  end
238
-
238
+
239
239
  # WRITE: change length.
240
240
  def length=(len)
241
241
  @dirty = true
242
242
  @dir_ent['file_size'] = len
243
243
  end
244
-
244
+
245
245
  # WRITE: change first cluster.
246
246
  def firstCluster=(first_clus)
247
247
  @dirty = true
248
248
  @dir_ent['first_clus_hi'] = (first_clus >> 16)
249
249
  @dir_ent['first_clus_lo'] = (first_clus & 0xffff)
250
250
  end
251
-
251
+
252
252
  # WRITE: change access time.
253
253
  def aTime=(tim)
254
254
  @dirty = true
255
255
  time, day = rubyToDosTime(tim)
256
256
  @dir_ent['atime_day'] = day
257
257
  end
258
-
258
+
259
259
  # To support root dir times (all zero).
260
260
  def zeroTime
261
261
  @dirty = true
@@ -263,13 +263,13 @@ module Fat32
263
263
  @dir_ent['ctime_tos'] = 0; @dir_ent['ctime_hms'] = 0; @dir_ent['ctime_day'] = 0
264
264
  @dir_ent['mtime_hms'] = 0; @dir_ent['mtime_day'] = 0
265
265
  end
266
-
266
+
267
267
  # WRITE: change modified (written) time.
268
268
  def mTime=(tim)
269
269
  @dirty = true
270
270
  @dir_ent['mtime_hms'], @dir_ent['mtime_day'] = rubyToDosTime(tim)
271
271
  end
272
-
272
+
273
273
  # WRITE: write or rewrite directory entry.
274
274
  def writeEntry(bs)
275
275
  return if not @dirty
@@ -290,7 +290,7 @@ module Fat32
290
290
  bs.putCluster(cluster, buf)
291
291
  @dirty = false
292
292
  end
293
-
293
+
294
294
  # WRITE: delete file.
295
295
  def delete(bs)
296
296
  # Deallocate data chain.
@@ -301,43 +301,43 @@ module Fat32
301
301
  @dirty = true
302
302
  self.writeEntry(bs)
303
303
  end
304
-
304
+
305
305
  def close(bs)
306
306
  writeEntry(bs) if @dirty
307
307
  end
308
-
308
+
309
309
  def attributes
310
310
  return @dir_ent['attributes']
311
311
  end
312
-
312
+
313
313
  def length
314
314
  return @dir_ent['file_size']
315
315
  end
316
-
316
+
317
317
  def firstCluster
318
318
  return (@dir_ent['first_clus_hi'] << 16) + @dir_ent['first_clus_lo']
319
319
  end
320
-
320
+
321
321
  def isDir?
322
322
  return true if @dir_ent['attributes'] & FA_DIRECTORY == FA_DIRECTORY
323
323
  return false
324
324
  end
325
-
325
+
326
326
  def mTime
327
327
  return dosToRubyTime(@dir_ent['mtime_day'], @dir_ent['mtime_hms'])
328
328
  end
329
-
329
+
330
330
  def aTime
331
331
  return dosToRubyTime(@dir_ent['atime_day'], 0)
332
332
  end
333
-
333
+
334
334
  def cTime
335
335
  return dosToRubyTime(@dir_ent['ctime_day'], @dir_ent['ctime_hms'])
336
336
  end
337
-
337
+
338
338
  # ////////////////////////////////////////////////////////////////////////////
339
339
  # // Utility functions.
340
-
340
+
341
341
  def getLongNameFromEntry(ent)
342
342
  pre_name = ""; hashNames = %w(name name2 name3)
343
343
  hashNames.each {|name|
@@ -351,7 +351,7 @@ module Fat32
351
351
  }
352
352
  return pre_name
353
353
  end
354
-
354
+
355
355
  def incShortName
356
356
  @dirty = true
357
357
  num = @dir_ent['name'][7].to_i
@@ -363,7 +363,7 @@ module Fat32
363
363
  @lfn_ents.each {|ent| ent['checksum'] = csum}
364
364
  end
365
365
  end
366
-
366
+
367
367
  def create
368
368
  @dirty = true
369
369
  @dir_ent = Hash.new
@@ -377,7 +377,7 @@ module Fat32
377
377
  # Must fill all members or BinaryStruct.encode fails.
378
378
  self.magic = 0x00; self.length = 0; self.firstCluster = 0 #magic used to be 0x18
379
379
  end
380
-
380
+
381
381
  def mkLongName(name)
382
382
  @lfn_ents = mkLfn(name)
383
383
  @dir_ent['name'] = mkSfn(name)
@@ -387,7 +387,7 @@ module Fat32
387
387
  csum = calcChecksum()
388
388
  @lfn_ents.each {|ent| ent['checksum'] = csum}
389
389
  end
390
-
390
+
391
391
  def mkLfn(name)
392
392
  name = mkLegalLfn(name)
393
393
  lfn_ents = []
@@ -420,11 +420,11 @@ module Fat32
420
420
  lfn_ents[0]['seq_num'] |= AF_LFN_LAST
421
421
  return lfn_ents
422
422
  end
423
-
423
+
424
424
  def mkSfn(name)
425
425
  return mkLegalSfn(name)
426
426
  end
427
-
427
+
428
428
  def isIllegalSfn(name)
429
429
  # Check: name length, extension length, NULL file name,
430
430
  # device names as file names & illegal chars.
@@ -437,14 +437,14 @@ module Fat32
437
437
  return SFN_ILLEGAL_CHARS if name.index(/[;+=\[\]',\"*\\<>\/?\:|]/) != nil
438
438
  return false
439
439
  end
440
-
440
+
441
441
  def checkForDeviceName(fn)
442
442
  %w[aux com1 com2 com3 com4 lpt lpt1 lpt2 lpt3 lpt4 mailslot nul pipe prn].each {|bad|
443
443
  return true if fn == bad
444
444
  }
445
445
  return false
446
446
  end
447
-
447
+
448
448
  def mkLegalSfn(name)
449
449
  name = name.upcase; name = name.delete(" ")
450
450
  name = name + "." if not name.include?(".")
@@ -454,18 +454,18 @@ module Fat32
454
454
  fn = fn[0, 6] + "~1" if fn.length > 8
455
455
  return (fn.ljust(8) + ext.ljust(3)).gsub(/[;+=\[\]',\"*\\<>\/?\:|]/, "_")
456
456
  end
457
-
457
+
458
458
  def isIllegalLfn(name)
459
459
  return LFN_NAME_LENGTH if name.length > LFN_NAME_MAXLEN
460
460
  return LFN_ILLEGAL_CHARS if name.index(/\/\\:><?/) != nil
461
461
  return false
462
462
  end
463
-
463
+
464
464
  def mkLegalLfn(name)
465
465
  name = name[0...LFN_NAME_MAXLEN] if name.length > LFN_NAME_MAXLEN
466
466
  return name.gsub(/\/\\:><?/, "_")
467
467
  end
468
-
468
+
469
469
  def calcChecksum
470
470
  name = @dir_ent['name']; csum = 0
471
471
  0.upto(10) {|i|
@@ -473,7 +473,7 @@ module Fat32
473
473
  }
474
474
  return csum
475
475
  end
476
-
476
+
477
477
  def dosToRubyTime(dos_day, dos_time)
478
478
  # Extract d,m,y,s,m,h & range check.
479
479
  day = dos_day & MSK_DAY; day = 1 if day == 0
@@ -487,7 +487,7 @@ module Fat32
487
487
  # Make a Ruby time.
488
488
  return Time.mktime(year, month, day, hour, min, sec)
489
489
  end
490
-
490
+
491
491
  def rubyToDosTime(tim)
492
492
  # Time
493
493
  sec = tim.sec; sec -= 1 if sec == 60 #correction for possible leap second.
@@ -501,7 +501,7 @@ module Fat32
501
501
  dos_day = (year << 9) + (month << 5) + day
502
502
  return dos_time, dos_day
503
503
  end
504
-
504
+
505
505
  # Dump object.
506
506
  def dump
507
507
  out = "\#<#{self.class}:0x#{'%08x' % self.object_id}>\n"
@@ -535,6 +535,6 @@ module Fat32
535
535
  out += "First clus lo: 0x#{'%04x' % @dir_ent['first_clus_lo']}\n"
536
536
  out += "File size : 0x#{'%08x' % @dir_ent['file_size']}\n"
537
537
  end
538
-
538
+
539
539
  end
540
540
  end # module Fat32
@@ -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.