Sha256: 6d98f424c47bbeb5143afcd5f7d6757aa2e2886215a807282fe0ec7af90c6f6c

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

class AffinityGroup < CloudstackCli::Base

  desc 'list', 'list affinity groups'
  option :account
  option :name
  option :type
  option :listall, type: :boolean, default: true
  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

13 entries across 13 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/affinity_group.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/affinity_group.rb