Class: Mortar::Command::Clusters
- Defined in:
- lib/mortar/command/clusters.rb
Overview
view running and recent clusters
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#index ⇒ Object
clusters.
-
#stop ⇒ Object
clusters: stop CLUSTER_ID.
Methods inherited from Base
#api, #ask_public, #config_parameters, #get_error_message_context, #git, #initialize, #initialize_embedded_project, #luigi_parameters, namespace, #pig_parameters, #project, #register_api_call, #register_do, #register_project, #spark_script_arguments, #validate_project_name, #validate_project_structure
Methods included from Helpers
#action, #ask, #confirm, #copy_if_not_present_at_dest, #default_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #display_with_indent, #download_to_file, #ensure_dir_exists, #error, error_with_failure, error_with_failure=, extended, extended_into, #format_bytes, #format_date, #format_with_bang, #full_host, #get_terminal_environment, #home_directory, #host, #hprint, #hputs, included, included_into, #installed_with_omnibus?, #json_decode, #json_encode, #line_formatter, #longest, #output_with_bang, #pending_github_team_state_message, #quantify, #redisplay, #retry_on_exception, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #test_name, #ticking, #time_ago, #truncate, #warning, #with_tty, #write_to_file
Constructor Details
This class inherits a constructor from Mortar::Command::Base
Instance Method Details
#index ⇒ Object
clusters
Display running and recently terminated clusters.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mortar/command/clusters.rb', line 27 def index validate_arguments! clusters = api.get_clusters(Mortar::API::Jobs::CLUSTER_BACKEND__ALL).body['clusters'] if not clusters.empty? display_table(clusters, %w( cluster_id size status_description cluster_type_description start_timestamp duration cluster_backend_description), ['cluster_id', 'Size (# of Nodes)', 'Status', 'Type', 'Start Timestamp', 'Elapsed Time', 'Cluster Backend']) else display("There are no running or recent clusters") end end |
#stop ⇒ Object
clusters: stop CLUSTER_ID
Stop a running cluster.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mortar/command/clusters.rb', line 45 def stop cluster_id = shift_argument unless cluster_id error("Usage: mortar clusters:stop CLUSTER_ID\nMust specify CLUSTER_ID.") end response = api.stop_cluster(cluster_id) .body if response['message'].nil? display("Stopping cluster #{cluster_id}.") else display(response['message']) end end |