Sha256: 2ac521c1e9692c9406d2960a9da940a6003afbdcd50913f8b1bc161f5d31f44c

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

Contents

class AffinityGroup < CloudstackCli::Base

  desc 'list', 'list affinity groups'
  option :account
  option :name
  option :type
  option :listall
  option :keyword
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_account
    affinity_groups = client.list_affinity_groups(options)
    if affinity_groups.size < 1
      say "No affinity groups found."
    else
      case options[:format].to_sym
      when :yaml
        puts({affinity_groups: affinity_groups}.to_yaml)
      when :json
        puts JSON.pretty_generate(affinity_groups: affinity_groups)
      else
        table = [%w(Domain Account Name, Description, VMs)]
        affinity_groups.each do |group|
          table << [
            group['domain'], group['account'],
          	group['name'], group['description'],
            group['virtualmachineIds'] ? group['virtualmachineIds'].size : nil
          ]
        end
        print_table table
        say "Total number of affinity groups: #{affinity_groups.size}"
      end
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.3 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.2 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.1 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.0 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.4.2 lib/cloudstack-cli/commands/affinity_group.rb