=begin __ ___ _ _ _____ ____ __ __ \ \ / / |__ (_) |_ ___| ___| _ ___ ___ / ___| \/ | \ \ /\ / /| '_ \| | __/ _ \ |_ | | | / __|/ _ \ | | |\/| | \ V V / | | | | | || __/ _|| |_| \__ \ __/ |___| | | | \_/\_/ |_| |_|_|\__\___|_| \__,_|___/\___|\____|_| |_| Container Manager Copyright (C) 2015 David Prandzioch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =end module ResourceManagerAdapter # ResourceManager adapter for Linux class Linux # Initializes the adapter # # @raise [RuntimeError] def initialize if $container_type == 'LXC' && File.exists?($lxc_cgroup_mount_path) == false raise RuntimeError, 'no cgroup node found' end end # Finds the total amount of cpu cores # # @return [Integer] def total_cpu_cores cpu_cores = `nproc`.strip.to_i if $?.exitstatus != 0 raise RuntimeError, 'could not run nproc' end return cpu_cores end end end