Class: RightScaleCLI::ServerArrays
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::ServerArrays
- Defined in:
- lib/rightscale_cli/server_arrays.rb,
lib/rightscale_cli/server_arrays/links.rb,
lib/rightscale_cli/server_arrays/alerts.rb,
lib/rightscale_cli/server_arrays/alert_specs.rb,
lib/rightscale_cli/server_arrays/current_instances.rb,
lib/rightscale_cli/server_arrays/elasticity_params.rb,
lib/rightscale_cli/server_arrays/multi_run_executable.rb
Class Method Summary collapse
Instance Method Summary collapse
- #alert_specs(server_array_id) ⇒ Object
- #alerts(server_array_id) ⇒ Object
- #api_methods(server_array_id) ⇒ Object
- #desc(server_array_id) ⇒ Object
- #instances(server_array_id) ⇒ Object
- #instances_count(server_array_id) ⇒ Object
- #links(server_array_id) ⇒ Object
- #list ⇒ Object
- #name(server_array_id) ⇒ Object
- #params(server_array_id) ⇒ Object
- #run_exec(server_array_id, exec_type, exec_identifier) ⇒ Object
- #show(server_array_id) ⇒ Object
- #state(server_array_id) ⇒ Object
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
123 124 125 |
# File 'lib/rightscale_cli/server_arrays.rb', line 123 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#alert_specs(server_array_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rightscale_cli/server_arrays/alert_specs.rb', line 22 def alert_specs(server_array_id) rightscale = RightApi::Client.new(RightScaleCLI::Config::API) alert_specs = [] rightscale.server_arrays(:id => server_array_id).show.alert_specs.index.each { |alert_spec| alert_specs.push(alert_spec.raw) } if [:xml] puts alert_specs.to_xml(:root => 'alert_specs') elsif [:json] puts JSON.pretty_generate(alert_specs) else puts alert_specs.to_yaml end end |
#alerts(server_array_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rightscale_cli/server_arrays/alerts.rb', line 22 def alerts(server_array_id) rightscale = RightApi::Client.new(RightScaleCLI::Config::API) array_alerts = rightscale.server_arrays(:id => server_array_id).show.alerts.index if [:xml] puts array_alerts.to_xml(:root => 'alerts') elsif [:json] puts JSON.pretty_generate(array_alerts) else puts array_alerts.to_yaml end end |
#api_methods(server_array_id) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/rightscale_cli/server_arrays.rb', line 115 def api_methods(server_array_id) log = CLILogger.new log.info "Retrieving API methods for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) server_array = rightscale.server_arrays(:id => server_array_id).show.api_methods puts server_array end |
#desc(server_array_id) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/rightscale_cli/server_arrays.rb', line 99 def desc(server_array_id) log = CLILogger.new log.info "Retrieving description for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.description end |
#instances(server_array_id) ⇒ Object
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 |
# File 'lib/rightscale_cli/server_arrays/current_instances.rb', line 37 def instances(server_array_id) log = CLILogger.new rightscale = RightApi::Client.new(RightScaleCLI::Config::API) array_instances = [] filter = [] filter.push("datacenter_href==#{[:datacenter]}") if [:datacenter] filter.push("deployment_href==#{[:deployment]}") if [:deployment] filter.push("name==#{[:private_ip]}") if [:name] filter.push("os_platform==#{[:os]}") if [:os] filter.push("parent_href==#{[:parent]}") if [:parent] filter.push("private_dns_name==#{[:private_dns]}") if [:private_dns] filter.push("private_ip_address==#{[:private_ip]}") if [:private_ip] filter.push("public_dns==#{[:public_dns]}") if [:public_dns] filter.push("public_ip_address==#{[:public_ip]}") if [:public_ip] filter.push("resource_uid==#{[:resource_uid]}") if [:resource_uid] filter.push("server_template_href==#{[:server_template]}") if [:server_template] filter.push("state==#{[:state]}") if [:state] log.info "filter: #{filter}" if [:debug] rightscale.server_arrays(:id => server_array_id).show.current_instances(:filter => filter).index.each { |array_instance| array_instances.push(array_instance.raw) } RightScaleCLI::Output.render(array_instances, 'array_instances', ) end |
#instances_count(server_array_id) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/rightscale_cli/server_arrays.rb', line 91 def instances_count(server_array_id) log = CLILogger.new log.info "Retrieving instances count for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.instances_count end |
#links(server_array_id) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rightscale_cli/server_arrays/links.rb', line 22 def links(server_array_id) log = CLILogger.new log.info "Retrieving links for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.links.to_yaml end |
#list ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rightscale_cli/server_arrays.rb', line 41 def list() log = CLILogger.new rightscale = RightApi::Client.new(RightScaleCLI::Config::API) filter = [] filter.push("cloud_href==/api/clouds/#{[:cloud]}") if [:cloud] filter.push("deployment_href==/api/deployments/#{[:cloud]}") if [:deployment] filter.push("name==#{[:name]}") if [:name] log.info "filter: #{filter}" if [:debug] server_arrays = [] rightscale.server_arrays.index(:filter => filter).each { |server_array| server_arrays.push(server_array.raw) } if [:xml] puts server_arrays.to_xml(:root => 'server_arrays') elsif [:json] puts JSON.pretty_generate(server_arrays) else puts server_arrays.to_yaml end end |
#name(server_array_id) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/rightscale_cli/server_arrays.rb', line 107 def name(server_array_id) log = CLILogger.new log.info "Retrieving name for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.name end |
#params(server_array_id) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rightscale_cli/server_arrays/elasticity_params.rb', line 22 def params(server_array_id) log = CLILogger.new log.info "Retrieving elasticity parameters for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.elasticity_params.to_yaml end |
#run_exec(server_array_id, exec_type, exec_identifier) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rightscale_cli/server_arrays/multi_run_executable.rb', line 22 def run_exec(server_array_id, exec_type, exec_identifier) log = CLILogger.new rightscale = RightApi::Client.new(RightScaleCLI::Config::API) params = {} if exec_type == 'recipe' params['recipe_name'] = exec_identifier elsif exec_type == 'rightscript' params['right_script_href'] = "/api/right_scripts/#{exec_identifier}" end server_array = rightscale.server_arrays(:id => server_array_id) log.info "params: #{params}" if [:debug] log.info "Running executable on server array." server_array.multi_run_executable(params) end |
#show(server_array_id) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rightscale_cli/server_arrays.rb', line 67 def show(server_array_id) log = CLILogger.new rightscale = RightApi::Client.new(RightScaleCLI::Config::API) server_array = rightscale.server_arrays(:id => server_array_id).show.raw if [:xml] puts server_array.to_xml(:root => 'server_array') elsif [:json] puts JSON.pretty_generate(server_array) else puts server_array.to_yaml end end |
#state(server_array_id) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/rightscale_cli/server_arrays.rb', line 83 def state(server_array_id) log = CLILogger.new log.info "Retrieving state for server array, #{server_array_id}." rightscale = RightApi::Client.new(RightScaleCLI::Config::API) puts rightscale.server_arrays(:id => server_array_id).show.state end |