Class: HammerCLIForemanBootdisk::DownloadCommand
- Inherits:
-
HammerCLIForeman::Command
- Object
- HammerCLIForeman::Command
- HammerCLIForemanBootdisk::DownloadCommand
show all
- Defined in:
- lib/hammer_cli_foreman_bootdisk/commands.rb
Instance Method Summary
collapse
Instance Method Details
#print_data(record) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/hammer_cli_foreman_bootdisk/commands.rb', line 10
def print_data(record)
server_filename = ::Regexp.last_match(1) if record.[:content_disposition].match?(/filename=["']?([^\s,;"']+)/)
file = options[HammerCLI.option_accessor_name('file')] || server_filename || 'bootdisk.iso'
raise(HammerCLIForeman::OperationNotSupportedError, _("Destination %s already exists and isn't a regular file, use '--force' if you are sure you wish to write to it") % file) if !options[HammerCLI.option_accessor_name('force')] && File.exist?(file) && !File.file?(file)
if options[HammerCLI.option_accessor_name('sudo')]
temp_file = Tempfile.new('bootdisk')
begin
File.write(temp_file, record)
system('sudo', 'dd', "if=#{temp_file.path}", "of=#{file}", 'bs=1024')
ensure
temp_file.close
temp_file.unlink
end
else
File.write(file, record)
end
print_message(success_message % file) if success_message
end
|
#request_options ⇒ Object
30
31
32
|
# File 'lib/hammer_cli_foreman_bootdisk/commands.rb', line 30
def request_options
{ response: :raw }
end
|