Class: RightScaleCLI::Instances
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::Instances
- Defined in:
- lib/rightscale_cli/instances.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Instances
constructor
A new instance of Instances.
- #list ⇒ Object
- #run_exec(exec_type, exec_identifier) ⇒ Object
- #show(instance_id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Instances
Returns a new instance of Instances.
25 26 27 28 29 |
# File 'lib/rightscale_cli/instances.rb', line 25 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new() end |
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
128 129 130 |
# File 'lib/rightscale_cli/instances.rb', line 128 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#list ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rightscale_cli/instances.rb', line 50 def list() 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] instances = [] @client.client.clouds(:id => [:cloud]).show.instances(:filter => filter).index.each do |instance| instance_href = instance.href instance = instance.raw instance['href'] = instance_href instances.push(instance) end @client.render(instances, 'instances') end |
#run_exec(exec_type, exec_identifier) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rightscale_cli/instances.rb', line 98 def run_exec(exec_type, exec_identifier) params = {} filter = [] if exec_type == 'recipe' params['recipe_name'] = exec_identifier elsif exec_type == 'rightscript' params['right_script_href'] = "/api/right_scripts/#{exec_identifier}" end 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] params['filter'] = filter @logger.debug "filter: #{filter}" if [:debug] @logger.debug "params: #{params}" if [:debug] @client.client.clouds(:id => [:cloud]).show.instances.multi_run_executable(params) end |
#show(instance_id) ⇒ Object
79 80 81 82 |
# File 'lib/rightscale_cli/instances.rb', line 79 def show(instance_id) filter = [] @client.render(@client.client.clouds(:id => [:cloud]).show.instances.index(:id => instance_id).show.raw, 'instance') end |