Sha256: 824dae962211e2077d8c7bb828c1e747bf945ef44ae072c8529e0e7caebd8224

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

class Account < CloudstackCli::Base

  TYPES = {
    0 => 'user',
    1 => 'domain-admin',
    2 => 'admin'
  }

  desc "show NAME", "show detailed infos about an account"
  def show(name)
    accounts = client.list_accounts(name: name)
    if accounts.size < 1
      say "No account named \"#{name}\" found.", :red
    else
      account = accounts.first
      account.delete 'user'
      account['accounttype'] = "#{account['accounttype']} (#{TYPES[account['accounttype']]})"
      table = account.map do |key, value|
        [ set_color("#{key}", :yellow), "#{value}" ]
      end
      print_table table
    end
  end

  desc 'list', 'list accounts'
  def list
    accounts = client.list_accounts
    if accounts.size < 1
      puts "No accounts found."
    else
      table = [%w(Name Type Domain State)]
      accounts.each do |account|
        table << [
          account['name'],
          TYPES[account['accounttype']],
          account['domain'],
          account['state']
        ]
      end
      print_table table
      say "Total number of accounts: #{accounts.size}"
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cloudstack-cli-0.15.1 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-0.15.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-0.14.1 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-0.14.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-0.13.1 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-0.13.0 lib/cloudstack-cli/commands/account.rb