Module: HammerCLIForemanTasks::Helper

Included in:
Task::ProgressCommand
Defined in:
lib/hammer_cli_foreman_tasks/helper.rb

Instance Method Summary collapse

Instance Method Details

#load_task(id) ⇒ Object



16
17
18
# File 'lib/hammer_cli_foreman_tasks/helper.rb', line 16

def load_task(id)
  HammerCLIForeman.foreman_resource!(:foreman_tasks).call(:show, :id => id)
end

#task_progress(task_or_id) ⇒ Object

render the progress of the task using polling to the task API



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hammer_cli_foreman_tasks/helper.rb', line 4

def task_progress(task_or_id)
  task_id = task_or_id.is_a?(Hash) ? task_or_id['id'] : task_or_id
  if !task_id.empty?
    options = { verbosity: @context[:verbosity] || HammerCLI::V_VERBOSE }
    task_progress = TaskProgress.new(task_id, options) { |id| load_task(id) }
    task_progress.render
    task_progress.success?
  else
    signal_usage_error(_('Please mention appropriate attribute value'))
  end
end