-
Notifications
You must be signed in to change notification settings - Fork 495
Expand file tree
/
Copy pathvirtual.rb
More file actions
32 lines (25 loc) · 926 Bytes
/
virtual.rb
File metadata and controls
32 lines (25 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true
module Facts
module Macosx
class Virtual
FACT_NAME = 'virtual'
def call_the_resolver
fact_value = check_vmware || check_virtualbox || check_parallels
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
private
def check_vmware
model_identifier = Facter::Resolvers::Macosx::SystemProfiler.resolve(:model_identifier)
return 'vmware' if model_identifier&.start_with?('VMware')
end
def check_virtualbox
boot_rom_version = Facter::Resolvers::Macosx::SystemProfiler.resolve(:boot_rom_version)
return 'virtualbox' if boot_rom_version&.start_with?('VirtualBox')
end
def check_parallels
subsystem_vendor_id = Facter::Resolvers::Macosx::SystemProfiler.resolve(:subsystem_vendor_id)
return 'parallels' if subsystem_vendor_id&.start_with?('0x1ab8')
end
end
end
end