Class: ResourceManagerAdapter::Linux

Inherits:
Object
  • Object
show all
Defined in:
lib/wf_node_api/resource_manager_adapter/linux.rb

Overview

ResourceManager adapter for Linux

Instance Method Summary collapse

Constructor Details

#initializeLinux

Initializes the adapter

Raises:

  • (RuntimeError)


37
38
39
40
41
# File 'lib/wf_node_api/resource_manager_adapter/linux.rb', line 37

def initialize
  if $container_type == 'LXC' && File.exists?($lxc_cgroup_mount_path) == false
    raise RuntimeError, 'no cgroup node found'
  end
end

Instance Method Details

#total_cpu_coresInteger

Finds the total amount of cpu cores

Returns:

  • (Integer)


46
47
48
49
50
51
52
53
54
# File 'lib/wf_node_api/resource_manager_adapter/linux.rb', line 46

def total_cpu_cores
  cpu_cores = `nproc`.strip.to_i

  if $?.exitstatus != 0
    raise RuntimeError, 'could not run nproc'
  end

  return cpu_cores
end