Class: Project

Inherits:
CloudstackCli::Base show all
Defined in:
lib/cloudstack-cli/commands/project.rb

Constant Summary

Constants included from CloudstackCli::Helper

CloudstackCli::Helper::ASYNC_STATES

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #print_job_status, #print_options, #update_job_status, #watch_jobs

Instance Method Details

#listObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cloudstack-cli/commands/project.rb', line 16

def list
  projects = client.list_projects
  if projects.size < 1
    puts "No projects found."
  else
    table = [["Name", "Displaytext", "Domain"]]
    projects.each do |project|
      table << [project['name'], project['displaytext'], project['domain']]
    end
    print_table(table)
    say "Total number of projects: #{projects.count}"
  end
end

#list_accounts(name) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cloudstack-cli/commands/project.rb', line 31

def list_accounts(name)
  unless project = client.get_project(name)
    say "No project with name #{name} found."
  else
    accounts = client.list_project_accounts(project['id'], options)
    if accounts.size < 1
      say "No project accounts found."
    else
      table = [%w(Name Type Domain State)]
      accounts.each do ||
        table << [
          ['name'],
          TYPES[['accounttype']],
          ['domain'],
          ['state']
        ]
      end
      print_table table
      say "Total number of project accounts: #{accounts.size}"
      print_table table
    end
  end
end

#show(name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/cloudstack-cli/commands/project.rb', line 4

def show(name)
  unless project = client.get_project(name)
    puts "No project with name #{name} found."
  else
    table = project.map do |key, value|
      [ set_color("#{key}", :yellow), "#{value}" ]
    end
    print_table table
  end
end