diff --git a/lib/facter/facts/linux/cloud/provider.rb b/lib/facter/facts/linux/cloud/provider.rb index 38af049cde..1e16a19aef 100644 --- a/lib/facter/facts/linux/cloud/provider.rb +++ b/lib/facter/facts/linux/cloud/provider.rb @@ -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' diff --git a/spec/facter/facts/linux/cloud/provider_spec.rb b/spec/facter/facts/linux/cloud/provider_spec.rb index 694ec014e4..0e32fbb757 100644 --- a/spec/facter/facts/linux/cloud/provider_spec.rb +++ b/spec/facter/facts/linux/cloud/provider_spec.rb @@ -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)