Sha256: e1eef014671c2ca7da2115e5db31639663e9e375534c277a39953600ea53b590

Contents?: true

Size: 1.2 KB

Versions: 367

Compression:

Stored size: 1.2 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 'puppet/util/windows/process'
      {
        :high    => Puppet::Util::Windows::Process::HIGH_PRIORITY_CLASS,
        :normal  => Puppet::Util::Windows::Process::NORMAL_PRIORITY_CLASS,
        :low     => Puppet::Util::Windows::Process::BELOW_NORMAL_PRIORITY_CLASS,
        :idle    => Puppet::Util::Windows::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}' for parameter: %{name}") % { value: value.inspect, name: @name }
    end
  end
end

Version data entries

367 entries across 367 versions & 2 rubygems

Version Path
puppet-6.29.0 lib/puppet/settings/priority_setting.rb
puppet-6.29.0-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.29.0-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.29.0-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-6.28.0 lib/puppet/settings/priority_setting.rb
puppet-6.28.0-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.28.0-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.28.0-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-6.27.0 lib/puppet/settings/priority_setting.rb
puppet-6.27.0-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.27.0-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.27.0-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-6.26.0 lib/puppet/settings/priority_setting.rb
puppet-6.26.0-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.26.0-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.26.0-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-6.25.1 lib/puppet/settings/priority_setting.rb
puppet-6.25.1-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.25.1-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-6.25.1-universal-darwin lib/puppet/settings/priority_setting.rb