Sha256: 6278c06daad7482a47fa458a34bdf6485affbea770d87e58bcbde840941d5881

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'beaker-hostgenerator/data'
require 'beaker-hostgenerator/data/vmpooler'
require 'deep_merge'

module BeakerHostGenerator
  module Utils
    include BeakerHostGenerator::Data
    include BeakerHostGenerator::Data::Vmpooler

    def pe_dir(version, family)
      # If our version is the same as our family, we're installing a
      # released version. Use the archive path. Otherwise, we want to use
      # the development build path.
      if version && family
        if version == family
          return "http://enterprise.delivery.puppetlabs.net/archives/releases/#{family}/"
        else
          return "http://enterprise.delivery.puppetlabs.net/#{family}/ci-ready"
        end
      end
    end

    def fixup_node(cfg)
      # PE 2.8 doesn't exist for EL 4. We use 2.0 instead.
      if cfg['platform'] =~ /el-4/ and pe_version =~ /2\.8/
        cfg['pe_ver'] = "2.0.3"
      end
    end

    def dump_hosts(hosts, path)
      config = {}
      config.deep_merge! BASE_CONFIG
      config.deep_merge! VMPOOLER_CONFIG

      hosts.each do |host|
        config['HOSTS'][host.node_name] = {
          'roles' => host['roles'],
          'hypervisor' => "#{host['hypervisor']}",
          'platform' => "#{host['platform']}",
        }
      end

      File.open(path, 'w') do |file|
        file.write(config.to_yaml)
      end
    end

    def get_platforms(hypervisor_type='vmpooler', bhg_version=0)
      case hypervisor_type
      when /vmpooler/
        osinfo = BeakerHostGenerator::Data::Vmpooler.get_osinfo(bhg_version)
      else
        raise "Invalid hypervisor #{hypervisor_type}"
      end
      return osinfo
    end

    def get_roles
      return BeakerHostGenerator::Data::ROLES
    end

    module_function :get_roles, :get_platforms, :dump_hosts, :fixup_node, :pe_dir
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
beaker-hostgenerator-0.5.0 lib/beaker-hostgenerator/util.rb
beaker-hostgenerator-0.4.0 lib/beaker-hostgenerator/util.rb