Class: RightScaleCLI::Clouds
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::Clouds
- Defined in:
- lib/rightscale_cli/clouds.rb
Overview
Represents Clouds
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Clouds
constructor
A new instance of Clouds.
- #list ⇒ Object
- #search ⇒ Object
- #show(cloud_id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Clouds
Returns a new instance of Clouds.
26 27 28 29 30 |
# File 'lib/rightscale_cli/clouds.rb', line 26 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new end |
Class Method Details
.banner(task, _namespace = true, subcommand = false) ⇒ Object
81 82 83 |
# File 'lib/rightscale_cli/clouds.rb', line 81 def self.(task, _namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#list ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rightscale_cli/clouds.rb', line 37 def list clouds = @client.get('clouds') if [:basic] basic_fields = %w('display_name', 'cloud_type', 'name') basic_clouds = [] @client.get('clouds').each do |cloud| cloud_id = cloud['links'].select { |link| link['rel'] == 'instances' } .first['href'].split('/')[3] c = cloud.select { |x| basic_fields.include?(x) } c['cloud_id'] = cloud_id.to_i basic_clouds.push(c) end clouds = basic_clouds end @client.render(clouds, 'clouds') end |
#search ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rightscale_cli/clouds.rb', line 65 def search filter = [] filter.push("name==#{[:name]}") if [:name] filter.push("cloud_type==#{[:cloud_type]}") if [:cloud_type] filter.push("description==#{[:cloud]}") if [:description] @logger.info 'Searching for clouds!' puts "filter: #{filter}" if [:debug] clouds = [] @client.client.clouds.index(filter: filter) .each { |cloud| clouds.push(cloud.raw) } @client.render(clouds, 'clouds') end |
#show(cloud_id) ⇒ Object
57 58 59 |
# File 'lib/rightscale_cli/clouds.rb', line 57 def show(cloud_id) @client.render(@client.show('clouds', cloud_id), 'cloud') end |