Sha256: 2c077c90c081f6cfc9b67dec7e23194f62b47974edad90a400a0679796304211

Contents?: true

Size: 1016 Bytes

Versions: 90

Compression:

Stored size: 1016 Bytes

Contents

module BeakerHostGenerator
  # Utility functions for supporting CI.next and the AlwaysBeScheduling hypervisor.
  module AbsSupport
    module_function

    # Given an existing, fully-specified host configuration, count the number of
    # hosts using each template, and return a map of template name to host count.
    #
    # For example, given the following config (parts omitted for brevity):
    #    {"HOSTS"=>
    #     {"centos6-64-1"=>
    #        {"template"=>"centos-6-x86_64", ...},
    #      "redhat7-64-1"=>
    #        {"template"=>"redhat-7-x86_64", ...},
    #      "centos6-64-2"=>
    #        {"template"=>"centos-6-x86_64", ...}},
    #     ...
    #    }}
    #
    # Returns the following map:
    #     {"centos-6-x86_64"=>2, "redhat-7-x86_64"=>1}
    #
    def extract_templates(config)
      templates_hosts = config['HOSTS'].values.group_by { |h| h['template'] }
      templates_hosts.each do |template, hosts|
        templates_hosts[template] = hosts.count
      end
    end
  end
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
beaker-hostgenerator-1.1.15 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.14 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.13 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.12 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.11 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.10 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.9 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.8 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.7 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.6 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.5 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.4 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.3 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.2 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.1 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.1.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.0.2 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.0.1 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-1.0.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-0.10.3 lib/beaker-hostgenerator/abs_support.rb