diff options
author | Tim Smith <tsmith@chef.io> | 2020-11-18 15:39:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 15:39:44 -0800 |
commit | 6d7f25f9f2b9bcbc570e7184447fe1f04d2df1e0 (patch) | |
tree | b5cd0bd549ec6a1e34417ccd176e361b5c00cafb | |
parent | dff33881402519b6d4a49cb64229ad46edbc8f96 (diff) | |
parent | 250f0f14464b63c5c287e948b0e03cc008981a2b (diff) | |
download | ohai-6d7f25f9f2b9bcbc570e7184447fe1f04d2df1e0.tar.gz |
Merge pull request #1576 from chef/aix_virtualization
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/aix/virtualization.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/aix/virtualization_spec.rb | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/ohai/plugins/aix/virtualization.rb b/lib/ohai/plugins/aix/virtualization.rb index c98d956e..e5b2b682 100644 --- a/lib/ohai/plugins/aix/virtualization.rb +++ b/lib/ohai/plugins/aix/virtualization.rb @@ -32,8 +32,7 @@ Ohai.plugin(:Virtualization) do virtualization[:lpar_name] = lpar_name end - so = shell_out("uname -W") - wpar_no = so.stdout.split($/)[0] + wpar_no = shell_out("uname -W").stdout.chomp if wpar_no.to_i > 0 virtualization[:wpar_no] = wpar_no else @@ -41,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].split[0] + 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 |