Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'xenhvm' for AWS instances #2758

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/facter/facts/linux/cloud/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def call_the_resolver
when 'hyperv'
metadata = Facter::Resolvers::Az.resolve(:metadata)
'azure' unless metadata.nil? || metadata.empty?
when 'kvm', 'xen'
when 'kvm', 'xen', 'xenhvm'
metadata = Facter::Resolvers::Ec2.resolve(:metadata)
'aws' unless metadata.nil? || metadata.empty?
when 'gce'
Expand Down
25 changes: 25 additions & 0 deletions spec/facter/facts/linux/cloud/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@
end
end

describe 'when on xenhvm' do
before do
allow(Facter::Resolvers::Ec2).to receive(:resolve).with(:metadata).and_return(value)
allow(Facter::Util::Facts::Posix::VirtualDetector).to receive(:platform).and_return('xenhvm')
end

describe 'Ec2 data exists and aws fact is set' do
let(:value) { { 'some' => 'fact' } }

it 'Testing things' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'cloud.provider', value: 'aws')
end
end

context 'when Ec2 data does not exist nil is returned' do
let(:value) { {} }

it 'returns nil' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'cloud.provider', value: nil)
end
end
end

describe 'when on gce' do
before do
allow(Facter::Resolvers::Gce).to receive(:resolve).with(:metadata).and_return(value)
Expand Down