Skip to content

Commit

Permalink
Merge pull request #1703 from szhuga/2.x
Browse files Browse the repository at this point in the history
[FACT-1822] Add support for EC2 instances based on the Nitro Hypervisor
  • Loading branch information
GabrielNagy authored Sep 30, 2019
2 parents 05dd0aa + a039ad7 commit 70f0e08
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/facter/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Facter.define_fact(:ec2_metadata) do
define_resolution(:rest) do
confine do
Facter.value(:virtual).match /^(xen|kvm)/
Facter.value(:virtual).match /^(xen|kvm|nitro)/
end

@querier = Facter::EC2::Metadata.new
Expand All @@ -37,7 +37,7 @@
Facter.define_fact(:ec2_userdata) do
define_resolution(:rest) do
confine do
Facter.value(:virtual).match /^(xen|kvm)/
Facter.value(:virtual).match /^(xen|kvm|nitro)/
end

@querier = Facter::EC2::Userdata.new
Expand Down
4 changes: 4 additions & 0 deletions lib/facter/util/virtual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def self.gce?
File.read("/sys/devices/virtual/dmi/id/product_name") =~ /Google/ rescue false
end

def self.nitro?
File.read("/sys/devices/virtual/dmi/id/bios_vendor") =~ /Amazon/ rescue false
end

def self.jail?
path = case Facter.value(:kernel)
when "FreeBSD" then "/sbin"
Expand Down
5 changes: 5 additions & 0 deletions lib/facter/virtual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
next Facter::Util::Virtual.kvm_type if Facter::Util::Virtual.kvm?
next "rhev" if Facter::Util::Virtual.rhev?
next "ovirt" if Facter::Util::Virtual.ovirt?
next "nitro" if Facter::Util::Virtual.nitro?

# Parse lspci
output = Facter::Util::Virtual.lspci
Expand Down Expand Up @@ -225,6 +226,10 @@
result = "xen"
end

if result.nil? and computersystem.manufacturer =~ /Amazon/
result = "nitro"
end

break
end
result ||= "physical"
Expand Down

0 comments on commit 70f0e08

Please sign in to comment.