Class: Inspec::Resources::FileSystemResource
- Inherits:
-
Object
- Object
- Inspec::Resources::FileSystemResource
- Defined in:
- lib/resources/filesystem.rb
Instance Attribute Summary collapse
-
#partition ⇒ Object
readonly
Returns the value of attribute partition.
Instance Method Summary collapse
-
#initialize(partition) ⇒ FileSystemResource
constructor
A new instance of FileSystemResource.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(partition) ⇒ FileSystemResource
Returns a new instance of FileSystemResource.
13 14 15 |
# File 'lib/resources/filesystem.rb', line 13 def initialize(partition) @partition = partition end |
Instance Attribute Details
#partition ⇒ Object (readonly)
Returns the value of attribute partition.
11 12 13 |
# File 'lib/resources/filesystem.rb', line 11 def partition @partition end |
Instance Method Details
#size ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/resources/filesystem.rb', line 17 def size @size ||= begin cmd = inspec.command("df #{partition} --output=size") raise Inspec::Exceptions::ResourceFailed, "Unable to get available space for partition #{partition}" if cmd.stdout.nil? || cmd.stdout.empty? || !cmd.exit_status.zero? value = cmd.stdout.gsub(/\dK-blocks[\r\n]/, '').strip value.to_i end end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/resources/filesystem.rb', line 27 def to_s "Filesystem #{partition}" end |