Skip to content

Commit

Permalink
(FACT-3121) Detect Illumos (SmartOS/OmniOS) LX virtualization
Browse files Browse the repository at this point in the history
  • Loading branch information
smokris committed Jan 18, 2024
1 parent 17dbf74 commit d959b40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/facter/util/facts/posix/virtual_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module VirtualDetector
class << self
def platform
@fact_value ||= # rubocop:disable Naming/MemoizedInstanceVariableName
check_docker_lxc || check_freebsd || check_gce || retrieve_from_virt_what || \
check_vmware || check_open_vz || check_vserver || check_xen || check_other_facts || \
check_lspci || 'physical'
check_docker_lxc || check_freebsd || check_gce || check_illumos_lx || \
retrieve_from_virt_what || check_vmware || check_open_vz || check_vserver || \
check_xen || check_other_facts || check_lspci || 'physical'
end

private
Expand All @@ -24,6 +24,10 @@ def check_gce
'gce' if bios_vendor&.include?('Google')
end

def check_illumos_lx
'illumos-lx' if Facter::Resolvers::Uname.resolve(:kernelversion) == 'BrandZ virtual linux'
end

def check_vmware
Facter::Resolvers::Vmware.resolve(:vm)
end
Expand Down
13 changes: 13 additions & 0 deletions spec/facter/util/facts/posix/virtual_detector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@
end
end

context 'when illumos-lx' do
let(:value) { 'illumos-lx' }

before do
allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return('lxc')
allow(Facter::Resolvers::Uname).to receive(:resolve).with(:kernelversion).and_return('BrandZ virtual linux')
end

it 'returns illumos-lx' do
expect(detector.platform).to eq(value)
end
end

context 'when all resolvers return nil ' do
let(:vm) { 'physical' }

Expand Down

0 comments on commit d959b40

Please sign in to comment.