Sha256: e12153e73098d5f2ea79da8b9e3ac397fa4e78f041a31c9b0e430b3a362db4c9

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 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)
    unless account = client.list_accounts(name: name).first
      say "No account named \"#{name}\" found.", :red
    else
      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(listall: true)
    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

22 entries across 22 versions & 1 rubygems

Version Path
cloudstack-cli-1.3.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.7 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.6 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.5 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.4 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.3 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.1 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.2.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.1.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.8 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.7 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.6 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.5 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.4 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.3 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.2 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.1 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.0 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.0.rc4 lib/cloudstack-cli/commands/account.rb
cloudstack-cli-1.0.0.rc3 lib/cloudstack-cli/commands/account.rb