Sha256: 015c06e79cb0c0c56d9aa534ad5862e740a677c55e742951c24fc05e1ccf1a70
Contents?: true
Size: 1.06 KB
Versions: 5
Compression:
Stored size: 1.06 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, listall: true).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
5 entries across 5 versions & 1 rubygems