Parent

OpenShift::Utils::Cgroups::Attrs

Public Class Methods

new(uuid) click to toggle source
# File lib/openshift-origin-node/utils/cgroups.rb, line 12
def initialize(uuid)
  @uuid = uuid
  @cgpath = "/openshift/#{uuid}"

  out, err, rc = OpenShift::Utils::oo_spawn("cgget -a #{@cgpath} >/dev/null")
  if rc != 0
    raise ValueError, "User does not exist in cgroups: #{@uuid}"
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/openshift-origin-node/utils/cgroups.rb, line 54
def [](key)
  fetch(key)
end
[]=(key, value) click to toggle source
# File lib/openshift-origin-node/utils/cgroups.rb, line 58
def []=(key, value)
  store(key, value)
end
fetch(key) click to toggle source
# File lib/openshift-origin-node/utils/cgroups.rb, line 22
def fetch(key)
  out, err, rc = OpenShift::Utils::oo_spawn("cgget -n -v -r #{key} #{@cgpath}")
  case rc
  when 0
    return out.strip
  when @@RET_NO_USER
    raise RuntimeError, "User no longer exists in cgroups: #{@uuid}"
  when @@RET_NO_VARIABLE
    raise KeyError, "Cgroups parameter not found: #{key}"
  when @@RET_NO_CONTROLLER
    raise KeyError, "Cgroups controller not found for: #{key}"
  else
    raise RuntimeError, "Cgroups error: #{err}"
  end
end
store(key, value) click to toggle source
# File lib/openshift-origin-node/utils/cgroups.rb, line 38
def store(key, value)
  out, err, rc = OpenShift::Utils::oo_spawn("cgset -r #{key}=#{value} #{@cgpath}")
  case rc
  when 0
    return value
  when @@RET_NO_USER
    raise RuntimeError, "User no longer exists in cgroups: #{@uuid}"
  when @@RET_NO_VARIABLE
    raise KeyError, "Cgroups parameter missing or cannot be set to value: #{key} = #{value}"
  when @@RET_NO_CONTROLLER
    raise KeyError, "Cgroups controller not found for: #{key}"
  else
    raise RuntimeError, "Cgroups error: #{err}"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.