diff options
author | Isa Farnik <isa@chef.io> | 2015-11-24 18:07:48 -0800 |
---|---|---|
committer | Isa Farnik <isa@chef.io> | 2015-12-09 17:17:48 -0800 |
commit | 2434cb96bef47f6dc0ada4f3e73e98e91038c0bb (patch) | |
tree | a54acfcd3af656950c9896d08253767ffe4c09b1 | |
parent | cc6fa2431599a6e127917d310e2817a991ec985b (diff) | |
download | ohai-if/fix-aix-attrs.tar.gz |
AIX WPAR plugin improvementsif/fix-aix-attrs
collect fs info by device or mountpoint on AIX
AIX WPARs have no macaddresses
provide proper os_version on AIX
provide WPAR info for an LPAR node (AIX)
collect AIX hostnames with dashes properly
style and credit for AIX plugns
PR comment feedback re: license
accommodate WPARs in AIX fs plugin
avoid phantom CPUs on WPARs in AIX CPU plugin
avoid macaddress on WPARs in AIX networking plugin & test hostname right
test AIX platform_version right
detect WPARs on LPARs (AIX)
refactor AIX filesystem
AIX fs plugin: mount options as array
license update AIX plugins
change AIX test hostnames
provide "wpars" as a child of virtualization on AIX
reduse code resuse in AIX virt plugin
-rw-r--r-- | lib/ohai/plugins/aix/cpu.rb | 62 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/filesystem.rb | 98 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/kernel.rb | 3 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 5 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/network.rb | 10 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/os.rb | 30 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/platform.rb | 3 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/uptime.rb | 5 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/virtualization.rb | 118 | ||||
-rw-r--r-- | lib/ohai/plugins/hostname.rb | 13 | ||||
-rw-r--r-- | spec/unit/plugins/aix/cpu_spec.rb | 108 | ||||
-rw-r--r-- | spec/unit/plugins/aix/filesystem_spec.rb | 202 | ||||
-rw-r--r-- | spec/unit/plugins/aix/hostname_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/aix/kernel_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/plugins/aix/memory_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/plugins/aix/network_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/plugins/aix/os_spec.rb | 35 | ||||
-rw-r--r-- | spec/unit/plugins/aix/platform_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/plugins/aix/uptime_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/plugins/aix/virtualization_spec.rb | 272 |
20 files changed, 824 insertions, 191 deletions
diff --git a/lib/ohai/plugins/aix/cpu.rb b/lib/ohai/plugins/aix/cpu.rb index 107ca9b4..32e294dc 100644 --- a/lib/ohai/plugins/aix/cpu.rb +++ b/lib/ohai/plugins/aix/cpu.rb @@ -1,7 +1,8 @@ # # Author:: Joshua Timberman <joshua@opscode.com> # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013, Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,36 +23,41 @@ Ohai.plugin(:CPU) do collect_data(:aix) do cpu Mash.new - + cpu[:total] = shell_out("pmcycles -m").stdout.lines.length - # At least one CPU will be available, but we'll wait to increment this later. - cpu[:available] = 0 - cpudevs = shell_out("lsdev -Cc processor").stdout.lines - #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html - #on AIX number of cores and processors are considered same - cpu[:real] = cpu[:cores] = cpudevs.length - cpudevs.each.with_index do |c,i| - name, status, location = c.split - index = i.to_s - cpu[index] = Mash.new - cpu[index][:status] = status - cpu[index][:location] = location - if status =~ /Available/ - cpu[:available] += 1 - lsattr = shell_out("lsattr -El #{name}").stdout.lines - lsattr.each do |attribute| - attrib, value = attribute.split - if attrib == "type" - cpu[index][:model_name] = value - elsif attrib == "frequency" - cpu[index][:mhz] = value.to_i / (1000 * 1000) #convert from hz to MHz - else - cpu[index][attrib] = value + # The below is only relevent on an LPAR + if shell_out('uname -W').stdout.strip == "0" + + # At least one CPU will be available, but we'll wait to increment this later. + cpu[:available] = 0 + + cpudevs = shell_out("lsdev -Cc processor").stdout.lines + #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html + #on AIX number of cores and processors are considered same + cpu[:real] = cpu[:cores] = cpudevs.length + cpudevs.each.with_index do |c,i| + name, status, location = c.split + index = i.to_s + cpu[index] = Mash.new + cpu[index][:status] = status + cpu[index][:location] = location + if status =~ /Available/ + cpu[:available] += 1 + lsattr = shell_out("lsattr -El #{name}").stdout.lines + lsattr.each do |attribute| + attrib, value = attribute.split + if attrib == "type" + cpu[index][:model_name] = value + elsif attrib == "frequency" + cpu[index][:mhz] = value.to_i / (1000 * 1000) #convert from hz to MHz + else + cpu[index][attrib] = value + end end - end - # IBM is the only maker of CPUs for AIX systems. - cpu[index][:vendor_id] = "IBM" + # IBM is the only maker of CPUs for AIX systems. + cpu[index][:vendor_id] = "IBM" + end end end end diff --git a/lib/ohai/plugins/aix/filesystem.rb b/lib/ohai/plugins/aix/filesystem.rb index ac35dc2d..8b7419a9 100644 --- a/lib/ohai/plugins/aix/filesystem.rb +++ b/lib/ohai/plugins/aix/filesystem.rb @@ -1,7 +1,8 @@ # # Author:: Deepali Jagtap (<deepali.jagtap@clogeny.com>) # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,52 +22,69 @@ Ohai.plugin(:Filesystem) do provides "filesystem" - collect_data(:aix) do - fs = Mash.new + def parse_df_or_mount(shell_out) + oldie = Mash.new - # Grab filesystem data from df - so = shell_out("df -P") - so.stdout.lines.each do |line| + shell_out.lines.each do |line| + fields = line.split case line - when /^Filesystem\s+1024-blocks/ + # headers and horizontal rules to skip + when /^\s*(node|---|^Filesystem\s+1024-blocks)/ next - when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/ - filesystem = $1 - fs[filesystem] = Mash.new - fs[filesystem][:kb_size] = $2 - fs[filesystem][:kb_used] = $3 - fs[filesystem][:kb_available] = $4 - fs[filesystem][:percent_used] = $5 - fs[filesystem][:mount] = $6 + # strictly a df entry + when /^(.+?)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+\%*)\s+(.+)$/ + if $1 == "Global" + key = "#{$1}:#{$6}" + else + key = $1 + end + oldie[key] ||= Mash.new + oldie[key][:kb_size] = $2 + oldie[key][:kb_used] = $3 + oldie[key][:kb_available] = $4 + oldie[key][:percent_used] = $5 + oldie[key][:mount] = $6 + # an entry starting with 'G' or / (E.G. /tmp or /var) + when /^\s*(G.*?|\/\w)/ + if fields[0] == "Global" + key = fields[0] + ":" + fields[1] + else + key = fields[0] + end + oldie[key] ||= Mash.new + oldie[key][:mount] = fields[1] + oldie[key][:fs_type] = fields[2] + oldie[key][:mount_options] = fields[6].split(',') + # entries occupying the 'Node' column parsed here + else + key = fields[0] + ":" + fields[1] + oldie[key] ||= Mash.new + oldie[key][:mount] = fields[1] + oldie[key][:fs_type] = fields[3] + oldie[key][:mount_options] = fields[7].split(',') end end + oldie + end - # Grab mount information from /bin/mount - so = shell_out("mount") - so.stdout.lines.each do |line| - case line - when /^\s*node/ - next - when /^\s*---/ - next - when /^\s*\/\w/ - fields = line.split - filesystem = fields[0] - fs[filesystem] = Mash.new unless fs.has_key?(filesystem) - fs[filesystem][:mount] = fields[1] - fs[filesystem][:fs_type] = fields[2] - fs[filesystem][:mount_options] = fields[6] - else - fields = line.split - filesystem = fields[0] + ":" + fields[1] - fs[filesystem] = Mash.new unless fs.has_key?(filesystem) - fs[filesystem][:mount] = fields[2] - fs[filesystem][:fs_type] = fields[3] - fs[filesystem][:mount_options] = fields[7] - end + def collect_old_version(shell_outs) + mount_hash = parse_df_or_mount shell_outs[:mount] + df_hash = parse_df_or_mount shell_outs[:df_Pk] + + mount_hash.each do |key, hash| + df_hash[key].merge!(hash) if df_hash.has_key?(key) end - # Set the filesystem data - filesystem fs + mount_hash.merge(df_hash) + end + + collect_data(:aix) do + + # Cache the command output + shell_outs = Mash.new + shell_outs[:mount] = shell_out("mount").stdout + shell_outs[:df_Pk] = shell_out("df -Pk").stdout + + filesystem collect_old_version(shell_outs) end end diff --git a/lib/ohai/plugins/aix/kernel.rb b/lib/ohai/plugins/aix/kernel.rb index bf84de8c..5fe61a70 100644 --- a/lib/ohai/plugins/aix/kernel.rb +++ b/lib/ohai/plugins/aix/kernel.rb @@ -1,6 +1,7 @@ # # Author:: Joshua Timberman <joshua@opscode.com> -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index c6729ea1..9e3cf527 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -1,6 +1,7 @@ # # Author:: Joshua Timberman <joshua@opscode.com> -# Copyright:: Copyright (c) 2013, Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +28,7 @@ Ohai.plugin(:Memory) do total_in_mb, u, free_in_mb = meminfo.split memory[:total] = "#{total_in_mb.to_i * 1024}kB" memory[:free] = "#{free_in_mb.to_i * 1024}kB" - + swapinfo = shell_out("swap -s").stdout.split #returns swap info in 4K blocks memory[:swap]['total'] = "#{(swapinfo[2].to_i) * 4}kB" memory[:swap]['free'] = "#{(swapinfo[10].to_i) * 4}kB" diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb index bd4214ff..3ac01d7a 100644 --- a/lib/ohai/plugins/aix/network.rb +++ b/lib/ohai/plugins/aix/network.rb @@ -2,7 +2,7 @@ # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>) # Author:: Prabhu Das (<prabhu.das@clogeny.com>) # Author:: Isa Farnik (<isa@chef.io>) -# Copyright:: Copyright (c) 2015 Chef, Inc. +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,7 @@ Ohai.plugin(:Network) do require 'ipaddr' - provides "network", "counters/network" + provides "network", "counters/network", "macaddress" # Helpers def hex_to_dec_netmask(netmask) @@ -115,7 +115,10 @@ Ohai.plugin(:Network) do e_so = shell_out("entstat -d #{interface} | grep \"Hardware Address\"") iface[interface][:addresses] = Mash.new unless iface[interface][:addresses] e_so.stdout.lines.each do |line| - iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" } if line =~ /Hardware Address: (\S+)/ + if line =~ /Hardware Address: (\S+)/ + iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" } + macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0 + end end end #ifconfig stdout @@ -145,7 +148,6 @@ Ohai.plugin(:Network) do count += 1 end end - network["interfaces"] = iface end end diff --git a/lib/ohai/plugins/aix/os.rb b/lib/ohai/plugins/aix/os.rb new file mode 100644 index 00000000..fd2abfed --- /dev/null +++ b/lib/ohai/plugins/aix/os.rb @@ -0,0 +1,30 @@ +# +# Author:: Adam Jacob (<adam@chef.io>) +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# 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. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'ohai/mixin/os' + +Ohai.plugin(:OS) do + provides "os", "os_version" + depends 'kernel' + + collect_data(:aix) do + os collect_os + os_version kernel[:version] + end +end diff --git a/lib/ohai/plugins/aix/platform.rb b/lib/ohai/plugins/aix/platform.rb index 29239a28..c65c511b 100644 --- a/lib/ohai/plugins/aix/platform.rb +++ b/lib/ohai/plugins/aix/platform.rb @@ -1,6 +1,7 @@ # # Author:: Joshua Timberman <joshua@opscode.com> -# Copyright:: Copyright (c) 2013, Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb index 270a692f..287b0ecf 100644 --- a/lib/ohai/plugins/aix/uptime.rb +++ b/lib/ohai/plugins/aix/uptime.rb @@ -1,6 +1,7 @@ # # Author:: Kurt Yoder (<ktyopscode@yoderhome.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,4 +34,4 @@ Ohai.plugin(:Uptime) do end end end -end
\ No newline at end of file +end diff --git a/lib/ohai/plugins/aix/virtualization.rb b/lib/ohai/plugins/aix/virtualization.rb index ad625d9b..4653b462 100644 --- a/lib/ohai/plugins/aix/virtualization.rb +++ b/lib/ohai/plugins/aix/virtualization.rb @@ -1,6 +1,7 @@ # # Author:: Julian C. Dunn (<jdunn@getchef.com>) -# Copyright:: Copyright (c) 2014 Chef Software, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +18,7 @@ # Ohai.plugin(:Virtualization) do - provides "virtualization" + provides "virtualization", "virtualization/wpars" collect_data(:aix) do virtualization Mash.new @@ -33,7 +34,116 @@ Ohai.plugin(:Virtualization) do so = shell_out("uname -W") wpar_no = so.stdout.split($/)[0] - virtualization[:wpar_no] = wpar_no unless wpar_no.to_i == 0 + if wpar_no.to_i > 0 + virtualization[:wpar_no] = wpar_no + else + # the below parses the output of lswpar in the long format + 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] + wpars[wpar_name] = Mash.new + wpar.scan(/^[A-Z]{4,}.*?[A-Z\:0-9]$.*?\n\n/m).each do |section| + + # retrieve title of section + title = section.lines.first[0..-2].downcase + wpars[wpar_name][title] = Mash.new + + # discard trailing section newline+title + # and save as array + sections = section.lines[1..-2] + + sections.each do |line| + case title + when 'network' + next if line =~ /^Interface|^---/ + splat = line.strip.split + key = splat[0].downcase + value = { + 'address' => splat[1], + 'netmask' => splat[2], + 'broadcast' => splat[3], + } + wpars[wpar_name][title][key] = value + when 'user-specified routes' + next if line =~ /^Type|^---/ + splat = line.strip.split + key = splat[2].downcase + value = { + 'destination' => splat[0], + 'gateway' => splat[1], + } + wpars[wpar_name][title][key] = value + when 'file systems' + next if line =~ /^MountPoint|^---/ + splat = line.strip.split + key = splat[1].downcase + value = { + 'mountpoint' => splat[0], + 'device' => splat[1], + 'vfs' => splat[2], + 'options' => splat[3].split(','), + } + wpars[wpar_name][title][key] = value + when 'security settings' + privileges ||= '' + wpars[wpar_name][title]['Privileges'] ||= [] + + if line =~ /^Privileges/ + privileges << line.split(':')[1].strip + else + privileges << line.strip + end + + wpars[wpar_name][title]['Privileges'] += privileges.split(',') + when 'device exports' + next if line =~ /^Name|^---/ + splat = line.strip.split + key = splat[0].downcase + value = { + 'type' => splat[1], + 'status' => splat[2], + } + wpars[wpar_name][title][key] = value + else + # key-value pairs are handled here + # such as GENERAL and RESOURCE- + # CONTROL + splat = line.strip.split(':') + key = splat[0].downcase + value = splat[1..-1].join(', ').strip + value = value.empty? ? nil : value + case value + when "yes" + value = true + when "no" + value = false + end + wpars[wpar_name][title][key] = value + end + end + end + top_level = [ + "general.directory", + "general.hostname", + "general.private /usr", + "general.type", + "general.uuid", + "resource controls.active", + "network.en0.address", + ] + + top_level.each do |attribute| + evalstr = "wpars['#{wpar_name}']" + breadcrumb = attribute.split('.') + breadcrumb.each do |node| + evalstr << "[\'#{node}\']" + end + wpars[wpar_name][breadcrumb[-1]] = eval evalstr + end + end + virtualization[:wpars] = wpars unless wpars.empty? + end end -end
\ No newline at end of file +end diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb index 834aee8d..02a83eb0 100644 --- a/lib/ohai/plugins/hostname.rb +++ b/lib/ohai/plugins/hostname.rb @@ -5,6 +5,8 @@ # Author:: Daniel DeLeo (<dan@kallistec.com>) # Author:: Doug MacEachern (<dougm@vmware.com>) # Author:: James Gartrell (<jgartrel@gmail.com>) +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2015 Chef Software, Inc. # Copyright:: Copyright (c) 2008, 2009 Opscode, Inc. # Copyright:: Copyright (c) 2009 Bryan McLellan # Copyright:: Copyright (c) 2009 Daniel DeLeo @@ -67,7 +69,7 @@ Ohai.plugin(:Hostname) do def collect_hostname # Hostname is everything before the first dot if machinename - machinename =~ /(\w+)\.?/ + machinename =~ /([^.]+)\.?/ hostname $1 elsif fqdn fqdn =~ /(.+?)\./ @@ -90,13 +92,20 @@ Ohai.plugin(:Hostname) do end end - collect_data(:aix, :hpux, :default) do + collect_data(:hpux, :default) do machinename from_cmd("hostname") fqdn sigar_is_available? ? get_fqdn_from_sigar : resolve_fqdn collect_hostname collect_domain end + collect_data(:aix) do + machinename from_cmd("hostname -s") + fqdn resolve_fqdn || from_cmd("hostname") + collect_hostname + collect_domain + end + collect_data(:darwin, :netbsd, :openbsd, :dragonflybsd) do hostname from_cmd("hostname -s") fqdn resolve_fqdn diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb index 59b49669..5e9f4892 100644 --- a/spec/unit/plugins/aix/cpu_spec.rb +++ b/spec/unit/plugins/aix/cpu_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,62 +39,89 @@ CPU 1 runs at 1654 MHz CPU 2 runs at 1654 MHz CPU 3 runs at 1654 MHz PMCYCLES_M - + @plugin = get_plugin("aix/cpu") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil)) allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil)) allow(@plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil)) - @plugin.run end + context "when run on an LPAR" do + before do + allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil)) + @plugin.run + end - it "sets the vendor id to IBM" do - expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM") - end + it "sets the vendor id to IBM" do + expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM") + end - it "sets the available attribute" do - expect(@plugin[:cpu][:available]).to eq(1) - end + it "sets the available attribute" do + expect(@plugin[:cpu][:available]).to eq(1) + end - it "sets the total number of processors" do - expect(@plugin[:cpu][:total]).to eq(4) - end - - it "sets the real number of processors" do - expect(@plugin[:cpu][:real]).to eq(2) - end - - it "sets the number of cores" do - #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html - #on AIX number of cores and processors are considered same - expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real]) - end + it "sets the total number of processors" do + expect(@plugin[:cpu][:total]).to eq(4) + end - it "detects the model" do - expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5") - end + it "sets the real number of processors" do + expect(@plugin[:cpu][:real]).to eq(2) + end - it "detects the mhz" do - expect(@plugin[:cpu]["0"][:mhz]).to eq(1654) - end + it "sets the number of cores" do + #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html + #on AIX number of cores and processors are considered same + expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real]) + end - it "detects the status of the device" do - expect(@plugin[:cpu]["0"][:status]).to eq("Available") - end + it "detects the model" do + expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5") + end - it "detects the location of the device" do - expect(@plugin[:cpu]["0"][:location]).to eq("00-00") + it "detects the mhz" do + expect(@plugin[:cpu]["0"][:mhz]).to eq(1654) + end + + it "detects the status of the device" do + expect(@plugin[:cpu]["0"][:status]).to eq("Available") + end + + it "detects the location of the device" do + expect(@plugin[:cpu]["0"][:location]).to eq("00-00") + end + + context "lsattr -El device_name" do + it "detects all the attributes of the device" do + expect(@plugin[:cpu]["0"][:mhz]).to eq(1654) + expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true") + expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2") + expect(@plugin[:cpu]["0"][:state]).to eq("enable") + expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5") + end + end end - context "lsattr -El device_name" do - it "detects all the attributes of the device" do - expect(@plugin[:cpu]["0"][:mhz]).to eq(1654) - expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true") - expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2") - expect(@plugin[:cpu]["0"][:state]).to eq("enable") - expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5") + context "when run on a WPAR" do + before do + allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "120", nil)) + @plugin.run + end + + it "sets the total number of processors" do + expect(@plugin[:cpu][:total]).to eq(4) + end + + it "doesn't set the real number of CPUs" do + expect(@plugin[:cpu][:real]).to be_nil + end + + it "doesn't set mhz of a processor it can't see" do + # I'm so sorry + expect { + expect(@plugin[:cpu]["0"][:mhz]).to eq(1654) + }.to raise_error(NoMethodError) end end end diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb index 95ca3801..5365978f 100644 --- a/spec/unit/plugins/aix/filesystem_spec.rb +++ b/spec/unit/plugins/aix/filesystem_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,20 +19,45 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "AIX filesystem plugin" do before(:each) do - @df_P = <<-DF_P -Filesystem 512-blocks Used Available Capacity Mounted on -/dev/hd4 786432 495632 290800 64% / -/dev/hd2 10485760 8743200 1742560 84% /usr -/dev/hd9var 2621440 1152952 1468488 44% /var -/dev/hd3 2621440 541928 2079512 21% /tmp -/dev/hd1 8650752 6098080 2552672 71% /home -/dev/hd11admin 262144 760 261384 1% /admin -/proc - - - - /proc -/dev/hd10opt 3407872 1744384 1663488 52% /opt -192.168.1.11:/stage/middleware 314572800 177025952 137546848 57% /stage/middleware -DF_P - - @mount = <<-MOUNT + @df_Pk_LPAR = <<-DF_PK +Filesystem 1024-blocks Used Available Capacity Mounted on +/dev/hd4 2097152 219796 1877356 11% / +/dev/hd2 5242880 2416828 2826052 47% /usr +/dev/hd9var 5242880 395540 4847340 8% /var +/dev/hd3 5242880 1539508 3703372 30% /tmp +/dev/hd1 10485760 1972 10483788 1% /home +/dev/hd11admin 131072 380 130692 1% /admin +/proc - - - - /proc +/dev/hd10opt 5242880 1286720 3956160 25% /opt +/dev/livedump 262144 368 261776 1% /var/adm/ras/livedump +/dev/fslv00 524288 45076 479212 9% /wpars/sink-thinker-541ba3 +/dev/fslv01 2097152 8956 2088196 1% /wpars/sink-thinker-541ba3/home +/dev/fslv02 5242880 1307352 3935528 25% /wpars/sink-thinker-541ba3/opt +/proc - - - - /wpars/sink-thinker-541ba3/proc +/dev/fslv03 1048576 168840 879736 17% /wpars/sink-thinker-541ba3/tmp +/dev/fslv04 5242880 2725040 2517840 52% /wpars/sink-thinker-541ba3/usr +/dev/fslv05 524288 76000 448288 15% /wpars/sink-thinker-541ba3/var +/dev/fslv07 10485760 130872 10354888 2% /wpars/toolchain-tester-5c969f +/dev/fslv08 5242880 39572 5203308 1% /wpars/toolchain-tester-5c969f/home +/dev/fslv09 5242880 1477164 3765716 29% /wpars/toolchain-tester-5c969f/opt +/proc - - - - /wpars/toolchain-tester-5c969f/proc +/dev/fslv10 5242880 42884 5199996 1% /wpars/toolchain-tester-5c969f/tmp +/dev/fslv11 5242880 2725048 2517832 52% /wpars/toolchain-tester-5c969f/usr +/dev/fslv12 10485760 272376 10213384 3% /wpars/toolchain-tester-5c969f/var +DF_PK + + @df_Pk_WPAR = <<-DF_PK +Filesystem 1024-blocks Used Available Capacity Mounted on +Global 10485760 130872 10354888 2% / +Global 5242880 39572 5203308 1% /home +Global 5242880 1477164 3765716 29% /opt +Global - - - - /proc +Global 5242880 42884 5199996 1% /tmp +Global 5242880 2725048 2517832 52% /usr +Global 10485760 272376 10213384 3% /var +DF_PK + + @mount_LPAR = <<-MOUNT node mounted mounted over vfs date options -------- --------------- --------------- ------ ------------ --------------- /dev/hd4 / jfs2 Jul 17 13:22 rw,log=/dev/hd8 @@ -45,68 +71,144 @@ DF_P 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys MOUNT + @mount_WPAR = <<-MOUNT + node mounted mounted over vfs date options +-------- --------------- --------------- ------ ------------ --------------- + Global / jfs2 Nov 23 21:03 rw,log=NULL + Global /home jfs2 Nov 23 21:03 rw,log=NULL + Global /opt jfs2 Nov 23 21:03 rw,log=NULL + Global /proc namefs Nov 23 21:03 rw + Global /tmp jfs2 Nov 23 21:03 rw,log=NULL + Global /usr jfs2 Nov 23 21:03 rw,log=NULL + Global /var jfs2 Nov 23 21:03 rw,log=NULL +192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys +MOUNT + @plugin = get_plugin("aix/filesystem") allow(@plugin).to receive(:collect_os).and_return(:aix) @plugin[:filesystem] = Mash.new - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil)) - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil)) - - @plugin.run end - describe "df -P" do - - it "returns the filesystem block size" do - expect(@plugin[:filesystem]["/dev/hd4"]['kb_size']).to eq("786432") + context 'when run within an LPAR' do + before do + allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_LPAR, nil)) + allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_LPAR, nil)) + @plugin.run end - it "returns the filesystem used space in kb" do - expect(@plugin[:filesystem]["/dev/hd4"]['kb_used']).to eq("495632") - end + describe "df -Pk" do - it "returns the filesystem available space in kb" do - expect(@plugin[:filesystem]["/dev/hd4"]['kb_available']).to eq("290800") - end + it "returns the filesystem block size" do + expect(@plugin[:filesystem]["/dev/hd4"]['kb_size']).to eq("2097152") + end - it "returns the filesystem capacity in percentage" do - expect(@plugin[:filesystem]["/dev/hd4"]['percent_used']).to eq("64%") - end + it "returns the filesystem used space in kb" do + expect(@plugin[:filesystem]["/dev/hd4"]['kb_used']).to eq("219796") + end - it "returns the filesystem mounted location" do - expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/") - end - end + it "returns the filesystem available space in kb" do + expect(@plugin[:filesystem]["/dev/hd4"]['kb_available']).to eq("1877356") + end - describe "mount" do + it "returns the filesystem capacity in percentage" do + expect(@plugin[:filesystem]["/dev/hd4"]['percent_used']).to eq("11%") + end - it "returns the filesystem mount location" do - expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/") + it "returns the filesystem mounted location" do + expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/") + end end - it "returns the filesystem type" do - expect(@plugin[:filesystem]["/dev/hd4"]['fs_type']).to eq("jfs2") + describe "mount" do + + it "returns the filesystem mount location" do + expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/") + end + + it "returns the filesystem type" do + expect(@plugin[:filesystem]["/dev/hd4"]['fs_type']).to eq("jfs2") + end + + it "returns the filesystem mount options" do + expect(@plugin[:filesystem]["/dev/hd4"]['mount_options']).to eq(["rw", "log=/dev/hd8"]) + end + + # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys + context "having node values" do + + it "returns the filesystem mount location" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware") + end + + it "returns the filesystem type" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3") + end + + it "returns the filesystem mount options" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq(["ro", "bg", "hard", "intr", "sec=sys"]) + end + end end + end - it "returns the filesystem mount options" do - expect(@plugin[:filesystem]["/dev/hd4"]['mount_options']).to eq("rw,log=/dev/hd8") + context 'when run within a WPAR' do + before do + allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_Pk_WPAR, nil)) + allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_WPAR, nil)) + @plugin.run end - # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys - context "having node values" do - before do - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys", nil)) + describe "df -Pk" do + + it "returns the filesystem block size" do + expect(@plugin[:filesystem]["Global:/"]['kb_size']).to eq("10485760") + end + + it "returns the filesystem used space in kb" do + expect(@plugin[:filesystem]["Global:/"]['kb_used']).to eq("130872") + end + + it "returns the filesystem available space in kb" do + expect(@plugin[:filesystem]["Global:/"]['kb_available']).to eq("10354888") + end + + it "returns the filesystem capacity in percentage" do + expect(@plugin[:filesystem]["Global:/"]['percent_used']).to eq("2%") end + it "returns the filesystem mounted location" do + expect(@plugin[:filesystem]["Global:/"]['mount']).to eq("/") + end + end + + describe "mount" do + it "returns the filesystem mount location" do - expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware") + expect(@plugin[:filesystem]["Global:/"]['mount']).to eq("/") end it "returns the filesystem type" do - expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3") + expect(@plugin[:filesystem]["Global:/"]['fs_type']).to eq("jfs2") end it "returns the filesystem mount options" do - expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq("ro,bg,hard,intr,sec=sys") + expect(@plugin[:filesystem]["Global:/"]['mount_options']).to eq(["rw", "log=NULL"]) + end + + # For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys + context "having node values" do + + it "returns the filesystem mount location" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware") + end + + it "returns the filesystem type" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3") + end + + it "returns the filesystem mount options" do + expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq(["ro", "bg", "hard", "intr", "sec=sys"]) + end end end end diff --git a/spec/unit/plugins/aix/hostname_spec.rb b/spec/unit/plugins/aix/hostname_spec.rb index 2a92c9c1..3512f77f 100644 --- a/spec/unit/plugins/aix/hostname_spec.rb +++ b/spec/unit/plugins/aix/hostname_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,11 +18,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') -describe Ohai::System, "Aix hostname plugin" do +describe Ohai::System, "AIX hostname plugin" do before(:each) do @plugin = get_plugin("hostname") allow(@plugin).to receive(:collect_os).and_return(:aix) - allow(@plugin).to receive(:from_cmd).with("hostname").and_return("aix_admin") + allow(@plugin).to receive(:from_cmd).with("hostname -s").and_return("aix_admin") + allow(@plugin).to receive(:from_cmd).with("hostname").and_return("aix_admin.ponyville.com") @plugin.run end diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb index 85756962..621df339 100644 --- a/spec/unit/plugins/aix/kernel_spec.rb +++ b/spec/unit/plugins/aix/kernel_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index 4aa98626..fed985aa 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -1,4 +1,6 @@ # +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,19 +31,19 @@ describe Ohai::System, "AIX memory plugin" do @plugin.run expect(@plugin['memory']['total']).to eql("#{513280 * 1024}kB") end - + it "should get free memory" do @plugin.run expect(@plugin['memory']['free']).to eql("#{173245.83.to_i * 1024}kB") end - + it "should get total swap" do @plugin.run expect(@plugin['memory']['swap']['total']).to eql( "#{23887872 * 4}kB") end - + it "should get free swap" do @plugin.run expect(@plugin['memory']['swap']['free']).to eql( "#{23598960 * 4}kB") end -end +end diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index 3b66465b..446a58ff 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -106,6 +107,17 @@ ARP_AN end describe "when running on an LPAR" do + + describe "sets the top-level attribute correctly" do + before do + @plugin.run + end + + it 'for \'macaddress\'' do + expect(@plugin[:macaddress]).to eq("BE:42:80:00:B0:05") + end + end + describe "netstat -rn |grep default" do before do @plugin.run @@ -134,6 +146,10 @@ ARP_AN it "avoids collecting default interface" do expect(@plugin[:network][:default_gateway]).to be_nil end + + it "avoids collecting a macaddress" do + expect(@plugin[:macaddress]).to be_nil + end end describe "lsdev -Cc if" do diff --git a/spec/unit/plugins/aix/os_spec.rb b/spec/unit/plugins/aix/os_spec.rb new file mode 100644 index 00000000..3aefdf8c --- /dev/null +++ b/spec/unit/plugins/aix/os_spec.rb @@ -0,0 +1,35 @@ +# +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# 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. +# See the License for the specific language governing permissions and +# limitations under the License. + +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') + +describe Ohai::System, "AIX os plugin" do + before(:each) do + @plugin = get_plugin("aix/os") + kernel = Mash.new + kernel[:version] = "6" + kernel[:release] = "1" + allow(@plugin).to receive(:collect_os).and_return(:aix) + allow(@plugin).to receive(:kernel).and_return(kernel) + @plugin.run + end + + it "should set the top-level os_level attribute" do + expect(@plugin[:os_version]).to eql("6") + end +end + diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb index 89f6469f..97df7f6d 100644 --- a/spec/unit/plugins/aix/platform_spec.rb +++ b/spec/unit/plugins/aix/platform_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,8 +24,8 @@ describe Ohai::System, "Aix plugin platform" do allow(@plugin).to receive(:collect_os).and_return(:aix) kernel = Mash.new kernel[:name] = "aix" - kernel[:version] = "1" - kernel[:release] = "0" + kernel[:version] = "7" + kernel[:release] = "1" allow(@plugin).to receive(:kernel).and_return(kernel) @plugin.run end @@ -34,7 +35,7 @@ describe Ohai::System, "Aix plugin platform" do end it "should set the platform_version" do - expect(@plugin[:platform_version]).to eq("1.0") + expect(@plugin[:platform_version]).to eq("7.1") end it "should set platform_family" do diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb index 986889de..3af623f8 100644 --- a/spec/unit/plugins/aix/uptime_spec.rb +++ b/spec/unit/plugins/aix/uptime_spec.rb @@ -1,6 +1,7 @@ # # Author:: Prabhu Das (<prabhu.das@clogeny.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/plugins/aix/virtualization_spec.rb b/spec/unit/plugins/aix/virtualization_spec.rb index 2cafabbf..271c930f 100644 --- a/spec/unit/plugins/aix/virtualization_spec.rb +++ b/spec/unit/plugins/aix/virtualization_spec.rb @@ -1,6 +1,7 @@ # -# Author:: Julian C. Dunn (<jdunn@getchef.com>) -# Copyright:: Copyright (c) 2014 Chef Software, Inc. +# Author:: Julian C. Dunn (<jdunn@getchef.comm>) +# Author:: Isa Farnik (<isa@chef.io>) +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,19 +21,284 @@ require 'spec_helper' describe Ohai::System, "AIX virtualization plugin" do context "inside an LPAR" do + let(:plugin) do p = get_plugin("aix/virtualization") allow(p).to receive(:collect_os).and_return(:aix) allow(p).to receive(:shell_out).with("uname -L").and_return(mock_shell_out(0, "29 l273pp027", nil)) allow(p).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil)) - p.run + allow(p).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, @lswpar_L, nil)) p end + before(:each) do + @lswpar_L = <<-LSWPAR_L +================================================================= +applejack-541ba3 - Active +================================================================= +GENERAL +Type: S +RootVG WPAR: no +Owner: root +Hostname: applejack-pony-541ba3.ponyville.com +WPAR-Specific Routing: yes +Virtual IP WPAR: +Directory: /wpars/applejack-541ba3 +Start/Stop Script: +Auto: no +Private /usr: yes +Checkpointable: no +Application: +UUID: 541ba314-c7ca-4f67-bc6e-a10d5eaa8541 + +NETWORK +Interface Address(6) Mask/Prefix Broadcast +----------------------------------------------------------------- +en0 192.168.0.231 255.255.252.0 192.168.0.255 +lo0 127.0.0.1 255.0.0.0 127.255.255.255 + +USER-SPECIFIED ROUTES +Type Destination Gateway Interface +----------------------------------------------------------------- + default 192.168.0.1 en0 + +FILE SYSTEMS +MountPoint Device Vfs Nodename Options +----------------------------------------------------------------- +/wpars/sink-thinker-5... /dev/fslv00 jfs2 log=NULL +/wpars/sink-thinker-5... /dev/fslv01 jfs2 log=NULL +/wpars/sink-thinker-5... /dev/fslv02 jfs2 log=NULL +/wpars/sink-thinker-5... /proc namefs rw +/wpars/sink-thinker-5... /dev/fslv03 jfs2 log=NULL +/wpars/sink-thinker-5... /dev/fslv04 jfs2 log=NULL +/wpars/sink-thinker-5... /dev/fslv05 jfs2 log=NULL + +RESOURCE CONTROLS +Active: yes +Resource Set: +CPU Shares: unlimited +CPU Limits: 0%-100%,100% +Memory Shares: unlimited +Memory Limits: 0%-100%,100% +Per-Process Virtual Memory Limit: unlimited +Total Virtual Memory Limit: unlimited +Total Processes: unlimited +Total Threads: unlimited +Total PTYs: unlimited +Total Large Pages: unlimited +Max Message Queue IDs: 100% +Max Semaphore IDs: 100% +Max Shared Memory IDs: 100% +Max Pinned Memory: 100% + +OPERATION +Operation: none +Process ID: +Start Time: + +SECURITY SETTINGS +Privileges: PV_AU_,PV_AU_ADD,PV_AU_ADMIN,PV_AU_PROC,PV_AU_READ, + PV_AU_WRITE,PV_AZ_ADMIN,PV_AZ_CHECK,PV_AZ_READ,PV_AZ_ROOT, + PV_DAC_,PV_DAC_GID,PV_DAC_O,PV_DAC_R,PV_DAC_RID,PV_DAC_UID, + PV_DAC_W,PV_DAC_X,PV_DEV_CONFIG,PV_DEV_QUERY,PV_FS_CHOWN, + PV_FS_CHROOT,PV_FS_CNTL,PV_FS_LINKDIR,PV_FS_MKNOD, + PV_FS_MOUNT,PV_FS_PDMODE,PV_FS_QUOTA,PV_KER_ACCT, + PV_KER_CONF,PV_KER_DR,PV_KER_EWLM,PV_KER_EXTCONF, + PV_KER_IPC,PV_KER_IPC_O,PV_KER_IPC_R,PV_KER_IPC_W, + PV_KER_NFS,PV_KER_RAC,PV_KER_RAS_ERR,PV_KER_REBOOT, + PV_NET_PORT,PV_PROC_CKPT,PV_PROC_CORE,PV_PROC_CRED, + PV_PROC_ENV,PV_PROC_PRIO,PV_PROC_PDMODE,PV_PROC_RAC, + PV_PROC_RTCLK,PV_PROC_SIG,PV_PROC_TIMER,PV_PROC_VARS, + PV_PROC_PRIV,PV_SU_UID,PV_TCB,PV_TP,PV_TP_SET,PV_MIC, + PV_MIC_CL,PV_LAB_,PV_LAB_CL,PV_LAB_CLTL,PV_LAB_LEF, + PV_LAB_SLDG,PV_LAB_SLDG_STR,PV_LAB_SL_FILE,PV_LAB_SL_PROC, + PV_LAB_SL_SELF,PV_LAB_SLUG,PV_LAB_SLUG_STR,PV_LAB_TL, + PV_MAC_,PV_MAC_CL,PV_MAC_R,PV_MAC_R_CL,PV_MAC_R_STR, + PV_MAC_R_PROC,PV_MAC_W,PV_MAC_W_CL,PV_MAC_W_DN,PV_MAC_W_UP, + PV_MAC_W_PROC,PV_MAC_OVRRD,PV_KER_SECCONFIG, + PV_PROBEVUE_TRC_USER,PV_PROBEVUE_TRC_USER_SELF,PV_KER_LVM + +DEVICE EXPORTS +Name Type Virtual Device RootVG Status +----------------------------------------------------------------- +/dev/null pseudo EXPORTED +/dev/tty pseudo EXPORTED +/dev/console pseudo EXPORTED +/dev/zero pseudo EXPORTED +/dev/clone pseudo EXPORTED +/dev/sad clone EXPORTED +/dev/xti/tcp clone EXPORTED +/dev/xti/tcp6 clone EXPORTED +/dev/xti/udp clone EXPORTED +/dev/xti/udp6 clone EXPORTED +/dev/xti/unixdg clone EXPORTED +/dev/xti/unixst clone EXPORTED +/dev/error pseudo EXPORTED +/dev/errorctl pseudo EXPORTED +/dev/audit pseudo EXPORTED +/dev/nvram pseudo EXPORTED + +================================================================= +fluttershy-5c969f - Active +================================================================= +GENERAL +Type: S +RootVG WPAR: no +Owner: root +Hostname: fluttershy-pony-5c969f.ponyville.com +WPAR-Specific Routing: yes +Virtual IP WPAR: +Directory: /wpars/fluttershy-5c969f +Start/Stop Script: +Auto: no +Private /usr: yes +Checkpointable: no +Application: +UUID: 6f1fd4be-8be5-4627-8ec0-3a8739cbd9e2 + +NETWORK +Interface Address(6) Mask/Prefix Broadcast +----------------------------------------------------------------- +en0 192.168.0.18 255.255.252.0 192.168.0.255 +lo0 127.0.0.1 255.0.0.0 127.255.255.255 + +USER-SPECIFIED ROUTES +Type Destination Gateway Interface +----------------------------------------------------------------- + default 192.168.0.1 en0 + +FILE SYSTEMS +MountPoint Device Vfs Nodename Options +----------------------------------------------------------------- +/wpars/toolchain-test... /dev/fslv07 jfs2 log=NULL +/wpars/toolchain-test... /dev/fslv08 jfs2 log=NULL +/wpars/toolchain-test... /dev/fslv09 jfs2 log=NULL +/wpars/toolchain-test... /proc namefs rw +/wpars/toolchain-test... /dev/fslv10 jfs2 log=NULL +/wpars/toolchain-test... /dev/fslv11 jfs2 log=NULL +/wpars/toolchain-test... /dev/fslv12 jfs2 log=NULL + +RESOURCE CONTROLS +Active: yes +Resource Set: +CPU Shares: unlimited +CPU Limits: 0%-100%,100% +Memory Shares: unlimited +Memory Limits: 0%-100%,100% +Per-Process Virtual Memory Limit: unlimited +Total Virtual Memory Limit: unlimited +Total Processes: unlimited +Total Threads: unlimited +Total PTYs: unlimited +Total Large Pages: unlimited +Max Message Queue IDs: 100% +Max Semaphore IDs: 100% +Max Shared Memory IDs: 100% +Max Pinned Memory: 100% + +OPERATION +Operation: none +Process ID: +Start Time: + +SECURITY SETTINGS +Privileges: PV_AU_,PV_AU_ADD,PV_AU_ADMIN,PV_AU_PROC,PV_AU_READ, + PV_AU_WRITE,PV_AZ_ADMIN,PV_AZ_CHECK,PV_AZ_READ,PV_AZ_ROOT, + PV_DAC_,PV_DAC_GID,PV_DAC_O,PV_DAC_R,PV_DAC_RID,PV_DAC_UID, + PV_DAC_W,PV_DAC_X,PV_DEV_CONFIG,PV_DEV_QUERY,PV_FS_CHOWN, + PV_FS_CHROOT,PV_FS_CNTL,PV_FS_LINKDIR,PV_FS_MKNOD, + PV_FS_MOUNT,PV_FS_PDMODE,PV_FS_QUOTA,PV_KER_ACCT, + PV_KER_CONF,PV_KER_DR,PV_KER_EWLM,PV_KER_EXTCONF, + PV_KER_IPC,PV_KER_IPC_O,PV_KER_IPC_R,PV_KER_IPC_W, + PV_KER_NFS,PV_KER_RAC,PV_KER_RAS_ERR,PV_KER_REBOOT, + PV_NET_PORT,PV_PROC_CKPT,PV_PROC_CORE,PV_PROC_CRED, + PV_PROC_ENV,PV_PROC_PRIO,PV_PROC_PDMODE,PV_PROC_RAC, + PV_PROC_RTCLK,PV_PROC_SIG,PV_PROC_TIMER,PV_PROC_VARS, + PV_PROC_PRIV,PV_SU_UID,PV_TCB,PV_TP,PV_TP_SET,PV_MIC, + PV_MIC_CL,PV_LAB_,PV_LAB_CL,PV_LAB_CLTL,PV_LAB_LEF, + PV_LAB_SLDG,PV_LAB_SLDG_STR,PV_LAB_SL_FILE,PV_LAB_SL_PROC, + PV_LAB_SL_SELF,PV_LAB_SLUG,PV_LAB_SLUG_STR,PV_LAB_TL, + PV_MAC_,PV_MAC_CL,PV_MAC_R,PV_MAC_R_CL,PV_MAC_R_STR, + PV_MAC_R_PROC,PV_MAC_W,PV_MAC_W_CL,PV_MAC_W_DN,PV_MAC_W_UP, + PV_MAC_W_PROC,PV_MAC_OVRRD,PV_KER_SECCONFIG, + PV_PROBEVUE_TRC_USER,PV_PROBEVUE_TRC_USER_SELF,PV_KER_LVM + +DEVICE EXPORTS +Name Type Virtual Device RootVG Status +----------------------------------------------------------------- +/dev/null pseudo EXPORTED +/dev/tty pseudo EXPORTED +/dev/console pseudo EXPORTED +/dev/zero pseudo EXPORTED +/dev/clone pseudo EXPORTED +/dev/sad clone EXPORTED +/dev/xti/tcp clone EXPORTED +/dev/xti/tcp6 clone EXPORTED +/dev/xti/udp clone EXPORTED +/dev/xti/udp6 clone EXPORTED +/dev/xti/unixdg clone EXPORTED +/dev/xti/unixst clone EXPORTED +/dev/error pseudo EXPORTED +/dev/errorctl pseudo EXPORTED +/dev/audit pseudo EXPORTED +/dev/nvram pseudo EXPORTED + + +LSWPAR_L + + end + it "uname -L detects the LPAR number and name" do + plugin.run expect(plugin[:virtualization][:lpar_no]).to eq("29") expect(plugin[:virtualization][:lpar_name]).to eq("l273pp027") end + + context 'when WPARs exist on the LPAR' do + before do + plugin.run + end + + let(:wpar1) do + plugin[:virtualization][:wpars]['applejack-541ba3'] + end + + let(:wpar2) do + plugin[:virtualization][:wpars]['fluttershy-5c969f'] + end + + it 'detects all WPARs present (2)' do + expect(plugin[:virtualization][:wpars].length).to eq(2) + end + + context 'when collecting WPAR info' do + it 'finds the WPAR\'s hostname correctly' do + expect(wpar1[:hostname]).to eq("applejack-pony-541ba3.ponyville.com") + expect(wpar2[:hostname]).to eq("fluttershy-pony-5c969f.ponyville.com") + end + + it 'finds the WPAR\'s IP correctly' do + expect(wpar1[:address]).to eq("192.168.0.231") + expect(wpar2[:address]).to eq("192.168.0.18") + end + + it 'parses device exports properly' do + expect(wpar1['device exports']['/dev/nvram']['type']).to eq("pseudo") + expect(wpar1['device exports']['/dev/nvram']['status']).to eq("EXPORTED") + end + end + end + + context 'when WPARs don\'t exist on the LPAR' do + before do + allow(plugin).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, '', nil)) + plugin.run + end + + it 'detects all WPARs present (0)' do + expect(plugin[:virtualization][:wpars]).to be_nil + end + end end context "inside a WPAR" do |