Class: RightScaleCLI::Volumes

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

Class Method Summary collapse

Instance Method Summary collapse

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



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

def list()
  volumes = []      
  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]

  $log.debug "filter: #{filter}" if options[:debug]

  RightApi::Client.new(RightScaleCLI::Config::API).clouds(:id => options[:cloud]).show.volumes(:filter => filter).index.each { |volume|
    volumes.push(volume.raw)
  }

  RightScaleCLI::Output.render(volumes, 'volumes', options)
end

#show(volume_id) ⇒ Object



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

def show(volume_id)
  volume = RightApi::Client.new(RightScaleCLI::Config::API).clouds(:id => options[:cloud]).show.volumes(:id => volume_id).show.raw
  RightScaleCLI::Output.render(volume, 'volume', options)
end