Class: Specinfra::HostInventory::Virtualization

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/host_inventory/virtualization.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
19
20
21
22
23
24
25
# File 'lib/specinfra/host_inventory/virtualization.rb', line 4

def get
  res = {}
  ## docker 
  if backend.run_command('ls /.dockerinit').success?
    res[:system] = 'docker'
    return res
  end

  ## OpenVZ on Linux 
  if backend.run_command('test -d /proc/vz -a ! -d /proc/bc').success?
    res[:system] = 'openvz'
    return res
  end

  cmd = backend.command.get(:get_inventory_system_product_name)
  ret = backend.run_command(cmd)
  if ret.exit_status == 0
     res[:system] = parse_system_product_name(ret.stdout)   
  end 

  res 
end

#parse_system_product_name(ret) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/specinfra/host_inventory/virtualization.rb', line 27

def parse_system_product_name(ret)
  product_name = case ret
    when /.*VMware Virtual Platform/
      'vmware'
    when /.*VirtualBox/
      'vbox'
    when /.*KVM/
      'kvm'
    when /.*OpenStack/
      'openstack'
    else
      nil
  end
  product_name
end