Class: RightScaleCLI::Volumes

Inherits:
Thor
  • Object
show all
Defined in:
lib/rightscale_cli/volumes.rb

Overview

Represents Storage Volumes

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Volumes

Returns a new instance of Volumes.



26
27
28
29
30
# File 'lib/rightscale_cli/volumes.rb', line 26

def initialize(*args)
  super
  @client = RightScaleCLI::Client.new(options)
  @logger = RightScaleCLI::Logger.new
end

Class Method Details



100
101
102
# File 'lib/rightscale_cli/volumes.rb', line 100

def self.banner(task, _namespace = true, subcommand = false)
  "#{basename} #{task.formatted_usage(self, true, subcommand)}"
end

Instance Method Details

#listObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rightscale_cli/volumes.rb', line 71

def list
  filter = []
  filter.push("datacenter_href==/api/clouds/#{options[:cloud]}/datacenters/#{options[:datacenter]}") if options[:datacenter]
  filter.push("description==#{options[:description]}") if options[:description]
  filter.push("name==#{options[:name]}") if options[:name]
  filter.push("parent_volume_snapshot_href==#{options[:parent]}") if options[:parent]
  filter.push("resource_uid==#{options[:resource_uid]}") if options[:resource_uid]

  @logger.debug "filter: #{filter}" if options[:debug]

  volumes = []
  @client.client.clouds(id: options[:cloud])
    .show.volumes(filter: filter).index.each do |volume|
    volumes.push(volume.raw)
  end

  @client.render(volumes, 'volumes')
end

#show(volume_id) ⇒ Object



95
96
97
98
# File 'lib/rightscale_cli/volumes.rb', line 95

def show(volume_id)
  @client.render(@client.client.clouds(id: options[:cloud])
    .show.volumes(id: volume_id).show.raw, 'volume')
end