Class: Specinfra::HostInventory::Ohai

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/host_inventory/ohai.rb

Instance Method Summary collapse

Methods inherited from Base

#backend, #initialize

Constructor Details

This class inherits a constructor from Specinfra::HostInventory::Base

Instance Method Details

#getObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/specinfra/host_inventory/ohai.rb', line 4

def get
  begin
    require 'json'
  rescue LoadError
    return nil
  end

  begin
    ret = backend.run_command('ohai --log_level error')
  rescue StandardError
    nil
  end

  ret.exit_status.zero? ? JSON.parse(ret.stdout) : nil
end