Sha256: 3f6bd4905bcdf2a303527d182df937a168e78d518ad15a6004d3adcaebda2dc1

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module CloudstackClient

	module Volume

		##
    # Lists all volumes.

    def list_volumes(args = {})
      params = {
          'command' => 'listVolumes',
          'listall' => true,
      }

      if args[:zone]
        zone = get_zone(args[:zone])
        unless zone 
          puts "Error: Zone #{args[:zone]} not found"
          exit 1
        end
        params['zoneid'] = zone['id']  
      end

      if args[:account]
        if account = list_accounts(name: args[:account]).first
          params['domainid'] = account["domainid"]
          params['account'] = args[:account]
        end
      end

      if args[:project]
        project = get_project(args[:project])
        unless project
          puts "Error: project #{args[:project]} not found."
          exit 1
        end
        params['projectid'] = project['id']
      end

      params['projectid'] = args[:project_id] if args[:project_id]
      params['type'] = args[:type] if args[:type]
      params['keyword'] = args[:keyword] if args[:keyword]
      params['name'] = args[:name] if args[:name]
  
      json = send_request(params)
      json['volume'] || []
    end

	end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudstack_client-0.4.1 lib/cloudstack_client/commands/volume.rb
cloudstack_client-0.4.0 lib/cloudstack_client/commands/volume.rb