Sha256: 272f3aa56550d4e7627b47607d952db2235bedb36cebcc89223b5f4928101393

Contents?: true

Size: 1.68 KB

Versions: 25

Compression:

Stored size: 1.68 KB

Contents

class StoragePool < CloudstackCli::Base

  desc 'list', 'list storage_pools'
  option :zone, desc: "zone name for the storage pool"
  option :name, desc: "name of the storage pool"
  option :keyword, desc: "list by keyword"
  option :state, desc: "filter by state (Up, Maintenance)"
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_zone
    storage_pools = client.list_storage_pools(options)
    if storage_pools.size < 1
      say "No storage pools found."
    else
      case options[:format].to_sym
      when :yaml
        puts({storage_pools: storage_pools}.to_yaml)
      when :json
        puts JSON.pretty_generate(storage_pools: storage_pools)
      else
        storage_pools = filter_by(storage_pools, "state", options[:state]) if options[:state]
        table = [%w(Name Pod State Zone)]
        table[0] << "Size [GB]"
        table[0] << "Used [GB]"
        table[0] << "Used [%]"
        table[0] << "Alocated [GB]"
        table[0] << "Alocated [%]"
        table[0] << "Type"
        storage_pools.each do |storage_pool|
          total = storage_pool['disksizetotal'] / 1024**3
          used = (storage_pool['disksizeused'] / 1024**3) rescue 0
          allocated = (storage_pool['disksizeallocated'] / 1024**3) rescue 0
          table << [
          	storage_pool['name'], storage_pool['podname'],
            storage_pool['state'], storage_pool['zonename'],
            total, used, (100.0 / total * used).round(0),
            allocated, (100.0 / total * allocated).round(0),
            storage_pool['type']
          ]
        end
        print_table table
        say "Total number of storage_pools: #{storage_pools.size}"
      end
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/storage_pool.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/storage_pool.rb