Class: Specinfra::HostInventory::Kernel

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/host_inventory/kernel.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
# File 'lib/specinfra/host_inventory/kernel.rb', line 4

def get
  kernel = {}
  kernel['machine'] = backend.os_info[:arch]

  cmd = backend.command.get(:get_inventory_kernel)
  ret = backend.run_command(cmd)
  if ret.exit_status == 0
    kernel = kernel.merge(parse_uname(ret.stdout))
  end
  kernel
end

#parse_uname(ret) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/specinfra/host_inventory/kernel.rb', line 16

def parse_uname(ret)
  match = ret.match(/^(\w+) (((\d+\.\d+)\.\d+).*)$/)
  if match
    name, release, version, major = match.captures
    Hash['name', name, "release", release, "version", version, "version_major", major]
  else
    nil
  end
end