Class: Inspec::Resources::Virtualization

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

Instance Method Summary collapse

Constructor Details

#initializeVirtualization

Returns a new instance of Virtualization.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/inspec/resources/virtualization.rb', line 27

def initialize
  # TODO: no need for hashie here... in fact, no reason for a hash at all
  @virtualization_data = Hashie::Mash.new

  if inspec.os.linux?
    collect_data_linux
  elsif inspec.os.windows?
    collect_data_windows
  end

  # Allows checking for non-virtualized systems as well
  @virtualization_data[:physical] = @virtualization_data.empty?
end

Instance Method Details

#paramsObject



57
58
59
60
# File 'lib/inspec/resources/virtualization.rb', line 57

def params
  # TODO: this is broken. cannot return anything but nil
  collect_data_linux
end

#physical_system?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/inspec/resources/virtualization.rb', line 53

def physical_system?
  @virtualization_data[:physical]
end

#resource_idObject



62
63
64
# File 'lib/inspec/resources/virtualization.rb', line 62

def resource_id
  @virtualization_data[:system] || "virtualization"
end

#to_sObject



66
67
68
# File 'lib/inspec/resources/virtualization.rb', line 66

def to_s
  "Virtualization Detection"
end

#virtual_system?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/inspec/resources/virtualization.rb', line 49

def virtual_system?
  @virtualization_data[:role] == "guest"
end