Sha256: f088a8db90cc1daea35259a84bf3db73ed69a95fe4ce7d77c4608b075b63f1fd
Contents?: true
Size: 1.75 KB
Versions: 30
Compression:
Stored size: 1.75 KB
Contents
# Copyright (c) 2012 National ICT Australia Limited (NICTA). # This software may be used and distributed solely under the terms of the MIT license (License). # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT. # By downloading or using this software you accept the terms and the liability disclaimer in the License. require 'hashie' require 'cocaine' # Manage Linux modules module OmfRc::Util::Mod include OmfRc::ResourceProxyDSL include Cocaine include Hashie # @!macro extend_dsl # @!macro group_request # @!macro request # @!method request_modules request :modules do CommandLine.new('lsmod').run.split("\n").map do |v| v.match(/^(\w+).+$/) && $1 end.compact.tap { |ary| ary.shift } end # @!endgroup # @!macro group_configure # # Load additional modules # # @param value name of the module to load # @!macro configure # @!method configure_load_module configure :load_module do |resource, value| raise ArgumentError, "Please provide at least module name" if value.name.nil? flags_string = nil if !value.flags.nil? if value.flags.kind_of?(Hash) flags_string = value.flags.keys.map do |k| "--#{k} #{value.flags[k]}" end.join(" ") else raise ArgumentError, "Please provide modprobe flags as a hash" end end if value.unload CommandLine.new("modprobe", "-r :mod_names", :mod_names => [value.unload].flatten.join(' ')).run end CommandLine.new("modprobe", ":flags :mod_name :module_parameters", :mod_name => value.name.to_s, :flags => flags_string, :module_parameters => value.mod_params.to_s).run "#{value.name} loaded" end # @!endgroup end
Version data entries
30 entries across 30 versions & 1 rubygems