Class: Puppet::Settings::PrioritySetting

Inherits:
BaseSetting show all
Defined in:
lib/puppet/settings/priority_setting.rb

Overview

A setting that represents a scheduling priority, and evaluates to an OS-specific priority level.

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from BaseSetting

#call_hook, #default, #deprecated, #desc, #name, #section, #short

Instance Method Summary collapse

Methods inherited from BaseSetting

#allowed_on_commandline?, available_call_hook_values, #call_hook_on_define?, #call_hook_on_initialize?, #completely_deprecated?, #deprecated?, #getopt_args, #has_hook?, #hook=, #initialize, #inspect, #iscreated, #iscreated?, #optparse_args, #print, #set_meta, #to_config, #value

Constructor Details

This class inherits a constructor from Puppet::Settings::BaseSetting

Instance Method Details

#munge(value) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/puppet/settings/priority_setting.rb', line 28

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

#typeObject



24
25
26
# File 'lib/puppet/settings/priority_setting.rb', line 24

def type
  :priority
end