Class: Inspec::Resources::UnixFileSystemResource

Inherits:
FsManagement
  • Object
show all
Defined in:
lib/inspec/resources/filesystem.rb

Instance Attribute Summary

Attributes inherited from FsManagement

#inspec

Instance Method Summary collapse

Methods inherited from FsManagement

#initialize

Constructor Details

This class inherits a constructor from Inspec::Resources::FsManagement

Instance Method Details

#info(partition) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/inspec/resources/filesystem.rb', line 101

def info(partition)
  cmd = inspec.command("df #{partition} -PT")
  if cmd.stdout.nil? || cmd.stdout.empty? || cmd.exit_status != 0
    raise Inspec::Exceptions::ResourceFailed,
          "Unable to get available space for partition #{partition}"
  end
  value = cmd.stdout.split(/\n/)[1].strip.split(" ")
  {
    name: partition,
    size_kb: value[2].to_i,
    free_kb: value[4].to_i,
    type: value[1].to_s,
  }
end