Sha256: 20f99a0af14582909fe99806a779d1550af7b30ca9c54328a733632a950f0396

Contents?: true

Size: 1.06 KB

Versions: 24

Compression:

Stored size: 1.06 KB

Contents

require 'puppet/settings/base_setting'

# A setting that represents a scheduling priority, and evaluates to an
# OS-specific priority level.
class Puppet::Settings::PrioritySetting < Puppet::Settings::BaseSetting
  PRIORITY_MAP =
    if Puppet::Util::Platform.windows?
      require 'win32/process'
      {
        :high    => Process::HIGH_PRIORITY_CLASS,
        :normal  => Process::NORMAL_PRIORITY_CLASS,
        :low     => Process::BELOW_NORMAL_PRIORITY_CLASS,
        :idle    => Process::IDLE_PRIORITY_CLASS
      }
    else
      {
        :high    => -10,
        :normal  => 0,
        :low     => 10,
        :idle    => 19
      }
    end

  def type
    :priority
  end

  def munge(value)
    return unless value

    case
    when value.is_a?(Integer)
      value
    when (value.is_a?(String) and value =~ /\d+/)
      value.to_i
    when (value.is_a?(String) and PRIORITY_MAP[value.to_sym])
      PRIORITY_MAP[value.to_sym]
    else
      raise Puppet::Settings::ValidationError, "Invalid priority format '#{value.inspect}' for parameter: #{@name}"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
puppet-3.6.2 lib/puppet/settings/priority_setting.rb
puppet-3.6.2-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.6.1 lib/puppet/settings/priority_setting.rb
puppet-3.6.1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.6.0 lib/puppet/settings/priority_setting.rb
puppet-3.6.0-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.6.0.rc1 lib/puppet/settings/priority_setting.rb
puppet-3.6.0.rc1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.5.1 lib/puppet/settings/priority_setting.rb
puppet-3.5.1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.5.1.rc1 lib/puppet/settings/priority_setting.rb
puppet-3.5.1.rc1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc3 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc3-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc2 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc2-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc1 lib/puppet/settings/priority_setting.rb
puppet-3.5.0.rc1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-3.4.3 lib/puppet/settings/priority_setting.rb
puppet-3.4.2 lib/puppet/settings/priority_setting.rb