Class: RightScaleCLI::Volumes

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Volumes

Returns a new instance of Volumes.



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

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

Class Method Details



65
66
67
# File 'lib/rightscale_cli/volumes.rb', line 65

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

Instance Method Details

#listObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rightscale_cli/volumes.rb', line 41

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 { |volume|
    volumes.push(volume.raw)
  }

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

#show(volume_id) ⇒ Object



61
62
63
# File 'lib/rightscale_cli/volumes.rb', line 61

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