class Account
Constants
- TYPES
Public Instance Methods
list()
click to toggle source
# File lib/cloudstack-cli/commands/account.rb 26 def list 27 accounts = client.list_accounts(listall: true) 28 if accounts.size < 1 29 puts "No accounts found." 30 else 31 case options[:format].to_sym 32 when :yaml 33 puts({accounts: accounts}.to_yaml) 34 when :json 35 puts JSON.pretty_generate(accounts: accounts) 36 else 37 table = [%w(Name Type Domain State)] 38 accounts.each do |account| 39 table << [ 40 account['name'], 41 TYPES[account['accounttype']], 42 account['domain'], 43 account['state'] 44 ] 45 end 46 print_table table 47 say "Total number of accounts: #{accounts.size}" 48 end 49 end 50 end
show(name)
click to toggle source
# File lib/cloudstack-cli/commands/account.rb 10 def show(name) 11 unless account = client.list_accounts(name: name, listall: true).first 12 say "No account named \"#{name}\" found.", :red 13 else 14 account.delete 'user' 15 account['accounttype'] = "#{account['accounttype']} (#{TYPES[account['accounttype']]})" 16 table = account.map do |key, value| 17 [ set_color("#{key}", :yellow), "#{value}" ] 18 end 19 print_table table 20 end 21 end