diff --git a/lib/resources/limits_conf.rb b/lib/resources/limits_conf.rb index a0b6550b8..47b66440d 100644 --- a/lib/resources/limits_conf.rb +++ b/lib/resources/limits_conf.rb @@ -4,10 +4,10 @@ require 'utils/simpleconfig' -class LimitsConf < Vulcano::Resource +class LimitsConf < Vulcano.resource(1) + name 'limits_conf' def initialize(path) - @runner = Specinfra::Runner @conf_path = path @files_contents = {} @content = nil @@ -26,11 +26,12 @@ class LimitsConf < Vulcano::Resource def read_content # read the file - if !@runner.check_file_is_file(@conf_path) + file = @vulcano.file(@conf_path) + if !file.is_file? return skip_resource "Can't find file \"#{@conf_path}\"" end - @content = read_file(@conf_path) - if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0 + @content = file.contents + if @content.empty? && file.size > 0 return skip_resource "Can't read file \"#{@conf_path}\"" end # parse the file @@ -42,15 +43,4 @@ class LimitsConf < Vulcano::Resource @content end - def read_file(path) - @files_contents[path] ||= @runner.get_file_content(path).stdout - end end - -module Serverspec::Type - def limits_conf(path = nil) - @limits_conf ||= {} - dpath = path || '/etc/security/limits.conf' - @limits_conf[dpath] ||= LimitsConf.new(dpath) - end -end \ No newline at end of file diff --git a/lib/resources/login_def.rb b/lib/resources/login_def.rb index 1b730ef86..a1cfcbd1d 100644 --- a/lib/resources/login_def.rb +++ b/lib/resources/login_def.rb @@ -4,10 +4,10 @@ require 'utils/simpleconfig' -class LoginDef < Vulcano::Resource +class LoginDef < Vulcano.resource(1) + name 'login_defs' def initialize(path = nil) - @runner = Specinfra::Runner @conf_path = path || '/etc/login.defs' @files_contents = {} @content = nil @@ -26,11 +26,12 @@ class LoginDef < Vulcano::Resource def read_content # read the file - if !@runner.check_file_is_file(@conf_path) + file = @vulcano.file(@conf_path) + if !file.is_file? return skip_resource "Can't find file \"#{@conf_path}\"" end - @content = read_file(@conf_path) - if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0 + @content = file.contents + if @content.empty? && file.size > 0 return skip_resource "Can't read file \"#{@conf_path}\"" end # parse the file @@ -41,13 +42,4 @@ class LoginDef < Vulcano::Resource @content end - def read_file(path) - @files_contents[path] ||= @runner.get_file_content(path).stdout - end end - -module Serverspec::Type - def login_def(path = nil) - LoginDef.new(path) - end -end \ No newline at end of file diff --git a/lib/vulcano/resources.rb b/lib/vulcano/resources.rb index d1372a602..8d13696a8 100644 --- a/lib/vulcano/resources.rb +++ b/lib/vulcano/resources.rb @@ -11,8 +11,8 @@ require 'vulcano/resource' # require 'resources/file' # require 'resources/group_policy' # require 'resources/inetd_conf' -# require 'resources/limits_conf' -# require 'resources/login_def' +require 'resources/limits_conf' +require 'resources/login_def' require 'resources/mysql' require 'resources/mysql_conf' require 'resources/mysql_session'