Skip to content

Commit

Permalink
Merge pull request #812 from chef/bhyve
Browse files Browse the repository at this point in the history
Add detection of bhyve guests running Linux/*BSD
  • Loading branch information
tas50 committed Apr 25, 2016
2 parents c53ddb9 + 68f1fea commit 780f7c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ohai/mixin/dmi_decode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def guest_from_dmi(dmi_data)
return "openstack"
when /Manufacturer: QEMU|Product Name: (KVM|RHEV)/
return "kvm"
when /Product.*: BHYVE/
return "bhyve"
end
end
return nil
Expand Down
19 changes: 19 additions & 0 deletions spec/unit/plugins/linux/virtualization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,25 @@
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
end

it "sets bhyve guest if dmidecode detects bhyve" do
bhyve_dmidecode = <<-OUTPUT
System Information
Manufacturer:
Product Name: BHYVE
Version: 1.0
Serial Number: None
UUID: 023B323A-E139-4B36-8BC5-CEBB2469DAAA
Wake-up Type: Power Switch
SKU Number: None
Family:
OUTPUT
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, bhyve_dmidecode, ""))
plugin.run
expect(plugin[:virtualization][:system]).to eq("bhyve")
expect(plugin[:virtualization][:role]).to eq("guest")
expect(plugin[:virtualization][:systems][:bhyve]).to eq("guest")
end

it "should run dmidecode and not set virtualization if nothing is detected" do
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
plugin.run
Expand Down

0 comments on commit 780f7c5

Please sign in to comment.