Class: HammerCLIForemanBootdisk::DownloadCommand
- Inherits:
-
HammerCLIForeman::Command
- Object
- HammerCLIForeman::Command
- HammerCLIForemanBootdisk::DownloadCommand
- Defined in:
- lib/hammer_cli_foreman_bootdisk/commands.rb
Direct Known Subclasses
Bootdisk::GenericCommand, Bootdisk::HostCommand, Bootdisk::SubnetCommand
Instance Method Summary collapse
-
#print_data(record) ⇒ Object
rubocop:disable Layout/LineLength.
-
#request_options ⇒ Object
rubocop:enable Layout/LineLength.
Instance Method Details
#print_data(record) ⇒ Object
rubocop:disable Layout/LineLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hammer_cli_foreman_bootdisk/commands.rb', line 13 def print_data(record) server_filename = ::Regexp.last_match(1) if record.headers[:content_disposition].match?(/filename=["']?([^\s,;"']+)/) file = [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 ![HammerCLI.option_accessor_name('force')] && File.exist?(file) && !File.file?(file) if [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 ( % file) if end |
#request_options ⇒ Object
rubocop:enable Layout/LineLength
34 35 36 |
# File 'lib/hammer_cli_foreman_bootdisk/commands.rb', line 34 def { response: :raw } end |