Sha256: da5627a5815ef22a25aa05fe2400fbf0ea5945b328cf6e25ab9c9f8ddea2550b

Contents?: true

Size: 1.16 KB

Versions: 214

Compression:

Stored size: 1.16 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.inspect}' for parameter: #{@name}"
    end
  end
end

Version data entries

214 entries across 214 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/settings/priority_setting.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/settings/priority_setting.rb
puppet-4.10.12 lib/puppet/settings/priority_setting.rb
puppet-4.10.12-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.12-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.12-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-4.10.11 lib/puppet/settings/priority_setting.rb
puppet-4.10.11-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.11-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.11-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-4.10.10 lib/puppet/settings/priority_setting.rb
puppet-4.10.10-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.10-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.10-universal-darwin lib/puppet/settings/priority_setting.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/settings/priority_setting.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/settings/priority_setting.rb
puppet-4.10.9 lib/puppet/settings/priority_setting.rb
puppet-4.10.9-x86-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.9-x64-mingw32 lib/puppet/settings/priority_setting.rb
puppet-4.10.9-universal-darwin lib/puppet/settings/priority_setting.rb