class Project

Public Instance Methods

list() click to toggle source
   # File lib/cloudstack-cli/commands/project.rb
19 def list
20   resolve_domain
21   projects = client.list_projects(options.merge listall: true)
22   if projects.size < 1
23     puts "No projects found."
24   else
25     case options[:format].to_sym
26     when :yaml
27       puts({projects: projects}.to_yaml)
28     when :json
29       puts JSON.pretty_generate(projects: projects)
30     else
31       table = [%w(Name Displaytext VMs CPU Memory Domain)]
32       projects.each do |project|
33         table << [
34           project['name'],
35           project['displaytext'],
36           project['vmtotal'],
37           project['cputotal'],
38           project['memorytotal'] / 1024,
39           project['domain']
40         ]
41       end
42       print_table(table)
43       say "Total number of projects: #{projects.count}"
44     end
45   end
46 end
list_accounts(name) click to toggle source
   # File lib/cloudstack-cli/commands/project.rb
49 def list_accounts(name)
50   unless project = client.list_projects(name: name, listall: true).first
51     say "Error: No project with name '#{name}' found.", :red
52   else
53     accounts = client.list_project_accounts(project_id: project['id'])
54     if accounts.size < 1
55       say "No project accounts found."
56     else
57       table = [%w(Account-Name Account-Type Role Domain)]
58       accounts.each do |account|
59         table << [
60           account['account'],
61           Account::TYPES[account['accounttype']],
62           account['role'],
63           account['domain']
64         ]
65       end
66       print_table table
67       say "Total number of project accounts: #{accounts.size}"
68     end
69   end
70 end
show(name) click to toggle source
   # File lib/cloudstack-cli/commands/project.rb
 4 def show(name)
 5   unless project = client.list_projects(name: name, listall: true).first
 6     say "Error: No project with name '#{name}' found.", :red
 7   else
 8     table = project.map do |key, value|
 9       [ set_color("#{key}", :yellow), "#{value}" ]
10     end
11     print_table table
12   end
13 end