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
-
#initialize(*args) ⇒ ServerArrays
constructor
A new instance of ServerArrays.
- #inputs(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
- #next(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
Constructor Details
#initialize(*args) ⇒ ServerArrays
Returns a new instance of ServerArrays.
31 32 33 34 35 |
# File 'lib/rightscale_cli/server_arrays.rb', line 31 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new() end |
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
105 106 107 |
# File 'lib/rightscale_cli/server_arrays.rb', line 105 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 |
# File 'lib/rightscale_cli/server_arrays/alert_specs.rb', line 22 def alert_specs(server_array_id) alert_specs = [] @client.client.server_arrays(:id => server_array_id).show.alert_specs.index.each { |alert_spec| alert_specs.push(alert_spec.raw) } @client.render(alert_specs, 'server_array') end |
#alerts(server_array_id) ⇒ Object
22 23 24 |
# File 'lib/rightscale_cli/server_arrays/alerts.rb', line 22 def alerts(server_array_id) @client.render(@client.client.server_arrays(:id => server_array_id).show.alerts.index, 'alert_specs') end |
#api_methods(server_array_id) ⇒ Object
90 91 92 93 |
# File 'lib/rightscale_cli/server_arrays.rb', line 90 def api_methods(server_array_id) @logger.info "Retrieving API methods for server array, #{server_array_id}." puts @client.client.server_arrays(:id => server_array_id).show.api_methods end |
#desc(server_array_id) ⇒ Object
78 79 80 81 |
# File 'lib/rightscale_cli/server_arrays.rb', line 78 def desc(server_array_id) @logger.info "Retrieving description for server array, #{server_array_id}." puts @client.client.server_arrays(:id => server_array_id).show.description end |
#inputs(server_array_id) ⇒ Object
96 97 98 |
# File 'lib/rightscale_cli/server_arrays.rb', line 96 def inputs(server_array_id) @client.render(@client.show('server_arrays', server_array_id), 'server_array') 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 |
# File 'lib/rightscale_cli/server_arrays/current_instances.rb', line 37 def instances(server_array_id) 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] @logger.debug "filter: #{filter}" if [:debug] array_instances = [] @client.client.server_arrays(:id => server_array_id).show.current_instances(:filter => filter).index.each { |array_instance| array_instances.push(array_instance.raw) } @client.render(array_instances, 'array_instances') end |
#instances_count(server_array_id) ⇒ Object
72 73 74 75 |
# File 'lib/rightscale_cli/server_arrays.rb', line 72 def instances_count(server_array_id) @logger.info "Retrieving instances count for server array, #{server_array_id}." puts @client.client.server_arrays(:id => server_array_id).show.instances_count end |
#links(server_array_id) ⇒ Object
31 32 33 34 |
# File 'lib/rightscale_cli/server_arrays/links.rb', line 31 def links(server_array_id) @logger.info "Retrieving links for server array, #{server_array_id}." @client.render(@client.client.server_arrays(:id => server_array_id).show.links, 'links') end |
#list ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rightscale_cli/server_arrays.rb', line 44 def list() 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] @logger.debug "filter: #{filter}" if [:debug] server_arrays = [] @client.client.server_arrays.index(:filter => filter).each { |server_array| server_arrays.push(server_array.raw) } @client.render(server_arrays, 'server_arrays') end |
#name(server_array_id) ⇒ Object
84 85 86 87 |
# File 'lib/rightscale_cli/server_arrays.rb', line 84 def name(server_array_id) @logger.info "Retrieving name for server array, #{server_array_id}." puts @client.client.server_arrays(:id => server_array_id).show.name end |
#next(server_array_id) ⇒ Object
101 102 103 |
# File 'lib/rightscale_cli/server_arrays.rb', line 101 def next(server_array_id) @client.render(@client.client.server_arrays(:id => server_array_id).show.next_instance.index) end |
#params(server_array_id) ⇒ Object
22 23 24 25 |
# File 'lib/rightscale_cli/server_arrays/elasticity_params.rb', line 22 def params(server_array_id) @logger.info "Retrieving elasticity parameters for server array, #{server_array_id}." @client.render(@client.client.server_arrays(:id => server_array_id).show.elasticity_params, 'server_array') 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 |
# File 'lib/rightscale_cli/server_arrays/multi_run_executable.rb', line 22 def run_exec(server_array_id, exec_type, exec_identifier) 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 = @client.client.server_arrays(:id => server_array_id) @logger.info "params: #{params}" if [:debug] @logger.info "Running executable on server array." server_array.multi_run_executable(params) end |
#show(server_array_id) ⇒ Object
61 62 63 |
# File 'lib/rightscale_cli/server_arrays.rb', line 61 def show(server_array_id) @client.render(@client.show('server_arrays', server_array_id), 'server_array') end |
#state(server_array_id) ⇒ Object
66 67 68 69 |
# File 'lib/rightscale_cli/server_arrays.rb', line 66 def state(server_array_id) @logger.info "Retrieving state for server array, #{server_array_id}." puts @client.client.server_arrays(:id => server_array_id).show.state end |