summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-11-18 14:36:13 -0800
committerTim Smith <tsmith84@gmail.com>2020-11-18 15:21:54 -0800
commit250f0f14464b63c5c287e948b0e03cc008981a2b (patch)
treeb5cd0bd549ec6a1e34417ccd176e361b5c00cafb
parentc7ed4c4250382017274a763fbeed1a7ef1380c27 (diff)
downloadohai-250f0f14464b63c5c287e948b0e03cc008981a2b.tar.gz
Gather wpar state
This is an important thing to know about the wpars Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/aix/virtualization.rb5
-rw-r--r--spec/unit/plugins/aix/virtualization_spec.rb7
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/ohai/plugins/aix/virtualization.rb b/lib/ohai/plugins/aix/virtualization.rb
index cd724df6..e5b2b682 100644
--- a/lib/ohai/plugins/aix/virtualization.rb
+++ b/lib/ohai/plugins/aix/virtualization.rb
@@ -40,8 +40,11 @@ Ohai.plugin(:Virtualization) do
so = shell_out("lswpar -L").stdout.scan(/={65}.*?(?:EXPORTED\n\n)+/m)
wpars = Mash.new
so.each do |wpar|
- wpar_name = wpar.lines[1].chomp
+ wpar_heading = wpar.lines[1].split
+ wpar_name = wpar_heading[0]
+
wpars[wpar_name] = Mash.new
+ wpars[wpar_name][:state] = wpar_heading[2].downcase
wpar.scan(/^[A-Z]{4,}.*?[A-Z\:0-9]$.*?\n\n/m).each do |section|
diff --git a/spec/unit/plugins/aix/virtualization_spec.rb b/spec/unit/plugins/aix/virtualization_spec.rb
index d7305f9a..3386ce18 100644
--- a/spec/unit/plugins/aix/virtualization_spec.rb
+++ b/spec/unit/plugins/aix/virtualization_spec.rb
@@ -137,7 +137,7 @@ describe Ohai::System, "AIX virtualization plugin" do
/dev/nvram pseudo EXPORTED
=================================================================
- fluttershy-5c969f - Active
+ fluttershy-5c969f - Defined
=================================================================
GENERAL
Type: S
@@ -264,6 +264,11 @@ describe Ohai::System, "AIX virtualization plugin" do
plugin[:virtualization][:wpars]["fluttershy-5c969f"]
end
+ it "detects WPAR states" do
+ expect(wpar1[:state]).to eq("active")
+ expect(wpar2[:state]).to eq("defined")
+ end
+
it "detects all WPARs present (2)" do
expect(plugin[:virtualization][:wpars].length).to eq(2)
end