manageiq-smartstate 0.3.1 → 0.3.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.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +3 -2
  3. data/lib/manageiq/smartstate/version.rb +1 -1
  4. data/manageiq-smartstate.gemspec +1 -1
  5. metadata +3 -42
  6. data/lib/MiqVm/test/camcorder_fleece_test.rb +0 -52
  7. data/lib/MiqVm/test/localVm.rb +0 -38
  8. data/lib/MiqVm/test/partitionAlignmentCheck.rb +0 -67
  9. data/lib/MiqVm/test/remoteVm.rb +0 -56
  10. data/lib/MiqVm/test/rhevmNfsTest.rb +0 -54
  11. data/lib/MiqVm/test/rhevmNfsTest2.rb +0 -58
  12. data/lib/MiqVm/test/rhevmTest.rb +0 -62
  13. data/lib/Scvmm/test/miq_hyperv_disk_test.rb +0 -23
  14. data/lib/Scvmm/test/miq_scvmm_vm_ssa_info_test.rb +0 -31
  15. data/lib/VmLocalDiskAccess/test/localCfg.rb +0 -87
  16. data/lib/VolumeManager/test/blockDevTest.rb +0 -32
  17. data/lib/VolumeManager/test/ldm.rb +0 -90
  18. data/lib/fs/MetakitFS/test/Makefile +0 -14
  19. data/lib/fs/MetakitFS/test/MkCollectFiles.rb +0 -165
  20. data/lib/fs/MetakitFS/test/MkSelectFiles.rb +0 -20
  21. data/lib/fs/MetakitFS/test/collect_files.yaml +0 -70
  22. data/lib/fs/MetakitFS/test/init.rb +0 -3
  23. data/lib/fs/MetakitFS/test/mk2vmdk.rb +0 -54
  24. data/lib/fs/MetakitFS/test/mk4test.c +0 -92
  25. data/lib/fs/MetakitFS/test/mkFsTest.rb +0 -113
  26. data/lib/fs/MetakitFS/test/proto.rb +0 -97
  27. data/lib/fs/ext3/test/tc_Ext3BlockPointersPath.rb +0 -74
  28. data/lib/fs/test/camcorder_fs_test.rb +0 -98
  29. data/lib/fs/test/collect_files_direct.yaml +0 -22
  30. data/lib/fs/test/collect_files_in.yaml +0 -24
  31. data/lib/fs/test/collect_files_in_nc.yaml +0 -22
  32. data/lib/fs/test/collect_files_out.yaml +0 -6
  33. data/lib/fs/test/collect_files_rm.yaml +0 -6
  34. data/lib/fs/test/copyTest.rb +0 -116
  35. data/lib/fs/test/fsTest.rb +0 -77
  36. data/lib/fs/test/updateTest.rb +0 -174
  37. data/lib/metadata/MIQExtract/test/extractTest.rb +0 -33
  38. data/lib/metadata/MIQExtract/test/full_extract_test.rb +0 -67
  39. data/lib/metadata/VmConfig/test/GetVMwareCfgTest.rb +0 -40
  40. data/lib/metadata/linux/test/Name +0 -0
  41. data/lib/metadata/linux/test/Packages +0 -0
  42. data/lib/metadata/linux/test/rpoTest.rb +0 -5
  43. data/lib/metadata/linux/test/tc_LinuxUtils.rb +0 -4157
@@ -1,62 +0,0 @@
1
- require 'manageiq-gems-pending'
2
- require 'ostruct'
3
- require 'MiqVm/MiqVm'
4
- require 'ovirt'
5
- require 'manageiq/providers/ovirt/legacy/inventory'
6
- Ovirt.logger = $rhevm_log if $rhevm_log
7
-
8
- RHEVM_SERVER = raise "please define RHEVM_SERVER"
9
- RHEVM_PORT = 443
10
- RHEVM_DOMAIN = raise "please define RHEVM_DOMAIN"
11
- RHEVM_USERNAME = raise "please define RHEVM_USERNAME"
12
- RHEVM_PASSWORD = raise "please define RHEVM_PASSWORD"
13
- VM_NAME = raise "please define VM_NAME"
14
-
15
- require 'logger'
16
- $log = Logger.new(STDERR)
17
- $log.level = Logger::DEBUG
18
-
19
- begin
20
-
21
- $rhevm = ManageIQ::Providers::Ovirt::Legacy::Inventory.new(
22
- :server => RHEVM_SERVER,
23
- :port => RHEVM_PORT,
24
- :domain => RHEVM_DOMAIN,
25
- :username => RHEVM_USERNAME,
26
- :password => RHEVM_PASSWORD,
27
- :verify_ssl => false
28
- )
29
-
30
- puts "Attempting to scan VM: #{VM_NAME}"
31
-
32
- unless (rvm = Ovirt::Vm.find_by_name($rhevm.service, VM_NAME))
33
- raise "Could not find VM: #{VM_NAME}"
34
- end
35
-
36
- ost = OpenStruct.new
37
- ost.miqRhevm = $rhevm
38
- ost.openParent = false
39
-
40
- vm = MiqVm.new(rvm.api_endpoint, ost)
41
-
42
- puts "\nChecking for file systems..."
43
- vm.rootTrees.each do |fs|
44
- puts "*** Found root tree for #{fs.guestOS}"
45
- puts "Listing files in #{fs.pwd} directory:"
46
- fs.dirEntries.each { |de| puts "\t#{de}" }
47
- puts
48
- end
49
-
50
- ["services", "software", "system", "vmconfig"].each do |c|
51
- puts
52
- puts "Extracting #{c}"
53
- vm.extract(c) # .to_xml.write($stdout, 4)
54
- end
55
-
56
- vm.unmount
57
- puts "...done"
58
-
59
- rescue => err
60
- $log.error err.to_s
61
- $log.error err.backtrace.join("\n")
62
- end
@@ -1,23 +0,0 @@
1
- require 'manageiq-gems-pending'
2
- require 'rubygems'
3
- require 'Scvmm/miq_hyperv_disk'
4
-
5
- require 'logger'
6
- $log = Logger.new(STDERR)
7
- $log.level = Logger::DEBUG
8
-
9
- HOST = raise "Please define SERVERNAME"
10
- PORT = raise "Please define PORT"
11
- USER = raise "Please define USER"
12
- PASS = raise "Please define PASS"
13
- DISK = raise "Please define DISK"
14
-
15
- hyperv_disk = MiqHyperVDisk.new(HOST, USER, PASS, PORT)
16
-
17
- $log.debug "Reading 256 byte slices"
18
- hyperv_disk.open(DISK)
19
- hyperv_disk.seek(0)
20
- (1..8).each do |i|
21
- buffer = hyperv_disk.read(256)
22
- $log.debug "Buffer #{i}: \n#{buffer}\n"
23
- end
@@ -1,31 +0,0 @@
1
- require 'manageiq-gems-pending'
2
- require 'rubygems'
3
- require 'Scvmm/miq_scvmm_vm_ssa_info'
4
-
5
- require 'logger'
6
- $log = Logger.new(STDERR)
7
- $log.level = Logger::DEBUG
8
-
9
- HOST = raise "Please define SERVERNAME"
10
- PORT = raise "Please define PORT"
11
- USER = raise "Please define USER"
12
- PASS = raise "Please define PASS"
13
- VM = raise "Please define VM"
14
-
15
- vm_info_handle = MiqScvmmVmSSAInfo.new(HOST, USER, PASS, PORT)
16
- $log.debug "Getting Hyper-V Host for VM #{VM}"
17
- hyperv_host = vm_info_handle.vm_host(VM)
18
- $log.debug "Hyper-V Host is #{hyperv_host}"
19
- $log.debug "Getting VHD Type for VM #{VM}"
20
- vhd_type = vm_info_handle.vm_vhdtype(VM)
21
- $log.debug "VHD Type is #{vhd_type}"
22
- vhd = vm_info_handle.vm_harddisks(VM)
23
- $log.debug "VHD is #{vhd}"
24
- vm_info_handle.vm_create_checkpoint(VM)
25
- checkpoint = vm_info_handle.vm_get_checkpoint(VM)
26
- $log.debug "Checkpoint for #{vhd} is #{checkpoint}"
27
- vm_info_handle.vm_remove_checkpoint(VM)
28
- vm_info_handle.vm_create_checkpoint(VM)
29
- checkpoint = vm_info_handle.vm_get_checkpoint(VM)
30
- $log.debug "Checkpoint for #{vhd} is #{checkpoint}"
31
- vm_info_handle.vm_remove_checkpoint(VM)
@@ -1,87 +0,0 @@
1
- require 'util/miq-xml'
2
- require 'util/runcmd'
3
- require 'metadata/VmConfig/VmConfig'
4
- require 'VolumeManager/MiqNativeVolumeManager'
5
- require 'fs/MiqMountManager'
6
-
7
- module MiqNativeMountManager
8
- LSHW = "lshw"
9
-
10
- def self.mountVolumes
11
- lshwXml = MiqUtil.runcmd("#{LSHW} -xml")
12
- nodeHash = Hash.new { |h, k| h[k] = [] }
13
- doc = MiqXml.load(lshwXml)
14
- doc.find_match("//node").each { |n| nodeHash[n.attributes["id"].split(':', 2)[0]] << n }
15
-
16
- hardware = ""
17
-
18
- nodeHash["disk"].each do |d|
19
- diskid = d.find_first('businfo').get_text.to_s
20
- next unless diskid
21
- sn = d.find_first('size')
22
- # If there's no size node, assume it's a removable drive.
23
- next unless sn
24
- busType, busAddr = diskid.split('@', 2)
25
- if busType == "scsi"
26
- f1, f2 = busAddr.split(':', 2)
27
- f2 = f2.split('.')[1]
28
- busAddr = "#{f1}:#{f2}"
29
- else
30
- busAddr['.'] = ':'
31
- end
32
- diskid = busType + busAddr
33
- filename = d.find_first('logicalname').get_text.to_s
34
- hardware += "#{diskid}.present = \"TRUE\"\n"
35
- hardware += "#{diskid}.filename = \"#{filename}\"\n"
36
- end
37
-
38
- cfg = VmConfig.new(hardware)
39
- volMgr = MiqNativeVolumeManager.new(cfg)
40
-
41
- (MiqMountManager.mountVolumes(volMgr, cfg))
42
- end
43
- end # module MiqNativeMountManager
44
-
45
- if __FILE__ == $0
46
- require 'logger'
47
- $log = Logger.new(STDERR)
48
- $log.level = Logger::DEBUG
49
-
50
- puts "Log debug?: #{$log.debug?}"
51
-
52
- rootTrees = MiqNativeMountManager.mountVolumes
53
-
54
- if rootTrees.nil? || rootTrees.empty?
55
- puts "No root filesystems detected"
56
- exit
57
- end
58
-
59
- $miqOut = $stdout
60
- rootTrees.each do |r|
61
- r.toXml(nil)
62
- end
63
-
64
- rootTree = rootTrees[0]
65
-
66
- if rootTree.guestOS == "Linux"
67
- puts
68
- puts "Files in /:"
69
- rootTree.dirForeach("/") { |f| puts "\t#{f}" }
70
-
71
- puts
72
- puts "All files in /test_mount:"
73
- rootTree.findEach("/test_mount") { |f| puts "\t#{f}" }
74
- elsif rootTree.guestOS == "Windows"
75
- puts
76
- puts "Files in C:/"
77
- rootTree.dirForeach("C:/") { |f| puts "\t#{f}" }
78
-
79
- ["E:/", "F:/"].each do |drive|
80
- puts
81
- puts "All files in #{drive}"
82
- rootTree.findEach(drive) { |f| puts "\t#{f}" }
83
- end
84
- else
85
- puts "Unknown guest OS: #{rootTree.guestOS}"
86
- end
87
- end
@@ -1,32 +0,0 @@
1
- require 'manageiq-gems-pending'
2
- require 'ostruct'
3
-
4
- require 'disk/MiqDisk'
5
- require 'VolumeManager/MiqVolumeManager'
6
-
7
- require 'logger'
8
- $vim_log = $log = Logger.new(STDERR)
9
- $log.level = Logger::DEBUG
10
-
11
- begin
12
-
13
- volMgr = MiqVolumeManager.fromNativePvs
14
-
15
- puts
16
- puts "Volume Groups:"
17
- volMgr.vgHash.each do |vgName, vgObj|
18
- puts "\t#{vgName}: seq# = #{vgObj.seqNo}"
19
- end
20
-
21
- puts
22
- puts "Logical Volumes:"
23
- volMgr.lvHash.each do |key, lv|
24
- puts "\t#{key}\t#{lv.dInfo.lvObj.lvName}"
25
- end
26
-
27
- volMgr.closeAll
28
-
29
- rescue => err
30
- puts err.to_s
31
- puts err.backtrace.join("\n")
32
- end
@@ -1,90 +0,0 @@
1
- require 'manageiq-gems-pending'
2
- require 'ostruct'
3
- require 'more_core_extensions/core_ext/object/blank'
4
- require 'metadata/VmConfig/VmConfig'
5
- require "VolumeManager/MiqVolumeManager"
6
- require "fs/MiqFS/MiqFS"
7
- require "MiqVm/MiqVm"
8
- require 'VMwareWebService/MiqVimBroker'
9
-
10
- SRC_VM = raise "please define"
11
- vmCfg = "/Volumes/WDpassport/Virtual Machines/MIQAppliance-win2008x86/Win2008x86.vmx"
12
-
13
- require 'logger'
14
- $log = Logger.new(STDERR)
15
- $log.level = Logger::DEBUG
16
-
17
- vm = nil
18
- vim = nil
19
-
20
- begin
21
- # Uncomment following 2 lines for clienr/server connection.
22
- # broker = MiqVimBroker.new(:client)
23
- # vim = broker.getMiqVim(SERVER, USERNAME, PASSWORD)
24
- # miqVm = vim.getVimVmByFilter("config.name" => SRC_VM)
25
- #
26
- # vmCfg = miqVm.vmh['summary']['config']['vmPathName']
27
- puts "vmCfg: #{vmCfg}"
28
-
29
- $miqOut = $stdout
30
- ost = OpenStruct.new
31
- # ost.miqVim = vim
32
- vm = MiqVm.new(vmCfg, ost)
33
-
34
- # puts "**** Volume information:"
35
- # xml = vm.volumeManager.toXml
36
- # xml.write($stdout, 4)
37
- # puts
38
-
39
- rta = vm.rootTrees
40
- raise "No root filesystems detected for: #{vmCfg}" if rta.empty?
41
- rt = rta.first
42
- puts "**** Filesystem information:"
43
- rt.toXml
44
- puts
45
-
46
- # exit
47
-
48
- puts "**** First-level files:"
49
- puts "C:"
50
- rt.dirForeach("C:/") { |f| puts "\t#{f}" }
51
- # puts "F:"
52
- # rt.dirForeach("F:/") { |f| puts "\t#{f}" }
53
-
54
- puts
55
- puts "******************* SOFTWARE:"
56
- xml = vm.extract("software")
57
- xml.write($stdout, 4)
58
- puts
59
-
60
- exit
61
-
62
- vmConfig = VmConfig.new(vmCfg)
63
- volMgr = MiqVolumeManager.new(vmConfig)
64
-
65
- volMgr.visibleVolumes.each do |vv|
66
- puts "Disk type: #{vv.diskType}"
67
- puts "Disk partition type: #{vv.partType}"
68
- puts "Disk block size: #{vv.blockSize}"
69
- puts "Disk start LBA: #{vv.lbaStart}"
70
- puts "Disk end LBA: #{vv.lbaEnd}"
71
- puts "Disk start byte: #{vv.startByteAddr}"
72
- puts "Disk end byte: #{vv.endByteAddr}"
73
- if (lvObj = vv.dInfo.lvObj)
74
- puts "Drive Hint: #{lvObj.driveHint}"
75
- end
76
-
77
- if (fs = MiqFS.getFS(vv))
78
- puts "\tFS type: #{fs.fsType}"
79
- fs.dirForeach { |f| puts "\t\t#{f}" }
80
- else
81
- puts "\tNo FS detected on volume"
82
- end
83
- puts
84
- end
85
- rescue => err
86
- puts err.to_s
87
- puts err.backtrace.join("\n")
88
- ensure
89
- vm.unmount if vm
90
- end
@@ -1,14 +0,0 @@
1
-
2
- CC = c++
3
-
4
- CFLAGS = -I/usr/local/lib/ruby/1.8/i686-darwin8.10.1
5
- LDFLAGS = -static
6
- LIBS = -lmk4 -lruby
7
-
8
- mk4test: a.out
9
- rm -f mk4test
10
- cp a.out mk4test
11
- ruby MkSelectFiles.rb collect_files.yaml mk4test
12
-
13
- a.out: mk4test.c
14
- $(CC) $(CFLAGS) $(LIBS) mk4test.c
@@ -1,165 +0,0 @@
1
- require 'find'
2
- require 'fileutils'
3
- require 'yaml'
4
- require 'ostruct'
5
- require 'zlib'
6
-
7
- require 'fs/MiqFS/MiqFS'
8
- require 'fs/MetakitFS/MetakitFS'
9
-
10
- class MkCollectFiles
11
- attr_writer :verbose
12
-
13
- def initialize(collectionSpec, mkFile)
14
- @csa = collectionSpec
15
- @csa = YAML.load_file(collectionSpec) if @csa.kind_of? String
16
- @csa = [@csa] if @csa.kind_of? Hash
17
- raise "Invalid collection spec" unless @csa.kind_of? Array
18
-
19
- dobj = OpenStruct.new
20
- dobj.mkfile = mkFile
21
- dobj.create = true
22
- @mkFS = MiqFS.new(MetakitFS, dobj)
23
-
24
- @verbose = false
25
- end
26
-
27
- def collect
28
- @csa.each { |cs| doCollect(OpenStruct.new(cs)) }
29
- end
30
-
31
- def dumpSpec(specFile)
32
- YAML.dump(@csa, File.open(specFile, "w"))
33
- end
34
-
35
- private
36
-
37
- def doCollect(cs)
38
- #
39
- # The directory where the collection will be created.
40
- #
41
- destDir = cs.todir
42
-
43
- #
44
- # The directory relative to which the files will be collected.
45
- #
46
- Dir.chdir(cs.basedir)
47
- puts "BASEDIR: #{Dir.pwd}" if @verbose
48
-
49
- #
50
- # Loop through the files and directories that are to be included in the collection.
51
- #
52
- cs.include.each do |i|
53
- raise "File: #{i} does not exist" unless File.exist? i
54
- #
55
- # If this is a plain file, then include it in the collection.
56
- #
57
- unless File.directory? i
58
- puts "FILE: #{i}" if @verbose
59
- toFile = File.join(destDir, i)
60
- makePath(File.dirname(toFile))
61
- #
62
- # If the file path matches an encrypt RE and doesn't
63
- # match a noencrypt RE, then encrypt the contents of
64
- # the file before copying it to the collection.
65
- #
66
- if cs.encrypt && cs.encrypt.detect { |e| i =~ e }
67
- if !cs.noencrypt || !cs.noencrypt.detect { |ne| i =~ ne }
68
- encryptFile(i, toFile)
69
- next
70
- end
71
- end
72
- #
73
- # If the file path matches an compress RE and doesn't
74
- # match a nocompress RE, then compress the contents of
75
- # the file before copying it to the collection.
76
- #
77
- if cs.compress && cs.compress.detect { |e| i =~ e }
78
- if !cs.nocompress || !cs.nocompress.detect { |ne| i =~ ne }
79
- compressFile(i, toFile)
80
- next
81
- end
82
- end
83
- copyFile(i, toFile)
84
- next
85
- end
86
-
87
- #
88
- # If this is a directory, then recursively copy its contents
89
- # to the collection directory.
90
- #
91
- puts "DIR: #{i}" if @verbose
92
- Find.find(i) do |path|
93
- #
94
- # Prune directories that match an exclude RE.
95
- #
96
- if File.directory? path
97
- Find.prune if cs.exclude && cs.exclude.detect { |e| path =~ e }
98
- next
99
- end
100
- #
101
- # Skip files that match an exclude RE.
102
- #
103
- next if cs.exclude && cs.exclude.detect { |e| path =~ e }
104
- toFile = File.join(destDir, path)
105
- makePath(File.dirname(toFile))
106
- #
107
- # If the file path matches an encrypt RE and doesn't
108
- # match a noencrypt RE, then encrypt the contents of
109
- # the file before copying it to the collection.
110
- #
111
- if cs.encrypt && cs.encrypt.detect { |e| path =~ e }
112
- if !cs.noencrypt || !cs.noencrypt.detect { |ne| path =~ ne }
113
- encryptFile(path, toFile)
114
- next
115
- end
116
- end
117
- #
118
- # If the file path matches an compress RE and doesn't
119
- # match a nocompress RE, then compress the contents of
120
- # the file before copying it to the collection.
121
- #
122
- if cs.compress && cs.compress.detect { |e| path =~ e }
123
- if !cs.nocompress || !cs.nocompress.detect { |ne| path =~ ne }
124
- compressFile(path, toFile)
125
- next
126
- end
127
- end
128
- copyFile(path, toFile)
129
- end
130
- end if cs.include
131
- end
132
-
133
- def makePath(path)
134
- return if @mkFS.fileExists? path
135
- parentDir = @mkFS.fileDirname(path)
136
- makePath(parentDir) unless @mkFS.fileExists? parentDir
137
- @mkFS.dirMkdir(path)
138
- end
139
-
140
- def copyFile(src, dest)
141
- puts "\t COPY: #{src}\n\t TO: #{dest}\n\n" if @verbose
142
- File.open(src) do |ffo|
143
- tfo = @mkFS.fileOpen(dest, "wb")
144
- while (buf = ffo.read(4096))
145
- tfo.write(buf, buf.length)
146
- end
147
- tfo.close
148
- end
149
- end
150
- alias_method :encryptFile, :copyFile
151
-
152
- def compressFile(src, dest)
153
- puts "\tCOMPRESS: #{src}\n\t TO: #{dest}\n\n" if @verbose
154
- File.open(src) do |ffo|
155
- tfo = @mkFS.fileOpen(dest, "wb")
156
- zipper = Zlib::Deflate.new
157
- while (buf = ffo.read(4096))
158
- zipper << buf
159
- end
160
- tfo.write(zipper.deflate(nil, Zlib::FINISH))
161
- tfo.addTag("compressed")
162
- tfo.close
163
- end
164
- end
165
- end # class MkCollectFiles