Sha256: d5cba48153104042a0f139629df24ea097b2830934a94f54e10c15bcea54ab7a
Contents?: true
Size: 1.85 KB
Versions: 18
Compression:
Stored size: 1.85 KB
Contents
class Project < CloudstackCli::Base desc "show NAME", "show detailed infos about a project" def show(name) unless project = client.list_projects(name: name, listall: true).first say "Error: No project with name '#{name}' found.", :red else table = project.map do |key, value| [ set_color("#{key}", :yellow), "#{value}" ] end print_table table end end desc "list", "list projects" option :domain, desc: "List only resources belonging to the domain specified" def list resolve_domain projects = client.list_projects(options.merge listall: true) if projects.size < 1 puts "No projects found." else table = [%w(Name Displaytext VMs CPU Memory Domain)] projects.each do |project| table << [ project['name'], project['displaytext'], project['vmtotal'], project['cputotal'], project['memorytotal'] / 1024, project['domain'] ] end print_table(table) say "Total number of projects: #{projects.count}" end end desc "list_accounts PROJECT_NAME", "show accounts belonging to a project" def list_accounts(name) unless project = client.list_projects(name: name, listall: true).first say "Error: No project with name '#{name}' found.", :red else accounts = client.list_project_accounts(project_id: project['id']) if accounts.size < 1 say "No project accounts found." else table = [%w(Account-Name Account-Type Role Domain)] accounts.each do |account| table << [ account['account'], Account::TYPES[account['accounttype']], account['role'], account['domain'] ] end print_table table say "Total number of project accounts: #{accounts.size}" end end end end
Version data entries
18 entries across 18 versions & 1 rubygems