Class: Bosh::Cli::Command::Task
Constant Summary collapse
- INCLUDE_ALL =
"Include all task types (ssh, logs, vms, etc)"
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#args, #options, #out, #runner, #work_dir
Instance Method Summary collapse
- #cancel(task_id) ⇒ Object
- #list_recent(count = 30) ⇒ Object
- #list_running ⇒ Object
- #track(task_id = nil) ⇒ Object
Methods inherited from Base
#add_option, #blob_manager, #blobstore, #cache, #config, #confirmed?, #deployment, #director, #exit_code, #initialize, #interactive?, #logged_in?, #non_interactive?, #password, #redirect, #release, #remove_option, #target, #target_name, #task_report, #username, #verbose?
Methods included from Bosh::Cli::CommandDiscovery
#desc, #method_added, #option, #register_command, #usage
Constructor Details
This class inherits a constructor from Bosh::Cli::Command::Base
Instance Method Details
#cancel(task_id) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/cli/commands/task.rb', line 98 def cancel(task_id) auth_required task = Bosh::Cli::DirectorTask.new(director, task_id) task.cancel say("Task #{task_id} is getting canceled") end |
#list_recent(count = 30) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/cli/commands/task.rb', line 86 def list_recent(count = 30) auth_required use_filter = !.key?(:no_filter) tasks = director.list_recent_tasks(count, get_verbose_level(use_filter)) err("No recent tasks") if tasks.empty? show_tasks_table(tasks) say("Showing #{tasks.size} recent #{tasks.size == 1 ? "task" : "tasks"}") end |
#list_running ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/cli/commands/task.rb', line 73 def list_running auth_required use_filter = !.key?(:no_filter) tasks = director.list_running_tasks(get_verbose_level(use_filter)) 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(task_id = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cli/commands/task.rb', line 18 def track(task_id = nil) auth_required use_filter = !.key?(:no_filter) use_cache = !.key?(:no_cache) raw_output = [:raw] log_type = "event" n_types = 0 if [:cpi] log_type = "cpi" n_types += 1 end if [:debug] log_type = "debug" n_types += 1 end if [:event] log_type = "event" n_types += 1 end if [:result] log_type = "result" raw_output = true n_types += 1 end if n_types > 1 err("Cannot track more than one log type") end = { :log_type => log_type, :use_cache => use_cache, :raw_output => raw_output } if task_id.nil? || %w(last latest).include?(task_id) task_id = get_last_task_id(get_verbose_level(use_filter)) end 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 |