class Uricp::Strategy::LocalConvert
Public Instance Methods
appropriate?()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 5 def appropriate? if conversion_required? && file_source? && supported_source? return proposal if new_qemu? || supported_conversion? raise Uricp::UnsupportedConversion, 'qemu-img does not support required conversion' end debug "#{self.class.name}: not appropriate" false end
command()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 16 def command qemu_img_command(proposed_path) end
compat_option()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 57 def compat_option '-o compat=0.10' if new_qemu? end
compress_option()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 61 def compress_option options['compress'] && '-c' end
conversion_options()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 46 def conversion_options case options['target-format'] when :raw '-O raw' when :qcow2 "#{compress_option} -O qcow2 #{compat_option}" when :qcow3, :qcow2v3 "#{compress_option} -O qcow2 -o compat=1.1" end end
new_qemu?()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 34 def new_qemu? @new_qemu ||= !!(`qemu-img convert -O qcow2 -o ? a b` =~ /\bcompat\b/m) end
proposal()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 20 def proposal @proposed_options = options.dup if to.scheme == 'file' @proposed_options['from_uri'] = @proposed_options['to_uri'] else @proposed_options['from_uri'] = temp_uri @proposed_options['clean'] ||= [] @proposed_options['clean'] << proposed_path end @proposed_options.delete('source-format') @proposed_options.delete('target-format') self end
qemu_img_command(target)
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 42 def qemu_img_command(target) "qemu-img convert #{conversion_options} #{from.path} #{target};" end
supported_conversion?()
click to toggle source
# File lib/uricp/strategy/local_convert.rb, line 38 def supported_conversion? ([:qcow3, :qcow2v3] & [options['source-format'], options['target-format']]).empty? # rubocop:disable Style/SymbolArray end