Skip to content
Merged
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
6 changes: 4 additions & 2 deletions lib/facter/facts/linux/ec2_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ def call_the_resolver
private

def aws_hypervisors?
virtual = check_virt_what || check_xen || check_product_name || check_bios_vendor || check_lspci
virtual =~ /kvm|xen|aws/
end

virtual == 'kvm' || virtual =~ /xen/
def virtual
check_virt_what || check_xen || check_product_name || check_bios_vendor || check_lspci
end

def check_virt_what
Expand Down
20 changes: 20 additions & 0 deletions spec/facter/facts/linux/ec2_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,25 @@
end
end
end

context 'when hypervisor is aws' do
let(:hypervisor) { 'aws' }
let(:value) { { 'info' => 'value' } }

it 'calls Facter::Resolvers::VirtWhat' do
fact.call_the_resolver
expect(Facter::Resolvers::VirtWhat).to have_received(:resolve).with(:vm)
end

it 'calls Facter::Resolvers::Ec2' do
fact.call_the_resolver
expect(Facter::Resolvers::Ec2).to have_received(:resolve).with(:metadata)
end

it 'returns ec2 userdata fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'ec2_metadata', value: value)
end
end
end
end