manageiq-smartstate 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +4 -0
- data/.rspec_ci +4 -0
- data/.travis.yml +15 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +202 -0
- data/README.md +45 -0
- data/Rakefile +23 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/MiqContainerGroup/MiqContainerGroup.rb +31 -0
- data/lib/MiqVm/MiqLocalVm.rb +50 -0
- data/lib/MiqVm/MiqRhevmVm.rb +179 -0
- data/lib/MiqVm/MiqVm.rb +355 -0
- data/lib/MiqVm/miq_azure_vm.rb +96 -0
- data/lib/MiqVm/miq_scvmm_vm.rb +38 -0
- data/lib/MiqVm/test/camcorder_fleece_test.rb +60 -0
- data/lib/MiqVm/test/localVm.rb +45 -0
- data/lib/MiqVm/test/partitionAlignmentCheck.rb +76 -0
- data/lib/MiqVm/test/remoteVm.rb +65 -0
- data/lib/MiqVm/test/rhevmNfsTest.rb +62 -0
- data/lib/MiqVm/test/rhevmNfsTest2.rb +66 -0
- data/lib/MiqVm/test/rhevmTest.rb +70 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackCommon.rb +107 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +67 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +182 -0
- data/lib/Scvmm/miq_hyperv_disk.rb +273 -0
- data/lib/Scvmm/miq_scvmm_parse_powershell.rb +75 -0
- data/lib/Scvmm/miq_scvmm_vm_ssa_info.rb +135 -0
- data/lib/Scvmm/test/miq_hyperv_disk_test.rb +33 -0
- data/lib/Scvmm/test/miq_scvmm_vm_ssa_info_test.rb +41 -0
- data/lib/VmLocalDiskAccess/test/localCfg.rb +97 -0
- data/lib/VolumeManager/LVM/logical_volume.rb +75 -0
- data/lib/VolumeManager/LVM/lv_segment.rb +43 -0
- data/lib/VolumeManager/LVM/lvm2disk.rb +158 -0
- data/lib/VolumeManager/LVM/parser.rb +138 -0
- data/lib/VolumeManager/LVM/physical_volume.rb +19 -0
- data/lib/VolumeManager/LVM/scanner.rb +156 -0
- data/lib/VolumeManager/LVM/thin/btree.rb +83 -0
- data/lib/VolumeManager/LVM/thin/constants.rb +86 -0
- data/lib/VolumeManager/LVM/thin/data_map.rb +44 -0
- data/lib/VolumeManager/LVM/thin/mapping_tree.rb +19 -0
- data/lib/VolumeManager/LVM/thin/space_maps.rb +58 -0
- data/lib/VolumeManager/LVM/thin/superblock.rb +136 -0
- data/lib/VolumeManager/LVM/thin.rb +6 -0
- data/lib/VolumeManager/LVM/volume_group.rb +97 -0
- data/lib/VolumeManager/LVM.rb +8 -0
- data/lib/VolumeManager/MiqLdm.rb +546 -0
- data/lib/VolumeManager/MiqLvm.rb +17 -0
- data/lib/VolumeManager/MiqNativeVolumeManager.rb +150 -0
- data/lib/VolumeManager/MiqVolumeManager.rb +277 -0
- data/lib/VolumeManager/VolMgrPlatformSupport.rb +18 -0
- data/lib/VolumeManager/VolMgrPlatformSupportLinux.rb +77 -0
- data/lib/VolumeManager/VolMgrPlatformSupportWin.rb +17 -0
- data/lib/VolumeManager/test/blockDevTest.rb +40 -0
- data/lib/VolumeManager/test/ldm.rb +97 -0
- data/lib/blackbox/VmBlackBox.rb +103 -0
- data/lib/blackbox/xmlStorage.rb +180 -0
- data/lib/db/MiqBdb/MiqBdb.rb +309 -0
- data/lib/db/MiqBdb/MiqBdbBtree.rb +219 -0
- data/lib/db/MiqBdb/MiqBdbHash.rb +199 -0
- data/lib/db/MiqBdb/MiqBdbPage.rb +159 -0
- data/lib/db/MiqBdb/MiqBdbUtil.rb +18 -0
- data/lib/db/MiqSqlite/MiqSqlite3.rb +330 -0
- data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +167 -0
- data/lib/db/MiqSqlite/MiqSqlite3Page.rb +151 -0
- data/lib/db/MiqSqlite/MiqSqlite3Table.rb +124 -0
- data/lib/db/MiqSqlite/MiqSqlite3Util.rb +32 -0
- data/lib/disk/DiskProbe.rb +68 -0
- data/lib/disk/MiqDisk.rb +317 -0
- data/lib/disk/camcorder_test.rb +90 -0
- data/lib/disk/dos_mbr.img +0 -0
- data/lib/disk/modules/AzureBlobDisk.rb +101 -0
- data/lib/disk/modules/LocalDevMod.rb +47 -0
- data/lib/disk/modules/LocalDevProbe.rb +6 -0
- data/lib/disk/modules/MSCommon.rb +352 -0
- data/lib/disk/modules/MSVSDiffDisk.rb +91 -0
- data/lib/disk/modules/MSVSDiskProbe.rb +61 -0
- data/lib/disk/modules/MSVSDynamicDisk.rb +42 -0
- data/lib/disk/modules/MSVSFixedDisk.rb +45 -0
- data/lib/disk/modules/MiqLargeFile.rb +63 -0
- data/lib/disk/modules/MiqLargeFileWin32.rb +107 -0
- data/lib/disk/modules/QcowDisk.rb +692 -0
- data/lib/disk/modules/QcowDiskProbe.rb +34 -0
- data/lib/disk/modules/RawBlockIO.rb +116 -0
- data/lib/disk/modules/RawDisk.rb +45 -0
- data/lib/disk/modules/RawDiskProbe.rb +7 -0
- data/lib/disk/modules/RhevmDescriptor.rb +167 -0
- data/lib/disk/modules/RhevmDiskProbe.rb +52 -0
- data/lib/disk/modules/VMWareCowdDisk.rb +207 -0
- data/lib/disk/modules/VMWareDescriptor.rb +214 -0
- data/lib/disk/modules/VMWareDiskProbe.rb +74 -0
- data/lib/disk/modules/VMWareSparseDisk.rb +189 -0
- data/lib/disk/modules/VhdxDisk.rb +625 -0
- data/lib/disk/modules/VhdxDiskProbe.rb +46 -0
- data/lib/disk/modules/VixDiskMod.rb +54 -0
- data/lib/disk/modules/VixDiskProbe.rb +6 -0
- data/lib/disk/modules/miq_disk_cache.rb +135 -0
- data/lib/disk/modules/miq_dummy_disk.rb +41 -0
- data/lib/disk/modules/vhdx_bat_entry.rb +10 -0
- data/lib/disk/test.rb +66 -0
- data/lib/fs/MetakitFS/MetakitFS.rb +530 -0
- data/lib/fs/MetakitFS/test/Makefile +14 -0
- data/lib/fs/MetakitFS/test/MkCollectFiles.rb +165 -0
- data/lib/fs/MetakitFS/test/MkSelectFiles.rb +30 -0
- data/lib/fs/MetakitFS/test/collect_files.yaml +70 -0
- data/lib/fs/MetakitFS/test/init.rb +3 -0
- data/lib/fs/MetakitFS/test/mk2vmdk.rb +64 -0
- data/lib/fs/MetakitFS/test/mk4test.c +92 -0
- data/lib/fs/MetakitFS/test/mkFsTest.rb +113 -0
- data/lib/fs/MetakitFS/test/proto.rb +97 -0
- data/lib/fs/MiqFS/FsProbe.rb +39 -0
- data/lib/fs/MiqFS/MiqFS.rb +515 -0
- data/lib/fs/MiqFS/modules/AUFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/Ext3.rb +305 -0
- data/lib/fs/MiqFS/modules/Ext3Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Ext4.rb +304 -0
- data/lib/fs/MiqFS/modules/Ext4Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Fat32.rb +318 -0
- data/lib/fs/MiqFS/modules/Fat32Probe.rb +30 -0
- data/lib/fs/MiqFS/modules/HFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/Iso9660.rb +293 -0
- data/lib/fs/MiqFS/modules/Iso9660Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/LocalFS.rb +105 -0
- data/lib/fs/MiqFS/modules/NTFS.rb +287 -0
- data/lib/fs/MiqFS/modules/NTFSProbe.rb +21 -0
- data/lib/fs/MiqFS/modules/NativeFS.rb +155 -0
- data/lib/fs/MiqFS/modules/ReFSProbe.rb +17 -0
- data/lib/fs/MiqFS/modules/RealFS.rb +79 -0
- data/lib/fs/MiqFS/modules/RealFSProbe.rb +6 -0
- data/lib/fs/MiqFS/modules/Reiser4Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/ReiserFS.rb +315 -0
- data/lib/fs/MiqFS/modules/ReiserFSProbe.rb +42 -0
- data/lib/fs/MiqFS/modules/UnionFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/WebDAV.rb +127 -0
- data/lib/fs/MiqFS/modules/WebDAVFile.rb +68 -0
- data/lib/fs/MiqFS/modules/XFS.rb +300 -0
- data/lib/fs/MiqFS/modules/XFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/ZFSProbe.rb +18 -0
- data/lib/fs/MiqFS/test.rb +59 -0
- data/lib/fs/MiqFsUtil.rb +383 -0
- data/lib/fs/MiqMountManager.rb +209 -0
- data/lib/fs/MiqNativeMountManager.rb +101 -0
- data/lib/fs/MountManagerProbe.rb +29 -0
- data/lib/fs/ReiserFS/block.rb +209 -0
- data/lib/fs/ReiserFS/directory.rb +136 -0
- data/lib/fs/ReiserFS/directory_entry.rb +140 -0
- data/lib/fs/ReiserFS/file_data.rb +111 -0
- data/lib/fs/ReiserFS/superblock.rb +140 -0
- data/lib/fs/ReiserFS/utils.rb +95 -0
- data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +192 -0
- data/lib/fs/ext3/alloc_bitmap.rb +38 -0
- data/lib/fs/ext3/block_pointers_path.rb +130 -0
- data/lib/fs/ext3/directory.rb +51 -0
- data/lib/fs/ext3/directory_entry.rb +67 -0
- data/lib/fs/ext3/ex_attrib_header.rb +14 -0
- data/lib/fs/ext3/ex_attrib_name.rb +23 -0
- data/lib/fs/ext3/file_data.rb +130 -0
- data/lib/fs/ext3/group_descriptor_entry.rb +65 -0
- data/lib/fs/ext3/group_descriptor_table.rb +54 -0
- data/lib/fs/ext3/hash_tree_entry.rb +18 -0
- data/lib/fs/ext3/hash_tree_header.rb +15 -0
- data/lib/fs/ext3/inode.rb +228 -0
- data/lib/fs/ext3/posix_acl_entry.rb +29 -0
- data/lib/fs/ext3/posix_acl_header.rb +11 -0
- data/lib/fs/ext3/superblock.rb +406 -0
- data/lib/fs/ext3/test/tc_Ext3BlockPointersPath.rb +74 -0
- data/lib/fs/ext4/alloc_bitmap.rb +38 -0
- data/lib/fs/ext4/directory.rb +87 -0
- data/lib/fs/ext4/directory_entry.rb +77 -0
- data/lib/fs/ext4/ex_attrib_header.rb +14 -0
- data/lib/fs/ext4/ex_attrib_name.rb +23 -0
- data/lib/fs/ext4/extent.rb +35 -0
- data/lib/fs/ext4/extent_header.rb +40 -0
- data/lib/fs/ext4/extent_index.rb +33 -0
- data/lib/fs/ext4/group_descriptor_entry.rb +69 -0
- data/lib/fs/ext4/group_descriptor_table.rb +54 -0
- data/lib/fs/ext4/hash_tree_entry.rb +58 -0
- data/lib/fs/ext4/hash_tree_header.rb +35 -0
- data/lib/fs/ext4/inode.rb +465 -0
- data/lib/fs/ext4/posix_acl_entry.rb +29 -0
- data/lib/fs/ext4/posix_acl_header.rb +11 -0
- data/lib/fs/ext4/superblock.rb +412 -0
- data/lib/fs/fat32/boot_sect.rb +379 -0
- data/lib/fs/fat32/directory.rb +222 -0
- data/lib/fs/fat32/directory_entry.rb +540 -0
- data/lib/fs/fat32/file_data.rb +128 -0
- data/lib/fs/iso9660/boot_sector.rb +170 -0
- data/lib/fs/iso9660/directory.rb +90 -0
- data/lib/fs/iso9660/directory_entry.rb +147 -0
- data/lib/fs/iso9660/file_data.rb +78 -0
- data/lib/fs/iso9660/rock_ridge.rb +329 -0
- data/lib/fs/iso9660/util.rb +57 -0
- data/lib/fs/modules/LinuxMount.rb +300 -0
- data/lib/fs/modules/LinuxMountProbe.rb +29 -0
- data/lib/fs/modules/WinMount.rb +97 -0
- data/lib/fs/modules/WinMountProbe.rb +24 -0
- data/lib/fs/ntfs/attrib_attribute_list.rb +131 -0
- data/lib/fs/ntfs/attrib_bitmap.rb +26 -0
- data/lib/fs/ntfs/attrib_data.rb +74 -0
- data/lib/fs/ntfs/attrib_file_name.rb +110 -0
- data/lib/fs/ntfs/attrib_header.rb +194 -0
- data/lib/fs/ntfs/attrib_index_allocation.rb +19 -0
- data/lib/fs/ntfs/attrib_index_root.rb +247 -0
- data/lib/fs/ntfs/attrib_object_id.rb +40 -0
- data/lib/fs/ntfs/attrib_standard_information.rb +107 -0
- data/lib/fs/ntfs/attrib_type.rb +49 -0
- data/lib/fs/ntfs/attrib_volume_information.rb +53 -0
- data/lib/fs/ntfs/attrib_volume_name.rb +31 -0
- data/lib/fs/ntfs/boot_sect.rb +253 -0
- data/lib/fs/ntfs/data_run.rb +358 -0
- data/lib/fs/ntfs/directory_index_node.rb +114 -0
- data/lib/fs/ntfs/index_node_header.rb +69 -0
- data/lib/fs/ntfs/index_record_header.rb +85 -0
- data/lib/fs/ntfs/mft_entry.rb +288 -0
- data/lib/fs/ntfs/utils.rb +43 -0
- data/lib/fs/test/camcorder_fs_test.rb +108 -0
- data/lib/fs/test/collect_files_direct.yaml +22 -0
- data/lib/fs/test/collect_files_in.yaml +24 -0
- data/lib/fs/test/collect_files_in_nc.yaml +22 -0
- data/lib/fs/test/collect_files_out.yaml +6 -0
- data/lib/fs/test/collect_files_rm.yaml +6 -0
- data/lib/fs/test/copyTest.rb +126 -0
- data/lib/fs/test/fsTest.rb +87 -0
- data/lib/fs/test/updateTest.rb +184 -0
- data/lib/fs/xfs/allocation_group.rb +160 -0
- data/lib/fs/xfs/bmap_btree_block.rb +125 -0
- data/lib/fs/xfs/bmap_btree_record.rb +80 -0
- data/lib/fs/xfs/bmap_btree_root_node.rb +72 -0
- data/lib/fs/xfs/directory.rb +133 -0
- data/lib/fs/xfs/directory2_data_header.rb +27 -0
- data/lib/fs/xfs/directory3_data_header.rb +34 -0
- data/lib/fs/xfs/directory_block_tail.rb +22 -0
- data/lib/fs/xfs/directory_data_header.rb +46 -0
- data/lib/fs/xfs/directory_entry.rb +106 -0
- data/lib/fs/xfs/inode.rb +532 -0
- data/lib/fs/xfs/inode_map.rb +100 -0
- data/lib/fs/xfs/short_form_directory_entry.rb +91 -0
- data/lib/fs/xfs/short_form_header.rb +44 -0
- data/lib/fs/xfs/superblock.rb +556 -0
- data/lib/lib/tasks/azure.rake +52 -0
- data/lib/manageiq/smartstate/version.rb +5 -0
- data/lib/manageiq/smartstate.rb +7 -0
- data/lib/manageiq-smartstate.rb +1 -0
- data/lib/metadata/MIQExtract/MIQExtract.rb +297 -0
- data/lib/metadata/MIQExtract/test/extractTest.rb +41 -0
- data/lib/metadata/MIQExtract/test/full_extract_test.rb +68 -0
- data/lib/metadata/ScanProfile/HostScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfiles.rb +41 -0
- data/lib/metadata/ScanProfile/ScanItemBase.rb +63 -0
- data/lib/metadata/ScanProfile/ScanProfileBase.rb +51 -0
- data/lib/metadata/ScanProfile/ScanProfilesBase.rb +60 -0
- data/lib/metadata/ScanProfile/VmScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfiles.rb +38 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemFile.rb +51 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemNteventlog.rb +84 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemFile.rb +39 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb +34 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb +64 -0
- data/lib/metadata/VMMount/VMMount.rb +81 -0
- data/lib/metadata/VMMount/VMPlatformMount.rb +18 -0
- data/lib/metadata/VMMount/VMPlatformMountLinux.rb +75 -0
- data/lib/metadata/VMMount/VMPlatformMountWin.rb +13 -0
- data/lib/metadata/VmConfig/GetNativeCfg.rb +45 -0
- data/lib/metadata/VmConfig/VmConfig.rb +947 -0
- data/lib/metadata/VmConfig/cfgConfig.rb +45 -0
- data/lib/metadata/VmConfig/ovfConfig.rb +99 -0
- data/lib/metadata/VmConfig/test/GetVMwareCfgTest.rb +40 -0
- data/lib/metadata/VmConfig/vmcConfig.rb +116 -0
- data/lib/metadata/VmConfig/vmtxConfig.rb +4 -0
- data/lib/metadata/VmConfig/vmxConfig.rb +162 -0
- data/lib/metadata/VmConfig/xmlConfig.rb +79 -0
- data/lib/metadata/VmConfig/xmlMsHyperVConfig.rb +41 -0
- data/lib/metadata/linux/InitProcHash.rb +632 -0
- data/lib/metadata/linux/LinuxInitProcs.rb +142 -0
- data/lib/metadata/linux/LinuxOSInfo.rb +237 -0
- data/lib/metadata/linux/LinuxPackages.rb +209 -0
- data/lib/metadata/linux/LinuxSystemd.rb +130 -0
- data/lib/metadata/linux/LinuxUsers.rb +289 -0
- data/lib/metadata/linux/LinuxUtils.rb +197 -0
- data/lib/metadata/linux/MiqConaryPackages.rb +41 -0
- data/lib/metadata/linux/MiqRpmPackages.rb +160 -0
- data/lib/metadata/linux/test/Name +0 -0
- data/lib/metadata/linux/test/Packages +0 -0
- data/lib/metadata/linux/test/rpoTest.rb +5 -0
- data/lib/metadata/linux/test/tc_LinuxUtils.rb +4157 -0
- data/lib/metadata/util/event_log_filter.rb +61 -0
- data/lib/metadata/util/md5deep.rb +280 -0
- data/lib/metadata/util/win32/Win32Accounts.rb +764 -0
- data/lib/metadata/util/win32/Win32EventLog.rb +743 -0
- data/lib/metadata/util/win32/Win32Services.rb +86 -0
- data/lib/metadata/util/win32/Win32Software.rb +326 -0
- data/lib/metadata/util/win32/Win32System.rb +333 -0
- data/lib/metadata/util/win32/boot_info_win.rb +59 -0
- data/lib/metadata/util/win32/fleece_hives.rb +220 -0
- data/lib/metadata/util/win32/ms-registry.rb +650 -0
- data/lib/metadata/util/win32/peheader.rb +868 -0
- data/lib/metadata/util/win32/remote-registry.rb +142 -0
- data/lib/metadata/util/win32/system_path_win.rb +103 -0
- data/lib/metadata/util/win32/versioninfo.rb +17 -0
- data/manageiq-smartstate.gemspec +35 -0
- metadata +486 -0
@@ -0,0 +1,546 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
3
|
+
# Windows dynamic disks
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'ostruct'
|
7
|
+
require 'binary_struct'
|
8
|
+
require 'util/miq-uuid'
|
9
|
+
|
10
|
+
class BinaryStruct
|
11
|
+
def self.stepDecode(data, format)
|
12
|
+
type = format[0, 1]
|
13
|
+
raise "unrecognized format: #{type}" if SIZES.key?(type) == false
|
14
|
+
raise "unsupported format: #{type}" if SIZES[type].nil?
|
15
|
+
|
16
|
+
count = (format.size > 1) ? format[1, format.size - 1].to_i : 1
|
17
|
+
raise "unsupported count: #{count}" if count.kind_of?(Numeric) == false
|
18
|
+
|
19
|
+
size = (count * SIZES[type])
|
20
|
+
|
21
|
+
data.slice!(0, size).unpack(format)[0]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module LdmScanner
|
26
|
+
LDM_SECTOR_SIZE = 512
|
27
|
+
LDM_PARTITION_TYPE = 66
|
28
|
+
PRIVHEAD_OFFSET = 6 * LDM_SECTOR_SIZE
|
29
|
+
|
30
|
+
#
|
31
|
+
# On disk, all numbers are in big-endian format.
|
32
|
+
#
|
33
|
+
|
34
|
+
PRIVHEAD = [
|
35
|
+
'a8', 'signature', # 8
|
36
|
+
'N', 'unknown_1', # 4
|
37
|
+
'n', 'ver_major', # 2
|
38
|
+
'n', 'ver_minor', # 2
|
39
|
+
'Q', 'timestamp', # 8
|
40
|
+
'Q', 'unknown_2', # 8 number ?
|
41
|
+
'Q', 'unknown_3', # 8 size ?
|
42
|
+
'Q', 'unknown_4', # 8 size ?
|
43
|
+
'a64', 'disk_id', # 64 zero padded
|
44
|
+
'a64', 'host_id', # 64 zero padded
|
45
|
+
'a64', 'diskgroup_id', # 64 zero padded
|
46
|
+
'a32', 'diskgroup_name', # 32 zero padded
|
47
|
+
'a2', 'unknown_5', # 2
|
48
|
+
'a9', 'unknown_6', # 9 zeros
|
49
|
+
'N', 'logical_disk_start_H', # 8
|
50
|
+
'N', 'logical_disk_start_L', # "
|
51
|
+
'N', 'logical_disk_size_H', # 8
|
52
|
+
'N', 'logical_disk_size_L', # "
|
53
|
+
'N', 'db_start_H', # 8
|
54
|
+
'N', 'db_start_L', # "
|
55
|
+
'N', 'db_size_H', # 8
|
56
|
+
'N', 'db_size_L', # "
|
57
|
+
'N', 'num_tocs_H', # 8
|
58
|
+
'N', 'num_tocs_L', # "
|
59
|
+
'N', 'toc_size_H', # 8
|
60
|
+
'N', 'toc_size_L', # "
|
61
|
+
'N', 'num_configs', # 4
|
62
|
+
'N', 'num_logs', # 4
|
63
|
+
'N', 'config_size_H', # 8
|
64
|
+
'N', 'config_size_L', # "
|
65
|
+
'N', 'log_size_H', # 8
|
66
|
+
'N', 'log_size_L', # "
|
67
|
+
'N', 'disk_signature', # 4
|
68
|
+
'C16', 'disk_set_guid', # 16
|
69
|
+
'C16', 'disk_set_guid2', # 16
|
70
|
+
"C#{512 - 391}", 'padding' # Pad to 512 bytes (sector size)
|
71
|
+
]
|
72
|
+
|
73
|
+
TBLOCK_BLOCK = [1, 2, 2045, 2046]
|
74
|
+
TOCBLOCK = [
|
75
|
+
'a8', 'signature',
|
76
|
+
'N', 'sequence1',
|
77
|
+
'a4', 'unknown1',
|
78
|
+
'N', 'sequence2',
|
79
|
+
'a16', 'unknown2',
|
80
|
+
'a10', 'bitmap1_name',
|
81
|
+
'N', 'bitmap1_start_H',
|
82
|
+
'N', 'bitmap1_start_L',
|
83
|
+
'N', 'bitmap1_size_H',
|
84
|
+
'N', 'bitmap1_size_L',
|
85
|
+
'N', 'bitmap1_flags_H',
|
86
|
+
'N', 'bitmap1_flags_L',
|
87
|
+
'a10', 'bitmap2_name',
|
88
|
+
'N', 'bitmap2_start_H',
|
89
|
+
'N', 'bitmap2_start_L',
|
90
|
+
'N', 'bitmap2_size_H',
|
91
|
+
'N', 'bitmap2_size_L',
|
92
|
+
'N', 'bitmap2_flags_H',
|
93
|
+
'N', 'bitmap2_flags_L',
|
94
|
+
"C#{512 - 104}", 'padding'
|
95
|
+
]
|
96
|
+
|
97
|
+
VMDB = [
|
98
|
+
'a4', 'signature',
|
99
|
+
'N', 'sequence',
|
100
|
+
'N', 'vblk_size',
|
101
|
+
'N', 'vblk_offset',
|
102
|
+
'n', 'unknown1',
|
103
|
+
'n', 'ver_major',
|
104
|
+
'n', 'ver_minor',
|
105
|
+
'a31', 'dg_name',
|
106
|
+
'a64', 'dg_guid',
|
107
|
+
'N', 'committed_seq_H',
|
108
|
+
'N', 'committed_seq_L',
|
109
|
+
'N', 'pending_seq_H',
|
110
|
+
'N', 'pending_seq_L',
|
111
|
+
'a56', 'unknown2',
|
112
|
+
'N', 'timestamp',
|
113
|
+
"C#{512 - 193}", 'padding'
|
114
|
+
]
|
115
|
+
|
116
|
+
VBLK = [
|
117
|
+
'a4', 'signature',
|
118
|
+
'N', 'vmdb_seq',
|
119
|
+
'N', 'grpnum',
|
120
|
+
'n', 'record',
|
121
|
+
'n', 'nrecords',
|
122
|
+
'n', 'update_status',
|
123
|
+
'C', 'flags',
|
124
|
+
'C', 'rec_type',
|
125
|
+
'N', 'data_length',
|
126
|
+
"a#{128 - 24}", 'padding'
|
127
|
+
]
|
128
|
+
|
129
|
+
#
|
130
|
+
# VBLOCK types.
|
131
|
+
#
|
132
|
+
VBT_NONE = 0x00
|
133
|
+
VBT_COMPONENT = 0x32
|
134
|
+
VBT_PARTITION = 0x33
|
135
|
+
VBT_DISKV1 = 0x34
|
136
|
+
VBT_DISKGROUPV1 = 0x35
|
137
|
+
VBT_DISKV2 = 0x44
|
138
|
+
VBT_DISKGROUPV2 = 0x45
|
139
|
+
VBT_VOLUME = 0x51
|
140
|
+
|
141
|
+
VBLK_TYPES = {
|
142
|
+
VBT_NONE => "NONE",
|
143
|
+
VBT_COMPONENT => "Component",
|
144
|
+
VBT_PARTITION => "Partition",
|
145
|
+
VBT_DISKV1 => "Disk v1",
|
146
|
+
VBT_DISKGROUPV1 => "Disk Group v1",
|
147
|
+
VBT_DISKV2 => "Disk v2",
|
148
|
+
VBT_DISKGROUPV2 => "Disk Group v2",
|
149
|
+
VBT_VOLUME => "Volume"
|
150
|
+
}
|
151
|
+
|
152
|
+
def self.scan(d)
|
153
|
+
return nil if d.partType != LDM_PARTITION_TYPE
|
154
|
+
|
155
|
+
d.seek(PRIVHEAD_OFFSET)
|
156
|
+
ph = readStruct(d, PRIVHEAD)
|
157
|
+
# LdmScanner.dumpPrivhead(ph)
|
158
|
+
return nil if ph.signature != "PRIVHEAD"
|
159
|
+
|
160
|
+
ph.disk_id.delete!("\000")
|
161
|
+
ph.diskgroup_id.delete!("\000")
|
162
|
+
ph.diskgroup_name.delete!("\000")
|
163
|
+
ph.host_id.delete!("\000")
|
164
|
+
|
165
|
+
ph.lvm_type = "LDM"
|
166
|
+
ph.pv_uuid = ph.disk_id
|
167
|
+
ph.diskObj = d
|
168
|
+
|
169
|
+
tb = nil
|
170
|
+
TBLOCK_BLOCK.each do |tbo|
|
171
|
+
tblock_offset = (ph.db_start + tbo) * LDM_SECTOR_SIZE
|
172
|
+
d.seek(tblock_offset)
|
173
|
+
tb = readStruct(d, TOCBLOCK)
|
174
|
+
# LdmScanner.dumpTocblock(tb)
|
175
|
+
break if tb.signature == "TOCBLOCK"
|
176
|
+
end
|
177
|
+
|
178
|
+
unless tb
|
179
|
+
$log.warn "LdmScanner: could not find valid TOCBLOCK on LDM disk" if $log
|
180
|
+
return nil
|
181
|
+
end
|
182
|
+
|
183
|
+
vmdb_offset = (ph.db_start + tb.bitmap1_start) * LDM_SECTOR_SIZE
|
184
|
+
d.seek(vmdb_offset)
|
185
|
+
vmdb = readStruct(d, VMDB)
|
186
|
+
|
187
|
+
ph.vblkHash = {}
|
188
|
+
ph.volumes = []
|
189
|
+
ph.diskVb = nil
|
190
|
+
(0...vmdb.sequence).each { |_i| readVBLK(d, ph) }
|
191
|
+
|
192
|
+
ph.vblkHash.each_value do |v|
|
193
|
+
ph.vblkHash[v.parent_id].children << v if v.parent_id
|
194
|
+
v.disk = ph.vblkHash[v.disk_id] if v.disk_id
|
195
|
+
end
|
196
|
+
(ph)
|
197
|
+
end
|
198
|
+
|
199
|
+
def self.readStruct(d, struct)
|
200
|
+
h = BinaryStruct.decode(d.read(BinaryStruct.sizeof(struct)), struct)
|
201
|
+
h.keys.delete_if { |k| !(/.*_H/ =~ k) }.each do |k|
|
202
|
+
(nk = k.dup)[/_H$/] = ""
|
203
|
+
lk = nk + "_L"
|
204
|
+
h[nk] = (h[k] << 32) | h[lk]
|
205
|
+
end
|
206
|
+
OpenStruct.new(h)
|
207
|
+
end # def self.readStruct
|
208
|
+
|
209
|
+
def self.getChunk(data)
|
210
|
+
len = data.slice!(0, 1).unpack("C")[0]
|
211
|
+
data.slice!(0, len)
|
212
|
+
end
|
213
|
+
|
214
|
+
def self.getNum(data)
|
215
|
+
n = 0
|
216
|
+
getChunk(data).each_byte { |b| n = (n << 8) | b }
|
217
|
+
(n)
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.getNBO8(data)
|
221
|
+
h, l = data.slice!(0, 8).unpack("N2")
|
222
|
+
((h << 32) | l)
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.readVBLK(disk, ph)
|
226
|
+
vblk = LdmScanner.readStruct(disk, LdmScanner::VBLK)
|
227
|
+
return if vblk.data_length == 0
|
228
|
+
buf = vblk.padding
|
229
|
+
|
230
|
+
vblk.vobject_id = getNum(buf)
|
231
|
+
vblk.name = getChunk(buf)
|
232
|
+
|
233
|
+
case vblk.rec_type
|
234
|
+
when VBT_NONE # NONE
|
235
|
+
when VBT_COMPONENT # Component
|
236
|
+
vblk.children = []
|
237
|
+
vblk.volume_state = getChunk(buf)
|
238
|
+
vblk.component_type = BinaryStruct.stepDecode(buf, "C")
|
239
|
+
BinaryStruct.stepDecode(buf, "C4")
|
240
|
+
vblk.num_children = getNum(buf)
|
241
|
+
BinaryStruct.stepDecode(buf, "C16")
|
242
|
+
vblk.parent_id = getNum(buf)
|
243
|
+
BinaryStruct.stepDecode(buf, "C")
|
244
|
+
if vblk.flags != 0
|
245
|
+
vblk.stripe_size = getNum(buf)
|
246
|
+
vblk.num_col = getNum(buf)
|
247
|
+
end
|
248
|
+
|
249
|
+
when VBT_PARTITION # Partition
|
250
|
+
BinaryStruct.stepDecode(buf, "C12")
|
251
|
+
vblk.start = getNBO8(buf)
|
252
|
+
vblk.volume_offset = getNBO8(buf)
|
253
|
+
vblk.size = getNum(buf)
|
254
|
+
vblk.parent_id = getNum(buf)
|
255
|
+
vblk.disk_id = getNum(buf)
|
256
|
+
vblk.comp_part_idx = getNum(buf) if vblk.flags == 0x08
|
257
|
+
|
258
|
+
when VBT_DISKV1 # Disk v1
|
259
|
+
vblk.disk_guid = getChunk(buf)
|
260
|
+
vblk.alt_name = getChunk(buf)
|
261
|
+
ph.diskVb = vblk if ph.disk_id == vblk.disk_guid
|
262
|
+
|
263
|
+
when VBT_DISKGROUPV1 # Disk Group v1
|
264
|
+
vblk.dg_guid = getChunk(buf)
|
265
|
+
|
266
|
+
when VBT_DISKV2 # Disk v2
|
267
|
+
vblk.disk_guid1 = UUIDTools::UUID.parse_raw(BinaryStruct.stepDecode(buf, "a16")).to_s
|
268
|
+
vblk.disk_guid2 = UUIDTools::UUID.parse_raw(BinaryStruct.stepDecode(buf, "a16")).to_s
|
269
|
+
ph.diskVb = vblk if ph.disk_id == vblk.disk_guid1
|
270
|
+
|
271
|
+
when VBT_DISKGROUPV2 # Disk Group v2
|
272
|
+
vblk.dg_guid = UUIDTools::UUID.parse_raw(BinaryStruct.stepDecode(buf, "a16")).to_s
|
273
|
+
vblk.ds_guid = UUIDTools::UUID.parse_raw(BinaryStruct.stepDecode(buf, "a16")).to_s
|
274
|
+
|
275
|
+
when VBT_VOLUME # Volume
|
276
|
+
vblk.children = []
|
277
|
+
vblk.volume_type = getChunk(buf)
|
278
|
+
BinaryStruct.stepDecode(buf, "C")
|
279
|
+
vblk.volume_state = BinaryStruct.stepDecode(buf, "a14").delete("\000")
|
280
|
+
vblk.volume_typeN = BinaryStruct.stepDecode(buf, "C")
|
281
|
+
BinaryStruct.stepDecode(buf, "C")
|
282
|
+
vblk.volume_number = BinaryStruct.stepDecode(buf, "C")
|
283
|
+
BinaryStruct.stepDecode(buf, "C3")
|
284
|
+
vblk.vol_flags = BinaryStruct.stepDecode(buf, "C")
|
285
|
+
vblk.num_children = getNum(buf)
|
286
|
+
BinaryStruct.stepDecode(buf, "C16")
|
287
|
+
vblk.size = getNum(buf)
|
288
|
+
BinaryStruct.stepDecode(buf, "C4")
|
289
|
+
vblk.partition_type = BinaryStruct.stepDecode(buf, "C")
|
290
|
+
vblk.volume_id = UUIDTools::UUID.parse_raw(BinaryStruct.stepDecode(buf, "a16")).to_s
|
291
|
+
|
292
|
+
vblk.id1 = getChunk(buf) if (vblk.flags & 0x08) != 0x0
|
293
|
+
vblk.id2 = getChunk(buf) if (vblk.flags & 0x20) != 0x0
|
294
|
+
vblk.csize = getNum(buf) if (vblk.flags & 0x80) != 0x0
|
295
|
+
vblk.drive_hint = getChunk(buf) if (vblk.flags & 0x02) != 0x0
|
296
|
+
|
297
|
+
if vblk.volume_state == "ACTIVE"
|
298
|
+
if vblk.volume_type == "gen"
|
299
|
+
ph.volumes << vblk
|
300
|
+
else
|
301
|
+
$log.warn "LdmScanner: unsupported volume type - #{vblk.volume_type}" if $log
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
vblk.delete_field("padding") if vblk.padding
|
307
|
+
ph.vblkHash[vblk.vobject_id] = vblk
|
308
|
+
(vblk)
|
309
|
+
end
|
310
|
+
|
311
|
+
def self.dumpPrivhead(ph)
|
312
|
+
puts
|
313
|
+
puts "PRIVHEAD:"
|
314
|
+
puts "\tsignature: #{ph.signature}"
|
315
|
+
puts "\tver_major: #{ph.ver_major}"
|
316
|
+
puts "\tver_minor: #{ph.ver_minor}"
|
317
|
+
puts "\tdisk_id: #{ph.disk_id}"
|
318
|
+
puts "\thost_id: #{ph.host_id}"
|
319
|
+
puts "\tdiskgroup_id: #{ph.diskgroup_id}"
|
320
|
+
puts "\tdiskgroup_name: #{ph.diskgroup_name}"
|
321
|
+
puts "\tlogical_disk_start: #{ph.logical_disk_start}"
|
322
|
+
puts "\tlogical_disk_size: #{ph.logical_disk_size}"
|
323
|
+
puts "\tdb_start: #{ph.db_start}"
|
324
|
+
puts "\tdb_size: #{ph.db_size}"
|
325
|
+
puts "\tnum_tocs: #{ph.num_tocs}"
|
326
|
+
puts "\ttoc_size: #{ph.toc_size}"
|
327
|
+
puts "\tnum_configs: #{ph.num_configs}"
|
328
|
+
puts "\tconfig_size: #{ph.config_size}"
|
329
|
+
puts "\tnum_logs: #{ph.num_logs}"
|
330
|
+
puts "\tlog_size: #{ph.log_size}"
|
331
|
+
puts "\tdisk_signature: #{ph.disk_signature}"
|
332
|
+
puts "\tdisk_set_guid: #{ph.disk_set_guid}"
|
333
|
+
puts "\tdisk_set_guid2: #{ph.disk_set_guid2}"
|
334
|
+
end
|
335
|
+
|
336
|
+
def self.dumpTocblock(tb)
|
337
|
+
puts
|
338
|
+
puts "TOCBLOCK:"
|
339
|
+
puts "\tsignature: #{tb.signature}"
|
340
|
+
puts "\tsequence1: #{tb.sequence1}"
|
341
|
+
puts "\tsequence2: #{tb.sequence2}"
|
342
|
+
puts "\tbitmap1_name: #{tb.bitmap1_name}"
|
343
|
+
puts "\tbitmap1_start: #{tb.bitmap1_start}"
|
344
|
+
puts "\tbitmap2_name: #{tb.bitmap2_name}"
|
345
|
+
puts "\tbitmap2_start: #{tb.bitmap2_start}"
|
346
|
+
end
|
347
|
+
|
348
|
+
def self.dumpVmdb(vmdb)
|
349
|
+
puts
|
350
|
+
puts "VMDB:"
|
351
|
+
puts "\tsignature: #{vmdb.signature}"
|
352
|
+
puts "\tsequence: #{vmdb.sequence}"
|
353
|
+
puts "\tvblk_size: #{vmdb.vblk_size}"
|
354
|
+
puts "\tvblk_offset: #{vmdb.vblk_offset}"
|
355
|
+
puts "\tver_major: #{vmdb.ver_major}"
|
356
|
+
puts "\tver_minor: #{vmdb.ver_minor}"
|
357
|
+
puts "\tdg_name: #{vmdb.dg_name}"
|
358
|
+
puts "\tdg_guid: #{vmdb.dg_guid}"
|
359
|
+
puts "\tcommitted_seq: #{vmdb.committed_seq}"
|
360
|
+
puts "\tpending_seq: #{vmdb.pending_seq}"
|
361
|
+
end
|
362
|
+
|
363
|
+
def self.dumpVblk_old(vb)
|
364
|
+
return if vb.data_length == 0
|
365
|
+
puts
|
366
|
+
puts "VBLK:"
|
367
|
+
puts "\tsignature: #{vb.signature}"
|
368
|
+
puts "\tvmdb_seq: #{vb.vmdb_seq}"
|
369
|
+
puts "\tgrpnum: #{vb.grpnum}"
|
370
|
+
puts "\trecord: #{vb.record}"
|
371
|
+
puts "\tnrecords: #{vb.nrecords}"
|
372
|
+
puts "\tupdate_status: #{vb.update_status}"
|
373
|
+
printf("\trec_type: 0x%x\t%s\n", vb.rec_type & 0xff, VBLK_TYPES[vb.rec_type & 0xff])
|
374
|
+
puts "\tdata_length: #{vb.data_length}"
|
375
|
+
puts "\tpadding.length: #{vb.padding.length}"
|
376
|
+
end
|
377
|
+
|
378
|
+
def self.dumpVblk(vb, indent = "")
|
379
|
+
return if vb.data_length == 0
|
380
|
+
puts
|
381
|
+
puts "#{indent}VBLK: #{VBLK_TYPES[vb.rec_type]}"
|
382
|
+
vb.marshal_dump.each { |k, v| printf("#{indent}\t%-15s: #{v}\n", k) unless v.kind_of?(Array) || v.kind_of?(OpenStruct) }
|
383
|
+
end
|
384
|
+
end # module LdmScanner
|
385
|
+
|
386
|
+
class LdmMdParser
|
387
|
+
attr_reader :vgName
|
388
|
+
|
389
|
+
def initialize(privhead, pvHdrs)
|
390
|
+
@pvHdrs = pvHdrs # PV headers hashed by UUID
|
391
|
+
@privhead = privhead
|
392
|
+
@vgName = privhead.diskgroup_name
|
393
|
+
end
|
394
|
+
|
395
|
+
def parse
|
396
|
+
getVgObj
|
397
|
+
end
|
398
|
+
|
399
|
+
private
|
400
|
+
|
401
|
+
def getVgObj
|
402
|
+
vgObj = VolumeGroup.new(@privhead.diskgroup_id, @vgName, 1)
|
403
|
+
vgObj.lvmType = "LDM"
|
404
|
+
|
405
|
+
@pvHdrs.each_value do |pvh|
|
406
|
+
next if pvh.diskgroup_name != @vgName
|
407
|
+
vgObj.physicalVolumes[pvh.diskVb.name] = getPvObj(vgObj, pvh) if pvh.diskVb
|
408
|
+
end
|
409
|
+
@privhead.volumes.each do |v|
|
410
|
+
vgObj.logicalVolumes[v.name] = getLvObj(vgObj, v)
|
411
|
+
end
|
412
|
+
(vgObj)
|
413
|
+
end
|
414
|
+
|
415
|
+
def getPvObj(vgObj, pvh)
|
416
|
+
pvObj = PhysicalVolume.new(pvh.disk_id, pvh.diskVb.name, nil, pvh.logical_disk_size, pvh.logical_disk_start, pvh.logical_disk_size)
|
417
|
+
pvObj.vgObj = vgObj
|
418
|
+
pvObj.diskObj = pvh.diskObj
|
419
|
+
pvObj.diskObj.pvObj = pvObj
|
420
|
+
(pvObj)
|
421
|
+
end
|
422
|
+
|
423
|
+
def getLvObj(vgObj, vol)
|
424
|
+
comp = vol.children.first
|
425
|
+
lvObj = LogicalVolume.new(vol.volume_id, vol.name, comp.num_children)
|
426
|
+
lvObj.vgObj = vgObj
|
427
|
+
lvObj.driveHint = vol.drive_hint
|
428
|
+
comp.children.each { |part| lvObj.segments << getSegObj(part) }
|
429
|
+
lvObj.segments.sort! { |x, y| x.startExtent <=> y.startExtent }
|
430
|
+
(lvObj)
|
431
|
+
end
|
432
|
+
|
433
|
+
def getSegObj(part)
|
434
|
+
segObj = LvSegment.new(part.volume_offset, part.size, nil, 1)
|
435
|
+
segObj.stripes << part.disk.name
|
436
|
+
segObj.stripes << part.start
|
437
|
+
(segObj)
|
438
|
+
end
|
439
|
+
end # class LdmMdParser
|
440
|
+
|
441
|
+
if __FILE__ == $0
|
442
|
+
SD = File.dirname(__FILE__)
|
443
|
+
$: << File.join(SD, "../disk")
|
444
|
+
|
445
|
+
require 'rubygems'
|
446
|
+
require 'log4r'
|
447
|
+
require 'ostruct'
|
448
|
+
require 'MiqDisk'
|
449
|
+
|
450
|
+
#
|
451
|
+
# Formatter to output log messages to the console.
|
452
|
+
#
|
453
|
+
class ConsoleFormatter < Log4r::Formatter
|
454
|
+
def format(event)
|
455
|
+
(event.data.kind_of?(String) ? event.data : event.data.inspect) + "\n"
|
456
|
+
end
|
457
|
+
end
|
458
|
+
$log = Log4r::Logger.new 'toplog'
|
459
|
+
$log.level = Log4r::DEBUG
|
460
|
+
Log4r::StderrOutputter.new('err_console', :formatter => ConsoleFormatter)
|
461
|
+
$log.add 'err_console'
|
462
|
+
|
463
|
+
# DISK = "/Volumes/WDpassport/Virtual Machines/cn071vcce130/cn071vcce130_3.vmdk"
|
464
|
+
# DISK = "/Volumes/WDpassport/Virtual Machines/cn071vcce130/cn071vcce130.vmdk"
|
465
|
+
DISK = "/Volumes/WDpassport/Virtual Machines/MIQAppliance-win2008x86/Win2008x86.vmdk"
|
466
|
+
puts "VMDB size = #{BinaryStruct.sizeof(LdmScanner::VBLK)}"
|
467
|
+
|
468
|
+
diskInfo = OpenStruct.new
|
469
|
+
diskInfo.fileName = DISK
|
470
|
+
|
471
|
+
disk = MiqDisk.getDisk(diskInfo)
|
472
|
+
|
473
|
+
unless disk
|
474
|
+
puts "Failed to open disk"
|
475
|
+
exit(1)
|
476
|
+
end
|
477
|
+
|
478
|
+
# parts = disk.getPartitions
|
479
|
+
|
480
|
+
puts "Disk type: #{disk.diskType}"
|
481
|
+
puts "Disk partition type: #{disk.partType}"
|
482
|
+
puts "Disk block size: #{disk.blockSize}"
|
483
|
+
puts "Disk start LBA: #{disk.lbaStart}"
|
484
|
+
puts "Disk end LBA: #{disk.lbaEnd}"
|
485
|
+
puts "Disk start byte: #{disk.startByteAddr}"
|
486
|
+
puts "Disk end byte: #{disk.endByteAddr}"
|
487
|
+
|
488
|
+
# disk.seek(LdmScanner::PRIVHEAD_OFFSET)
|
489
|
+
# ph = LdmScanner.readStruct(disk, LdmScanner::PRIVHEAD)
|
490
|
+
# if ph.signature != "PRIVHEAD"
|
491
|
+
# puts "#{DISK} is not an LDM disk"
|
492
|
+
# exit
|
493
|
+
# end
|
494
|
+
# LdmScanner.dumpPrivhead(ph)
|
495
|
+
#
|
496
|
+
# tblock_offset = (ph.db_start + LdmScanner::TBLOCK_BLOCK) * LdmScanner::LDM_SECTOR_SIZE
|
497
|
+
# disk.seek(tblock_offset)
|
498
|
+
# tb = LdmScanner.readStruct(disk, LdmScanner::TOCBLOCK)
|
499
|
+
# LdmScanner.dumpTocblock(tb)
|
500
|
+
#
|
501
|
+
# vmdb_offset = (ph.db_start + tb.bitmap1_start) * LdmScanner::LDM_SECTOR_SIZE
|
502
|
+
# disk.seek(vmdb_offset)
|
503
|
+
# vmdb = LdmScanner.readStruct(disk, LdmScanner::VMDB)
|
504
|
+
# LdmScanner.dumpVmdb(vmdb)
|
505
|
+
#
|
506
|
+
# # puts
|
507
|
+
# # puts "=============================================="
|
508
|
+
# #
|
509
|
+
# (0...vmdb.sequence).each do |i|
|
510
|
+
# next unless (vblk = LdmScanner.readVBLK(disk))
|
511
|
+
# LdmScanner.dumpVblk(vblk)
|
512
|
+
# end
|
513
|
+
#
|
514
|
+
# LdmScanner.vblkHash.each_value do |v|
|
515
|
+
# LdmScanner.vblkHash[v.parent_id].children << v if v.parent_id
|
516
|
+
# v.disk = LdmScanner.vblkHash[v.disk_id] if v.disk_id
|
517
|
+
# end
|
518
|
+
|
519
|
+
puts
|
520
|
+
puts "=============================================="
|
521
|
+
|
522
|
+
unless (ph = LdmScanner.scan(disk))
|
523
|
+
puts "#{disk.dInfo.fileName} is not an LDM disk"
|
524
|
+
disk.close
|
525
|
+
exit
|
526
|
+
end
|
527
|
+
|
528
|
+
if ph.volumes.empty?
|
529
|
+
puts "#{disk.dInfo.fileName} has no volumes"
|
530
|
+
disk.close
|
531
|
+
exit
|
532
|
+
end
|
533
|
+
|
534
|
+
ph.volumes.each do |v|
|
535
|
+
LdmScanner.dumpVblk(v)
|
536
|
+
v.children.each do |c|
|
537
|
+
LdmScanner.dumpVblk(c, "\t")
|
538
|
+
c.children.each do |p|
|
539
|
+
LdmScanner.dumpVblk(p, "\t\t")
|
540
|
+
LdmScanner.dumpVblk(p.disk, "\t\t\t") if p.disk
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
disk.close
|
546
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
3
|
+
require 'VolumeManager/LVM'
|
4
|
+
|
5
|
+
if __FILE__ == $0
|
6
|
+
md = IO.read("lvmt2_metadata")
|
7
|
+
parser = Lvm2MdParser.new(md, nil)
|
8
|
+
puts "Parsing metadata for volume group: #{parser.vgName}"
|
9
|
+
vg = parser.parse
|
10
|
+
vg.dump
|
11
|
+
|
12
|
+
vg.logicalVolumes.each_value do |lv|
|
13
|
+
puts "***** LV: #{lv.lvName} start *****"
|
14
|
+
parser.dumpVg(lv.vgObj)
|
15
|
+
puts "***** LV: #{lv.lvName} end *****"
|
16
|
+
end
|
17
|
+
end
|