summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@getchef.com>2014-05-15 08:21:20 -0700
committerBryan McLellan <btm@getchef.com>2014-05-15 08:21:20 -0700
commit5d161814a8c195eed9b93c675d156b62dd41ad30 (patch)
tree4ae887c5fcd571dd9840da6c166d31c440b3f8ca
parent368694fb7adf7c109d1a2558462678c77a74f70d (diff)
parente0a11bb5200179e011a6a4badd70ac88ca1d4526 (diff)
downloadohai-5d161814a8c195eed9b93c675d156b62dd41ad30.tar.gz
Merge branch 'OHAI-575'
-rw-r--r--lib/ohai/plugins/freebsd/virtualization.rb4
-rw-r--r--spec/unit/plugins/freebsd/virtualization_spec.rb22
2 files changed, 11 insertions, 15 deletions
diff --git a/lib/ohai/plugins/freebsd/virtualization.rb b/lib/ohai/plugins/freebsd/virtualization.rb
index aedcb694..bad34fd2 100644
--- a/lib/ohai/plugins/freebsd/virtualization.rb
+++ b/lib/ohai/plugins/freebsd/virtualization.rb
@@ -54,7 +54,7 @@ Ohai.plugin(:Virtualization) do
# Detect KVM/QEMU from cpu, report as KVM
# hw.model: QEMU Virtual CPU version 0.9.1
so = shell_out("sysctl -n hw.model")
- if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
+ if so.stdout.split($/)[0] =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
virtualization[:system] = "kvm"
virtualization[:role] = "guest"
end
@@ -83,7 +83,7 @@ Ohai.plugin(:Virtualization) do
when /Manufacturer: VMware/
found_virt_manufacturer = "vmware"
when /Product Name: VMware Virtual Platform/
- if found_virt_manufacturer == "vmware"
+ if found_virt_manufacturer == "vmware"
virtualization[:system] = "vmware"
virtualization[:role] = "guest"
end
diff --git a/spec/unit/plugins/freebsd/virtualization_spec.rb b/spec/unit/plugins/freebsd/virtualization_spec.rb
index ccefdd8f..a2c374f1 100644
--- a/spec/unit/plugins/freebsd/virtualization_spec.rb
+++ b/spec/unit/plugins/freebsd/virtualization_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD virtualization plugin" do
@@ -47,7 +46,6 @@ describe Ohai::System, "FreeBSD virtualization plugin" do
end
end
-
context "when on a virtualbox guest" do
before do
@vbox_guest = <<-OUT
@@ -55,7 +53,7 @@ Id Refs Address Size Name
1 40 0xffffffff80100000 d20428 kernel
7 3 0xffffffff81055000 41e88 vboxguest.ko
OUT
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, @vbox_guest, ""))
+ @plugin.stub(:shell_out).with("#{ Ohai.abs_path("/sbin/kldstat")}").and_return(mock_shell_out(0, @vbox_guest, ""))
end
it "detects we are a guest" do
@@ -84,16 +82,14 @@ OUT
context "when on a QEMU guest" do
it "detects we are a guest" do
- @qemu_guest = 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)'
- @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, @qemu_guest, ""))
- @plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
+ [ 'Common KVM processor', 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', 'Common 32-bit KVM processor'].each do |kvm_string|
+ @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
+ @plugin.run
+ @plugin[:virtualization][:system].should == "kvm"
+ @plugin[:virtualization][:role].should == "guest"
+ end
end
end
# TODO upfactor tests from linux virtualization plugin for dmidecode
end
-
-
-