Class: Bosh::Cli::Command::Task

Inherits:
Base show all
Defined in:
lib/cli/commands/task.rb

Constant Summary

Constants inherited from Base

Base::BLOBS_DIR, Base::BLOBS_INDEX_FILE

Instance Attribute Summary

Attributes inherited from Base

#cache, #config, #options, #out, #usage, #work_dir

Instance Method Summary collapse

Methods inherited from Base

#blob_manager, #blobstore, command, #confirmed?, #director, #dry_run?, #exit_code, #full_target_name, #initialize, #interactive?, #logged_in?, #non_interactive?, #redirect, #release, #run, #show_usage, #target_name, #target_version, #task_report, #verbose?

Constructor Details

This class inherits a constructor from Bosh::Cli::Command::Base

Instance Method Details

#cancel(task_id) ⇒ Object



47
48
49
50
51
52
# File 'lib/cli/commands/task.rb', line 47

def cancel(task_id)
  auth_required
  task = Bosh::Cli::DirectorTask.new(director, task_id)
  task.cancel
  say("Cancelling task #{task_id}")
end

#list_recent(count = 30) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/cli/commands/task.rb', line 38

def list_recent(count = 30)
  auth_required
  tasks = director.list_recent_tasks(count)
  err("No recent tasks") if tasks.empty?
  show_tasks_table(tasks)
  say("Showing %d recent %s" % [tasks.size,
                                tasks.size == 1 ? "task" : "tasks"])
end

#list_runningObject



30
31
32
33
34
35
36
# File 'lib/cli/commands/task.rb', line 30

def list_running
  auth_required
  tasks = director.list_running_tasks
  err("No running tasks") if tasks.empty?
  show_tasks_table(tasks.sort_by { |t| t["id"].to_i * -1 })
  say("Total tasks running now: %d" % [tasks.size])
end

#track(*args) ⇒ Object

Tracks a running task or outputs the logs from an old task. Triggered with ‘bosh task <task_num>’. Check parse_flags to see what flags can be used with this.

Parameters:

  • args (Array)

    The arguments from the command line command.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cli/commands/task.rb', line 11

def track(*args)
  auth_required

  task_id, log_type, no_cache, raw_output = parse_flags(args)

  track_options = {
    :log_type => log_type,
    :use_cache => no_cache ? false : true,
    :raw_output => raw_output
  }

  if task_id.to_i <= 0
    err("Task id must be a positive integer")
  end

  tracker = Bosh::Cli::TaskTracker.new(director, task_id, track_options)
  tracker.track
end