Class: Bosh::Cli::Command::Task
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
- #cancel(task_id) ⇒ Object
- #list_recent(count = 30) ⇒ Object
- #list_running ⇒ Object
-
#track(*args) ⇒ Object
Tracks a running task or outputs the logs from an old task.
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_running ⇒ Object
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.
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) = { :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, ) tracker.track end |