Sha256: 34e78d362be2b94b7efc7a64356f8de874f6d260f01afb1d418ba9eef4cd4c4c
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 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}) puts "No account with name #{name} found." else account = account.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 [NAME]', 'list accounts (by name)' def list(name = nil) accounts = client.list_accounts({name: name}) if accounts.size < 1 puts "No accounts found." else table = [["Name", "Type", "Domain"]] accounts.each do |account| table << [account['name'], TYPES[account['accounttype']], account['domain']] end print_table table say "Total number of accounts: #{accounts.size}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cloudstack-cli-0.12.2 | lib/cloudstack-cli/commands/account.rb |
cloudstack-cli-0.12.1 | lib/cloudstack-cli/commands/account.rb |
cloudstack-cli-0.12.0 | lib/cloudstack-cli/commands/account.rb |