Module: ImportTools::Exceptional::Include

Included in:
HammerCLIImport::BaseCommand
Defined in:
lib/hammer_cli_import/importtools.rb

Instance Method Summary collapse

Instance Method Details

#handle_missing_and_supress(what, &block) ⇒ Object



326
327
328
329
330
331
332
333
# File 'lib/hammer_cli_import/importtools.rb', line 326

def handle_missing_and_supress(what, &block)
  block.call
rescue HammerCLIImport::MissingObjectError => moe
  error moe.message
rescue => e
  error "Caught #{e.class}:#{e.message} while #{what}"
  logtrace e
end

#silently(&block) ⇒ Object

this method catches everything sent to stdout and stderr and disallows any summary changes

this is a bad hack, but we need it, as sat6 cannot tell, whether there’re still content hosts associated with a content view so we try to delete system content views silently



341
342
343
344
345
346
347
348
349
350
# File 'lib/hammer_cli_import/importtools.rb', line 341

def silently(&block)
  summary_backup = @summary.clone
  $stdout = StringIO.new
  $stderr = StringIO.new
  block.call
  ensure
    $stdout = STDOUT
    $stderr = STDERR
    @summary = summary_backup
end