Class: DTK::Client::Task
- Inherits:
-
CommandBaseThor
- Object
- Thor
- CommandBaseThor
- DTK::Client::Task
- Defined in:
- lib/commands/thor/task.rb
Constant Summary
Constants inherited from CommandBaseThor
CommandBaseThor::ALT_IDENTIFIER_SEPARATOR, CommandBaseThor::EXTENDED_TIMEOUT, CommandBaseThor::HIDE_FROM_BASE_CONTEXT, CommandBaseThor::TIME_DIFF
Constants included from CommandHelperMixin
Constants included from ReparseMixin
ReparseMixin::YamlDTKMetaFiles
Constants included from Poller
Constants inherited from Thor
Thor::HIDE_FROM_BASE_CONTEXT_HELP
Class Method Summary collapse
Instance Method Summary collapse
- #commit_changes(context_params) ⇒ Object
- #commit_changes_and_execute(context_params) ⇒ Object
- #converge_node(context_params) ⇒ Object
- #converge_nodes ⇒ Object
- #execute(context_params) ⇒ Object
- #list(context_params) ⇒ Object
- #simple_run(context_params) ⇒ Object
- #status(context_params) ⇒ Object
Methods inherited from CommandBaseThor
action_on_revalidation_response, basename, create_context_arguments, execute_from_cli, generate_cached_id, get_cached_response, get_identifiers, get_usage_info, #help, #initialize, invalidate_entities, invisible_context_list, list_method_supported?, task_names, tiered_task_names, valid_id?
Methods included from CommandBase
#get, #get_connection, handle_argument_error, #post, #post_file, #rest_url, #rotate_args
Methods included from TaskStatusMixin
#list_task_info_aux, #task_status_aux, #task_status_stream
Methods included from Console
confirmation_prompt, confirmation_prompt_additional_options, confirmation_prompt_multiple_choice, confirmation_prompt_simple, unix_shell, wait_animation
Methods included from CommandHelperMixin
Methods included from ReparseMixin
Methods included from PushCloneChangesMixin
Methods included from CommandBaseThor::CommonOptionDefs::ClassMixin
Methods included from Poller
#poller_response, #print_response, #resolve_type
Methods inherited from Thor
get_alternative_identifiers, help, match_help_item_changes, overriden_help, printable_tasks, replace_if_matched!, set_context
Constructor Details
This class inherits a constructor from DTK::Client::CommandBaseThor
Class Method Details
.whoami ⇒ Object
21 22 23 |
# File 'lib/commands/thor/task.rb', line 21 def self.whoami() return :task, "task/list", nil end |
Instance Method Details
#commit_changes(context_params) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/commands/thor/task.rb', line 53 def commit_changes(context_params) scope = context_params.retrieve_arguments([:option_1],method_argument_names) post_hash_body = Hash.new post_hash_body.merge!(:scope => scope) if scope post rest_url("task/create_task_from_pending_changes"),post_hash_body end |
#commit_changes_and_execute(context_params) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/commands/thor/task.rb', line 67 def commit_changes_and_execute(context_params) response = commit_changes(context_params) if response.ok? execute(response.data(:task_id)) else response end end |
#converge_node(context_params) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/commands/thor/task.rb', line 82 def converge_node(context_params) node_id = context_params.retrieve_arguments([:option_1!],method_argument_names) scope = node_id && {:node_id => node_id} response = post(rest_url("task/create_converge_state_changes"),scope) return response unless response.ok? response = commit_changes_and_execute(scope) while not task_complete(response) do response = status() sleep(TASK_STATUS_POLLING_INTERVAL) end response end |
#converge_nodes ⇒ Object
97 98 99 |
# File 'lib/commands/thor/task.rb', line 97 def converge_nodes() converge_node(nil) end |
#execute(context_params) ⇒ Object
61 62 63 64 |
# File 'lib/commands/thor/task.rb', line 61 def execute(context_params) task_id = context_params.retrieve_arguments([:task_id!],method_argument_names) post rest_url("task/execute"), :task_id => task_id end |
#list(context_params) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/commands/thor/task.rb', line 28 def list(context_params) #TODO: just hard coded params now search_hash = SearchHash.new() search_hash.cols = [:commit_message,:status,:id,:created_at,:started_at,:ended_at] search_hash.filter = [:eq, ":task_id", nil] #just top level tasks search_hash.set_order_by!(:created_at,"DESC") response = post rest_url("task/list"), search_hash.post_body_hash() response.render_table(:task) unless .list? return response end |
#simple_run(context_params) ⇒ Object
77 78 79 |
# File 'lib/commands/thor/task.rb', line 77 def simple_run(context_params) commit_changes_and_execute(context_params) end |
#status(context_params) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/commands/thor/task.rb', line 43 def status(context_params) task_id = context_params.retrieve_arguments([:task_id],method_argument_names) detail_level = ["detail-level"] post_hash_body = Hash.new post_hash_body[:detail_level] = detail_level if detail_level post_hash_body[:task_id] = task_id if task_id post rest_url("task/status"),post_hash_body end |