Class: RightScaleCLI::Instances
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::Instances
- Defined in:
- lib/rightscale_cli/instances.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
111 112 113 |
# File 'lib/rightscale_cli/instances.rb', line 111 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#list ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rightscale_cli/instances.rb', line 40 def list() instances = [] filter = [] filter.push("datacenter_href==#{options[:datacenter]}") if [:datacenter] filter.push("deployment_href==#{options[:deployment]}") if [:deployment] filter.push("name==#{options[:private_ip]}") if [:name] filter.push("os_platform==#{options[:os]}") if [:os] filter.push("parent_href==#{options[:parent]}") if [:parent] filter.push("private_dns_name==#{options[:private_dns]}") if [:private_dns] filter.push("private_ip_address==#{options[:private_ip]}") if [:private_ip] filter.push("public_dns==#{options[:public_dns]}") if [:public_dns] filter.push("public_ip_address==#{options[:public_ip]}") if [:public_ip] filter.push("resource_uid==#{options[:resource_uid]}") if [:resource_uid] filter.push("server_template_href==#{options[:server_template]}") if [:server_template] filter.push("state==#{options[:state]}") if [:state] $log.debug "filter: #{filter}" if [:debug] RightApi::Client.new(RightScaleCLI::Config::API).clouds(:id => [:cloud]).show.instances(:filter => filter).index.each { |instance| instances.push(instance.raw) } puts instances.to_yaml end |
#run_exec(exec_type, exec_identifier) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rightscale_cli/instances.rb', line 79 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==#{options[:datacenter]}") if [:datacenter] filter.push("deployment_href==#{options[:deployment]}") if [:deployment] filter.push("name==#{options[:private_ip]}") if [:name] filter.push("os_platform==#{options[:os]}") if [:os] filter.push("parent_href==#{options[:parent]}") if [:parent] filter.push("private_dns_name==#{options[:private_dns]}") if [:private_dns] filter.push("private_ip_address==#{options[:private_ip]}") if [:private_ip] filter.push("public_dns==#{options[:public_dns]}") if [:public_dns] filter.push("public_ip_address==#{options[:public_ip]}") if [:public_ip] filter.push("resource_uid==#{options[:resource_uid]}") if [:resource_uid] filter.push("server_template_href==#{options[:server_template]}") if [:server_template] filter.push("state==#{options[:state]}") if [:state] params['filter'] = filter $log.debug "filter: #{filter}" if [:debug] $log.debug "params: #{params}" if [:debug] rightscale = RightApi::Client.new(RightScaleCLI::Config::API) rightscale.clouds(:id => [:cloud]).show.instances.multi_run_executable(params) end |