summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-12-20 14:23:38 +0000
committerGitHub <noreply@github.com>2016-12-20 14:23:38 +0000
commit39f4a10a6da874b66d701730d29c70873038f138 (patch)
tree30ca76d75a55fffead9d92eb4733e0338b9f68f2
parent09813a9f987946c0b195f7bfc50b6501c5ee8bff (diff)
parente4301fba2a9018d328462a4f32de1faf29babc60 (diff)
downloadohai-39f4a10a6da874b66d701730d29c70873038f138.tar.gz
Merge pull request #925 from chef/Veertu
Detect guests running on Veertu hypervisor
-rw-r--r--lib/ohai/mixin/dmi_decode.rb2
-rw-r--r--lib/ohai/plugins/windows/virtualization.rb4
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb19
-rw-r--r--spec/unit/plugins/windows/virtualization_spec.rb16
4 files changed, 41 insertions, 0 deletions
diff --git a/lib/ohai/mixin/dmi_decode.rb b/lib/ohai/mixin/dmi_decode.rb
index c56291c7..64be3371 100644
--- a/lib/ohai/mixin/dmi_decode.rb
+++ b/lib/ohai/mixin/dmi_decode.rb
@@ -42,6 +42,8 @@ module ::Ohai::Mixin::DmiDecode
return "kvm"
when /Product.*: BHYVE/
return "bhyve"
+ when /Manufacturer: Veertu/
+ return "veertu"
end
end
return nil
diff --git a/lib/ohai/plugins/windows/virtualization.rb b/lib/ohai/plugins/windows/virtualization.rb
index ac36b05a..16d750ea 100644
--- a/lib/ohai/plugins/windows/virtualization.rb
+++ b/lib/ohai/plugins/windows/virtualization.rb
@@ -54,6 +54,10 @@ Ohai.plugin(:Virtualization) do
virtualization[:system] = "xen"
virtualization[:role] = "guest"
virtualization[:systems][:xen] = "guest"
+ when "Veertu"
+ virtualization[:system] = "veertu"
+ virtualization[:role] = "guest"
+ virtualization[:systems][:veertu] = "guest"
end
# vmware fusion detection
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index 84870b95..da4ecf90 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -345,6 +345,25 @@ OUTPUT
expect(plugin[:virtualization][:systems][:bhyve]).to eq("guest")
end
+ it "sets veertu guest if dmidecode detects Veertu" do
+ veertu_dmidecode = <<-VEERTU
+System Information
+ Manufacturer: Veertu
+ Product Name: Veertu
+ Version: Not Specified
+ Serial Number: Not Specified
+ UUID: Not Settable
+ Wake-up Type: Power Switch
+ SKU Number: Not Specified
+ Family: Not Specified
+VEERTU
+ allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, veertu_dmidecode, ""))
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("veertu")
+ expect(plugin[:virtualization][:role]).to eq("guest")
+ expect(plugin[:virtualization][:systems][:veertu]).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
diff --git a/spec/unit/plugins/windows/virtualization_spec.rb b/spec/unit/plugins/windows/virtualization_spec.rb
index c3ac04ab..87ed4712 100644
--- a/spec/unit/plugins/windows/virtualization_spec.rb
+++ b/spec/unit/plugins/windows/virtualization_spec.rb
@@ -224,6 +224,22 @@ describe Ohai::System, "Windows virtualization platform" do
end
end
+ context "when running on veertu" do
+ it "system is veertu" do
+ allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "smbiosbiosversion" => ["Veertu"],
+ "manufacturer" => "Veertu",
+ "name" => "Default System BIOS",
+ "serialnumber" => "",
+ "version" => "Veertu - 1",
+
+ }])
+ plugin.run
+ expect(plugin[:virtualization][:system]).to eq("veertu")
+ expect(plugin[:virtualization][:role]).to eq("guest")
+ expect(plugin[:virtualization][:systems][:veertu]).to eq("guest")
+ end
+ end
+
context "when running on a hardware system" do
it "does not set virtualization attributes" do
allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [7, 11, 12, 15, 16, 17, 19, 23, 24, 25, 26, 27, 28, 29, 32, 33, 40, 42, 43],