Sha256: 6069015cbb1af15af5e883ded351381412cdae996784a19046963af944f6283e

Contents?: true

Size: 1016 Bytes

Versions: 26

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"=>
    #     {"centos9-64-1"=>
    #        {"template"=>"centos-9-x86_64", ...},
    #      "redhat7-64-1"=>
    #        {"template"=>"redhat-7-x86_64", ...},
    #      "centos9-64-2"=>
    #        {"template"=>"centos-9-x86_64", ...}},
    #     ...
    #    }}
    #
    # Returns the following map:
    #     {"centos-9-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

26 entries across 26 versions & 1 rubygems

Version Path
beaker-hostgenerator-2.18.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.17.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.16.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.15.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.14.2 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.14.1 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.14.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.13.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.11.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.10.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.9.1 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.9.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.8.2 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.8.1 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.8.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.7.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.6.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.5.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.4.0 lib/beaker-hostgenerator/abs_support.rb
beaker-hostgenerator-2.3.0 lib/beaker-hostgenerator/abs_support.rb