summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-10-13 15:32:30 -0700
committerClaire McQuin <claire@getchef.com>2014-10-13 15:32:30 -0700
commitb1c85278ce700f92ac81bdd5f7793feeb905cfb0 (patch)
treee338b8f255464134dcbc41d3d08e192bb4c71787
parentc2e1596fe2844fb22bebb96b4908bd0d8b6fcd35 (diff)
parent7eaec0d39d6f030d077f87b41a416ef6fe73a764 (diff)
downloadohai-b1c85278ce700f92ac81bdd5f7793feeb905cfb0.tar.gz
Merge branch 'patch-1' of github.com:nshahzad/ohai into nshahzad-patch-1
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb2
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index 49d01565..6a9c9fa2 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -137,7 +137,7 @@ Ohai.plugin(:Virtualization) do
# Detect Linux-VServer
if File.exists?("/proc/self/status")
proc_self_status = File.read("/proc/self/status")
- vxid = proc_self_status.match(/^(s_context|VxID): (\d+)$/)
+ vxid = proc_self_status.match(/^(s_context|VxID): *(\d+)$/)
if vxid and vxid[2]
virtualization[:system] = "linux-vserver"
if vxid[2] == "0"
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index 890c425d..77a810a0 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -229,6 +229,15 @@ VBOX
@plugin[:virtualization][:role].should == "host"
@plugin[:virtualization][:systems]['linux-vserver'].should == "host"
end
+
+ it "should set Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
+ File.should_receive(:exists?).with("/proc/self/status").and_return(true)
+ File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
+ @plugin.run
+ @plugin[:virtualization][:system].should == "linux-vserver"
+ @plugin[:virtualization][:role].should == "host"
+ @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
+ end
it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
File.should_receive(:exists?).with("/proc/self/status").and_return(true)