Class: Inspec::Resources::WindowsFileSystemResource

Inherits:
FsManagement
  • Object
show all
Defined in:
lib/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



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/resources/filesystem.rb', line 82

def info(partition)
  cmd = inspec.command "    $disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='\#{partition}'\"\n    $disk.Size = $disk.Size / 1GB\n    $disk | select -property DeviceID,Size,FileSystem | ConvertTo-Json\n  EOF\n\n  raise Inspec::Exceptions::ResourceSkipped, \"Unable to get available space for partition \#{partition}\" if cmd.stdout == '' || cmd.exit_status.to_i != 0\n  begin\n    fs = JSON.parse(cmd.stdout)\n  rescue JSON::ParserError => e\n    raise Inspec::Exceptions::ResourceFailed,\n          'Failed to parse JSON from Powershell. ' \\\n          \"Error: \#{e}\"\n  end\n  {\n    name: fs['DeviceID'],\n    size: fs['Size'].to_i,\n    type: fs['FileSystem'],\n  }\nend\n".gsub(/^\s*/, '')