Class: Cangallo::Check
- Inherits:
-
Object
- Object
- Cangallo::Check
- Defined in:
- lib/cangallo/check.rb
Instance Method Summary collapse
- #check ⇒ Object
- #check_kernel ⇒ Object
- #check_libguestfs ⇒ Object
- #check_qemu_img ⇒ Object
- #help_kernel ⇒ Object
- #help_libguestfs ⇒ Object
- #help_qemu_img ⇒ Object
-
#initialize ⇒ Check
constructor
A new instance of Check.
Constructor Details
#initialize ⇒ Check
Returns a new instance of Check.
22 23 |
# File 'lib/cangallo/check.rb', line 22 def initialize end |
Instance Method Details
#check ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cangallo/check.rb', line 25 def check problem = false problem ||= !check_kernel problem ||= !check_qemu_img problem ||= !check_libguestfs if problem text = <<-EOT There is at least one problem in your system. You can go this page to get more information on how to fix it: https://canga.io/install/ EOT STDERR.puts text end STDERR.puts <<-EOT It's also a good idea to execute libguestfs test tool: $ libguestfs-test-tool EOT problem end |
#check_kernel ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cangallo/check.rb', line 54 def check_kernel Dir['/boot/vmlinuz*'].each do |file| if File.readable?(file) return true end end help_kernel false end |
#check_libguestfs ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cangallo/check.rb', line 112 def check_libguestfs version = Cangallo::LibGuestfs.version if !version text = "Could not get virt-customize version. Is libguestfs installed?" STDERR.puts text STDERR.puts exit(-1) end current = Gem::Version.new(version) good = Gem::Version.new("1.30.0") enough = Gem::Version.new("1.28.0") if current < enough help_libguestfs return false elsif current < good STDERR.puts "libguestfs >= 1.30.0 recomended" STDERR.puts end true end |
#check_qemu_img ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cangallo/check.rb', line 76 def check_qemu_img version = Cangallo::Qcow2.qemu_img_version if !version text = "Could not get qemu-img version. Is it installed in your system?" STDERR.puts text STDERR.puts exit(-1) end good = Gem::Version.new('2.4.0') current = Gem::Version.new(version) if current >= good true else help_qemu_img false end end |
#help_kernel ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cangallo/check.rb', line 65 def help_kernel text = <<-EOT libguestfs needs a kernel to boot it's qemu appliance. There is no kernel in your /boot directory readable by your kernel. Change the permissions of at least one kernel in that directory to be readable by the current user. EOT STDERR.puts text end |
#help_libguestfs ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/cangallo/check.rb', line 138 def help_libguestfs text = <<-EOT libguestfs version 1.28.0 is needed although 1.30.0 or newer is recomended. EOT STDERR.puts text end |
#help_qemu_img ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cangallo/check.rb', line 98 def help_qemu_img text = <<-EOT Cangallo needs a qemu-img version equal or greater than 2.4.0. Yours appears to be older. This will make impossible to compress delta images. You can download this qemu-img binary and add it to the path. Make sure the path possition is before #{%x(which qemu-img).strip}. https://canga.io/downloads/qemu-img.bz2 EOT STDERR.puts text end |