Sha256: 52ba7fc8c8bad321f954bf674d2af229d66f19837e653358eeb02f25ee38ea9e

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 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"
  def list
    projects = client.list_projects(listall: true)
    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

  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

9 entries across 9 versions & 1 rubygems

Version Path
cloudstack-cli-1.0.4 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.3 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.2 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.1 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.0 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.0.rc4 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.0.rc3 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.0.rc2 lib/cloudstack-cli/commands/project.rb
cloudstack-cli-1.0.0.rc1 lib/cloudstack-cli/commands/project.rb