summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-01-13 12:09:50 -0800
committersersut <serdar@opscode.com>2014-01-13 12:09:50 -0800
commitd5f2ee37ab3717ccc92e79c098b77ee5697b5e85 (patch)
tree59277c4e7ce38a2506f70a67441c8a8276bd1668
parentedfedd70fddc608bba8504bd85f337bd77640223 (diff)
downloadohai-d5f2ee37ab3717ccc92e79c098b77ee5697b5e85.tar.gz
Convert AIX plugins to use shell_out.
-rw-r--r--lib/ohai/plugins/aix/cpu.rb4
-rw-r--r--lib/ohai/plugins/aix/filesystem.rb74
-rw-r--r--lib/ohai/plugins/aix/kernel.rb8
-rw-r--r--lib/ohai/plugins/aix/memory.rb2
-rw-r--r--lib/ohai/plugins/aix/network.rb166
-rw-r--r--lib/ohai/plugins/aix/uptime.rb14
-rw-r--r--spec/unit/plugins/aix/cpu_spec.rb4
-rw-r--r--spec/unit/plugins/aix/filesystem_spec.rb8
-rw-r--r--spec/unit/plugins/aix/kernel_spec.rb12
-rw-r--r--spec/unit/plugins/aix/network_spec.rb18
-rw-r--r--spec/unit/plugins/aix/uptime_spec.rb2
11 files changed, 148 insertions, 164 deletions
diff --git a/lib/ohai/plugins/aix/cpu.rb b/lib/ohai/plugins/aix/cpu.rb
index d885a391..eaf6f431 100644
--- a/lib/ohai/plugins/aix/cpu.rb
+++ b/lib/ohai/plugins/aix/cpu.rb
@@ -29,7 +29,7 @@ Ohai.plugin(:CPU) do
cpu[:available] = 0
cpu[:total] = 0
- cpudevs = from("lsdev -Cc processor").lines
+ cpudevs = shell_out("lsdev -Cc processor").stdout.lines
cpudevs.each do |c|
cpu[:total] += 1
name, status, location = c.split
@@ -38,7 +38,7 @@ Ohai.plugin(:CPU) do
cpu[name][:location] = location
if status =~ /Available/
cpu[:available] += 1
- lsattr = from("lsattr -El #{name}").lines
+ lsattr = shell_out("lsattr -El #{name}").stdout.lines
lsattr.each do |attribute|
attrib, value = attribute.split
cpu[name][attrib] = value
diff --git a/lib/ohai/plugins/aix/filesystem.rb b/lib/ohai/plugins/aix/filesystem.rb
index 55e576c7..1e220a17 100644
--- a/lib/ohai/plugins/aix/filesystem.rb
+++ b/lib/ohai/plugins/aix/filesystem.rb
@@ -25,49 +25,45 @@ Ohai.plugin(:Filesystem) do
fs = Mash.new
# Grab filesystem data from df
- popen4("df -P") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /^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
- end
+ so = shell_out("df -P")
+ so.stdout.lines.each do |line|
+ case line
+ when /^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
end
end
# Grab mount information from /bin/mount
- popen4("mount") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.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]
- 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
+ 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]
+ 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
end
diff --git a/lib/ohai/plugins/aix/kernel.rb b/lib/ohai/plugins/aix/kernel.rb
index 748ce702..b8ce0acf 100644
--- a/lib/ohai/plugins/aix/kernel.rb
+++ b/lib/ohai/plugins/aix/kernel.rb
@@ -22,10 +22,10 @@ Ohai.plugin(:Kernel) do
collect_data(:aix) do
kernel Mash.new
- kernel[:name] = from("uname -s").downcase
- kernel[:release] = from("uname -r")
- kernel[:version] = from("uname -v")
- kernel[:machine] = from("uname -p")
+ kernel[:name] = shell_out("uname -s").stdout.downcase
+ kernel[:release] = shell_out("uname -r").stdout
+ kernel[:version] = shell_out("uname -v").stdout
+ kernel[:machine] = shell_out("uname -p").stdout
kernel[:modules] = Mash.new
end
end
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb
index 8500a42d..da74a778 100644
--- a/lib/ohai/plugins/aix/memory.rb
+++ b/lib/ohai/plugins/aix/memory.rb
@@ -22,7 +22,7 @@ Ohai.plugin(:Memory) do
collect_data(:aix) do
memory = Mash.new
- meminfo = from("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'")
+ meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout
memory[:total], u, memory[:free] = meminfo.split
end
end
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb
index 164ae57b..b6dbb22e 100644
--- a/lib/ohai/plugins/aix/network.rb
+++ b/lib/ohai/plugins/aix/network.rb
@@ -43,116 +43,104 @@ Ohai.plugin(:Network) do
iface = Mash.new
# :default_interface, :default_gateway - route -n get 0
- popen4("route -n get 0") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /gateway: (\S+)/
- network[:default_gateway] = $1
- when /interface: (\S+)/
- network[:default_interface] = $1
- end
+ so = shell_out("route -n get 0")
+ so.stdout.lines.each do |line|
+ case line
+ when /gateway: (\S+)/
+ network[:default_gateway] = $1
+ when /interface: (\S+)/
+ network[:default_interface] = $1
end
end
# List the interfaces in system.
- popen4("lsdev -Cc if") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /(\S+) (\S+)\s+(.+)/
- interface = $1
- iface[interface] = Mash.new unless iface[interface]
- iface[interface][:state] = ($2 == 'Available' ? 'up' : 'down')
- iface[interface][:description] = $3
-
- # Query the interface information
- popen4("ifconfig #{interface}") do |if_pid, if_stdin, if_stdout, if_stderr|
- if_stdin.close
- if_stdout.each do |line|
- case line
- when /^#{interface}:\sflags=\S+<(\S+)>/
- iface[interface][:flags] = $1.split(',')
- iface[interface][:metric] = $1 if line =~ /metric\s(\S+)/
- else
- # We have key value pairs.
- if line =~ /inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\/(\d{1,2}))?/
- tmp_addr, tmp_prefix = $1, $3
- if tmp_prefix.nil?
- netmask = hex_to_dec_netmask($1) if line =~ /netmask\s(\S+)\s/
- unless netmask
- tmp_prefix ||= "32"
- netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
- end
- else
- netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
- end
-
- iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
- iface[interface][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
- iface[interface][:addresses][tmp_addr][:netmask] = netmask
-
- if line =~ /broadcast\s(\S+)\s/
- iface[interface][:addresses][tmp_addr][:broadcast] = $1
- end
- elsif line =~ /inet6 ([a-f0-9\:%]+)\/(\d+)/
- # TODO do we have more properties on inet6 in aix? broadcast
- iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
- iface[interface][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2 }
- else
- # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
- properties = line.split
- n = properties.length/2 - 1
- (0..n).each do |i|
- iface[interface][properties[i*2]] = properties[(i*2+1)]
- end
+ so = shell_out("lsdev -Cc if")
+ so.stdout.lines.each do |line|
+ if line =~ /(\S+) (\S+)\s+(.+)/
+ interface = $1
+ iface[interface] = Mash.new unless iface[interface]
+ iface[interface][:state] = ($2 == 'Available' ? 'up' : 'down')
+ iface[interface][:description] = $3
+
+ # Query the interface information
+ if_so = shell_out("ifconfig #{interface}")
+ if_so.stdout.lines.each do |line|
+ case line
+ when /^#{interface}:\sflags=\S+<(\S+)>/
+ iface[interface][:flags] = $1.split(',')
+ iface[interface][:metric] = $1 if line =~ /metric\s(\S+)/
+ else
+ # We have key value pairs.
+ if line =~ /inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\/(\d{1,2}))?/
+ tmp_addr, tmp_prefix = $1, $3
+ if tmp_prefix.nil?
+ netmask = hex_to_dec_netmask($1) if line =~ /netmask\s(\S+)\s/
+ unless netmask
+ tmp_prefix ||= "32"
+ netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
end
+ else
+ netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
+ end
+
+ iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
+ iface[interface][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
+ iface[interface][:addresses][tmp_addr][:netmask] = netmask
+
+ if line =~ /broadcast\s(\S+)\s/
+ iface[interface][:addresses][tmp_addr][:broadcast] = $1
+ end
+ elsif line =~ /inet6 ([a-f0-9\:%]+)\/(\d+)/
+ # TODO do we have more properties on inet6 in aix? broadcast
+ iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
+ iface[interface][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2 }
+ else
+ # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
+ properties = line.split
+ n = properties.length/2 - 1
+ (0..n).each do |i|
+ iface[interface][properties[i*2]] = properties[(i*2+1)]
end
- end
- end #ifconfig stdout
-
- # Query macaddress
- popen4("entstat -d #{interface} | grep \"Hardware Address\"") do |e_pid, e_stdin, e_stdout, e_stderr|
- e_stdin.close
- iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
- e_stdout.each do |line|
- iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" } if line =~ /Hardware Address: (\S+)/
end
end
+ end #ifconfig stdout
+
+ # Query macaddress
+ 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+)/
end
end #lsdev stdout
end
# Query routes information
%w{inet inet6}.each do |family|
- popen4("netstat -nrf #{family}") do |n_pid, n_stdin, n_stdout, n_stderr|
- n_stdin.close
- n_stdout.each do |line|
- if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
- interface = $6
- iface[interface][:routes] = Array.new unless iface[interface][:routes]
- iface[interface][:routes] << Mash.new( :destination => $1, :family => family,
- :via => $2, :flags => $3)
- end
+ so_n = shell_out("netstat -nrf #{family}")
+ so_n.stdout.lines.each do |line|
+ if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
+ interface = $6
+ iface[interface][:routes] = Array.new unless iface[interface][:routes]
+ iface[interface][:routes] << Mash.new( :destination => $1, :family => family,
+ :via => $2, :flags => $3)
end
end
end
# List the arp entries in system.
- popen4("arp -an") do |pid, stdin, stdout, stderr|
- stdin.close
- count = 0
- stdout.each do |line|
- network[:arp] = Mash.new unless network[:arp]
- if line =~ /\s*(\S+) \((\S+)\) at ([a-fA-F0-9\:]+) \[(\w+)\] stored in bucket/
- network[:arp][count] = Mash.new unless network[:arp][count]
- network[:arp][count][:remote_host] = $1
- network[:arp][count][:remote_ip] = $2
- network[:arp][count][:remote_mac] = $3.downcase
- count += 1
- end
+ so = shell_out("arp -an")
+ count = 0
+ so.stdout.lines.each do |line|
+ network[:arp] = Mash.new unless network[:arp]
+ if line =~ /\s*(\S+) \((\S+)\) at ([a-fA-F0-9\:]+) \[(\w+)\] stored in bucket/
+ network[:arp][count] = Mash.new unless network[:arp][count]
+ network[:arp][count][:remote_host] = $1
+ network[:arp][count][:remote_ip] = $2
+ network[:arp][count][:remote_mac] = $3.downcase
+ count += 1
end
end
-
+
network["interfaces"] = iface
end
end
diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb
index d96e10f1..6c33cb7b 100644
--- a/lib/ohai/plugins/aix/uptime.rb
+++ b/lib/ohai/plugins/aix/uptime.rb
@@ -24,14 +24,12 @@ Ohai.plugin(:Uptime) do
# Example output:
# $ who -b
# . system boot Jul 9 17:51
- popen4('who -b') do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /.* boot (.+)/
- uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i
- uptime seconds_to_human(uptime_seconds)
- break
- end
+ so = shell_out('who -b')
+ so.stdout.lines.each do |line|
+ if line =~ /.* boot (.+)/
+ uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i
+ uptime seconds_to_human(uptime_seconds)
+ break
end
end
end
diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb
index d47e87ea..5a58d18d 100644
--- a/spec/unit/plugins/aix/cpu_spec.rb
+++ b/spec/unit/plugins/aix/cpu_spec.rb
@@ -34,8 +34,8 @@ LSATTR_EL
@plugin = get_plugin("aix/cpu")
@plugin.stub(:collect_os).and_return(:aix)
- @plugin.stub(:from).with("lsdev -Cc processor").and_return(@lsdev_Cc_processor)
- @plugin.stub(:from).with("lsattr -El proc0").and_return(@lsattr_El_proc0)
+ @plugin.stub(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
+ @plugin.stub(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
@plugin.run
end
diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb
index 4c903787..c03f2c01 100644
--- a/spec/unit/plugins/aix/filesystem_spec.rb
+++ b/spec/unit/plugins/aix/filesystem_spec.rb
@@ -48,8 +48,9 @@ MOUNT
@plugin = get_plugin("aix/filesystem")
@plugin.stub(:collect_os).and_return(:aix)
@plugin[:filesystem] = Mash.new
- @plugin.stub(:popen4).with("df -P").and_yield(nil, StringIO.new, StringIO.new(@df_P), nil)
- @plugin.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new(@mount), nil)
+ @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil))
+ @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil))
+
@plugin.run
end
@@ -93,8 +94,9 @@ MOUNT
# 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
- @plugin.stub(:popen4).with("mount").and_yield(nil, StringIO.new, StringIO.new("192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys"), nil)
+ @plugin.stub(: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))
end
+
it "returns the filesystem mount location" do
@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount'].should == "/stage/middleware"
end
diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb
index 89173a6b..f1018e5b 100644
--- a/spec/unit/plugins/aix/kernel_spec.rb
+++ b/spec/unit/plugins/aix/kernel_spec.rb
@@ -21,10 +21,10 @@ describe Ohai::System, "AIX kernel plugin" do
before(:each) do
@plugin = get_plugin("aix/kernel")
@plugin.stub(:collect_os).and_return(:aix)
- @plugin.stub(:from).with("uname -s").and_return("AIX")
- @plugin.stub(:from).with("uname -r").and_return(1)
- @plugin.stub(:from).with("uname -v").and_return(6)
- @plugin.stub(:from).with("uname -p").and_return("powerpc")
+ @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
+ @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
+ @plugin.stub(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
+ @plugin.stub(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
@modules = Mash.new
@plugin.stub(:modules).and_return(@modules)
@plugin.run
@@ -35,11 +35,11 @@ describe Ohai::System, "AIX kernel plugin" do
end
it "uname -r detects the release" do
- @plugin[:kernel][:release].should == 1
+ @plugin[:kernel][:release].should == "1"
end
it "uname -v detects the version" do
- @plugin[:kernel][:version].should == 6
+ @plugin[:kernel][:version].should == "6"
end
it "uname -p detects the machine" do
diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb
index f6806992..1aa00a9e 100644
--- a/spec/unit/plugins/aix/network_spec.rb
+++ b/spec/unit/plugins/aix/network_spec.rb
@@ -74,13 +74,13 @@ ARP_AN
@plugin = get_plugin("aix/network")
@plugin.stub(:collect_os).and_return(:aix)
@plugin[:network] = Mash.new
- @plugin.stub(:popen4).with("route -n get 0").and_yield(nil, StringIO.new, StringIO.new(@route_n_get_0), nil)
- @plugin.stub(:popen4).with("lsdev -Cc if").and_yield(nil, StringIO.new, StringIO.new(@lsdev_Cc_if), nil)
- @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new(@ifconfig_en0), nil)
- @plugin.stub(:popen4).with("entstat -d en0 | grep \"Hardware Address\"").and_yield(nil, StringIO.new, StringIO.new("Hardware Address: be:42:80:00:b0:05"), nil)
- @plugin.stub(:popen4).with("netstat -nrf inet").and_yield(nil, StringIO.new, StringIO.new(@netstat_nrf_inet), nil)
- @plugin.stub(:popen4).with("netstat -nrf inet6").and_yield(nil, StringIO.new, StringIO.new("::1%1 ::1%1 UH 1 109392 en0 - -"), nil)
- @plugin.stub(:popen4).with("arp -an").and_yield(nil, StringIO.new, StringIO.new(@aix_arp_an), nil)
+ @plugin.stub(:shell_out).with("route -n get 0").and_return(mock_shell_out(0, @route_n_get_0, nil))
+ @plugin.stub(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil))
+ @plugin.stub(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
+ @plugin.stub(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
+ @plugin.stub(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
+ @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
end
describe "run" do
@@ -164,7 +164,7 @@ ARP_AN
# For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255
context "with no netmask in the output" do
before do
- @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet 172.29.174.59 broadcast 172.29.191.255"), nil)
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
end
it "detects the default prefixlen" do
@@ -181,7 +181,7 @@ ARP_AN
context "inet6 entries" do
before do
- @plugin.stub(:popen4).with("ifconfig en0").and_yield(nil, StringIO.new, StringIO.new("inet6 ::1%1/0"), nil)
+ @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet6 ::1%1/0", nil))
@plugin.run
@inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["::1%1"]
end
diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb
index bf7716c1..2f66b031 100644
--- a/spec/unit/plugins/aix/uptime_spec.rb
+++ b/spec/unit/plugins/aix/uptime_spec.rb
@@ -24,7 +24,7 @@ describe Ohai::System, "Aix plugin uptime" do
@plugin.stub(:collect_os).and_return(:aix)
Time.stub_chain(:now, :to_i).and_return(1374258600)
DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1373392260)
- @plugin.stub(:popen4).with("who -b").and_yield(nil, StringIO.new, StringIO.new(" . system boot Jul 9 17:51"), nil)
+ @plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Jul 9 17:51", nil))
@plugin.run
end