ohai 6.24.0.rc.0 → 6.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75f76d654069d4ef12d8a6a3d30e9348e5bb27e3
4
- data.tar.gz: 7c95096035412a72d52dac6eb4acc0e9d0475f01
3
+ metadata.gz: ea95d6137035fa5e4065985fda8ee793152bfb70
4
+ data.tar.gz: b8f8ebc64d0d228542eca403be15715dae942e51
5
5
  SHA512:
6
- metadata.gz: 488496d1bd45d87ef018be9593e4b6d42a1643e5bd4a9d8a297484d67bddc61d1ffaf30eb3b26d11d8a444a3402bee6426f7306a059c0d8a880faa080deb8e8f
7
- data.tar.gz: e58cf67c4549c12ef3e6637300d704a1cfbb4204f05fe7a76c49398dcc345091159ffcf47b35c383330b05e49a50790bad5e37dcae941210d8f11fce8ded1b05
6
+ metadata.gz: 0a2bd36af0e8368ec8dcf6e95ef9833e546a956ba84c839c711ad8708a790468d3d3782f428e1ed58f662e48a4e5a4cee0d068f90332af71311f1c40ea088c23
7
+ data.tar.gz: cb3ec503e6c4fd6ec4d8aecaf338d5c3a1d2bcfc1b44bb98fd1eb8316dcc8579f739abd5dc8aad82fc53175c9627ebf49ed74046370a8344e23bd69d6b26a5b0
@@ -52,11 +52,21 @@ stdout.each_line do |line|
52
52
  end
53
53
  end
54
54
 
55
- # Gather more filesystem types via libuuid, even devices that's aren't mounted
56
- popen4("blkid -s TYPE") do |pid, stdin, stdout, stderr|
55
+ have_lsblk = File.exists?('/bin/lsblk')
56
+
57
+ # Gather more filesystem types via libuuid/libblkid even devices that
58
+ # aren't mounted
59
+ if have_lsblk
60
+ cmd = 'lsblk -r -o NAME,FSTYPE -n'
61
+ regex = /^(\S+) (\S+)/
62
+ else
63
+ cmd = 'blkid -s TYPE'
64
+ regex = /^(\S+): TYPE="(\S+)"/
65
+ end
66
+ popen4(cmd) do |pid, stdin, stdout, stderr|
57
67
  stdin.close
58
68
  stdout.each do |line|
59
- if line =~ /^(\S+): TYPE="(\S+)"/
69
+ if line =~ regex
60
70
  filesystem = $1
61
71
  fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
62
72
  fs[filesystem][:fs_type] = $2
@@ -64,11 +74,18 @@ popen4("blkid -s TYPE") do |pid, stdin, stdout, stderr|
64
74
  end
65
75
  end
66
76
 
67
- # Gather device UUIDs via libuuid
68
- popen4("blkid -s UUID") do |pid, stdin, stdout, stderr|
77
+ if have_lsblk
78
+ cmd = 'lsblk -r -o NAME,UUID -n'
79
+ regex = /^(\S+) (\S+)/
80
+ else
81
+ cmd = 'blkid -s UUID'
82
+ regex = /^(\S+): UUID="(\S+)"/
83
+ end
84
+
85
+ popen4(cmd) do |pid, stdin, stdout, stderr|
69
86
  stdin.close
70
87
  stdout.each do |line|
71
- if line =~ /^(\S+): UUID="(\S+)"/
88
+ if line =~ regex
72
89
  filesystem = $1
73
90
  fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
74
91
  fs[filesystem][:uuid] = $2
@@ -76,11 +93,18 @@ popen4("blkid -s UUID") do |pid, stdin, stdout, stderr|
76
93
  end
77
94
  end
78
95
 
79
- # Gather device labels via libuuid
80
- popen4("blkid -s LABEL") do |pid, stdin, stdout, stderr|
96
+ if have_lsblk
97
+ cmd = 'lsblk -r -o NAME,LABEL -n'
98
+ regex = /^(\S+) (\S+)/
99
+ else
100
+ cmd = 'blkid -s LABEL'
101
+ regex = /^(\S+): LABEL="(\S+)"/
102
+ end
103
+
104
+ popen4(cmd) do |pid, stdin, stdout, stderr|
81
105
  stdin.close
82
106
  stdout.each do |line|
83
- if line =~ /^(\S+): LABEL="(\S+)"/
107
+ if line =~ regex
84
108
  filesystem = $1
85
109
  fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
86
110
  fs[filesystem][:label] = $2
@@ -90,7 +114,24 @@ end
90
114
 
91
115
  # Grab any missing mount information from /proc/mounts
92
116
  if File.exists?('/proc/mounts')
93
- File.open('/proc/mounts').read_nonblock(4096).each_line do |line|
117
+ mounts = ''
118
+ # Due to https://tickets.opscode.com/browse/OHAI-196
119
+ # we have to non-block read dev files. Ew.
120
+ f = File.open('/proc/mounts')
121
+ loop do
122
+ begin
123
+ data = f.read_nonblock(4096)
124
+ mounts << data
125
+ # We should just catch EOFError, but the kernel had a period of
126
+ # bugginess with reading virtual files, so we're being extra
127
+ # cautious here, catching all exceptions, and then we'll read
128
+ # whatever data we might have
129
+ rescue Exception
130
+ break
131
+ end
132
+ end
133
+ f.close
134
+ mounts.each_line do |line|
94
135
  if line =~ /^(\S+) (\S+) (\S+) (\S+) \S+ \S+$/
95
136
  filesystem = $1
96
137
  next if fs.has_key?(filesystem)
@@ -201,13 +201,22 @@ if File.exist?("/sbin/ip")
201
201
  # the routing table source field.
202
202
  # 3) and since we're at it, let's populate some :routes attributes
203
203
  # (going to do that for both inet and inet6 addresses)
204
- popen4("ip -f #{family[:name]} route show") do |pid, stdin, stdout, stderr|
204
+ popen4("ip -o -f #{family[:name]} route show") do |pid, stdin, stdout, stderr|
205
205
  stdin.close
206
206
  stdout.each do |line|
207
- if line =~ /^([^\s]+)\s(.*)$/
207
+ line.strip!
208
+ Ohai::Log.debug("Parsing #{line}")
209
+ if line =~ /\\/
210
+ parts = line.split('\\')
211
+ route_dest = parts.shift.strip
212
+ route_endings = parts
213
+ elsif line =~ /^([^\s]+)\s(.*)$/
208
214
  route_dest = $1
209
- route_ending = $2
210
- #
215
+ route_endings = [$2]
216
+ else
217
+ next
218
+ end
219
+ route_endings.each do |route_ending|
211
220
  if route_ending =~ /\bdev\s+([^\s]+)\b/
212
221
  route_int = $1
213
222
  else
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = '6.24.0.rc.0'
21
+ VERSION = '6.24.0'
22
22
  end
@@ -42,10 +42,15 @@ describe Ohai::System, "Linux filesystem plugin" do
42
42
 
43
43
  @ohai.stub!(:run_command).with(@df_cmd).and_return([0,stdout,stderr])
44
44
  @ohai.stub!(:run_command).with(@mount_cmd).and_return([0,stdout,stderr])
45
+ File.stub!(:exists?).with("/bin/lsblk").and_return(false)
45
46
  @ohai.stub!(:popen4).with("blkid -s TYPE").and_return(false)
46
47
  @ohai.stub!(:popen4).with("blkid -s UUID").and_return(false)
47
48
  @ohai.stub!(:popen4).with("blkid -s LABEL").and_return(false)
48
49
 
50
+ @ohai.stub!(:popen4).with("lsblk -r -o NAME,FSTYPE -n").and_return(false)
51
+ @ohai.stub!(:popen4).with("lsblk -r -o NAME,UUID -n").and_return(false)
52
+ @ohai.stub!(:popen4).with("lsblk -r -o NAME,LABEL -n").and_return(false)
53
+
49
54
  File.stub!(:exists?).with("/proc/mounts").and_return(false)
50
55
  end
51
56
 
@@ -192,6 +197,37 @@ describe Ohai::System, "Linux filesystem plugin" do
192
197
  end
193
198
  end
194
199
 
200
+ describe "when gathering filesystem type data from lsblk" do
201
+ before(:each) do
202
+ File.stub!(:exists?).with('/bin/lsblk').and_return(true)
203
+ @stdin = mock("STDIN", { :close => true })
204
+ @pid = 10
205
+ @stderr = mock("STDERR")
206
+ @stdout = mock("STDOUT")
207
+ @status = 0
208
+
209
+ @stdout.stub!(:each).
210
+ and_yield("/dev/sdb1 linux_raid_member").
211
+ and_yield("/dev/sdb2 linux_raid_member").
212
+ and_yield("/dev/sda1 linux_raid_member").
213
+ and_yield("/dev/sda2 linux_raid_member").
214
+ and_yield("/dev/md0 ext3").
215
+ and_yield("/dev/md1 LVM2_member").
216
+ and_yield("/dev/mapper/sys.vg-root.lv ext4").
217
+ and_yield("/dev/mapper/sys.vg-swap.lv swap").
218
+ and_yield("/dev/mapper/sys.vg-tmp.lv ext4").
219
+ and_yield("/dev/mapper/sys.vg-usr.lv ext4").
220
+ and_yield("/dev/mapper/sys.vg-var.lv ext4").
221
+ and_yield("/dev/mapper/sys.vg-home.lv xfs")
222
+ end
223
+
224
+ it "should run lsblk -r -o NAME,FSTYPE -n" do
225
+ @ohai.should_receive(:popen4).with("lsblk -r -o NAME,FSTYPE -n").
226
+ and_return(true)
227
+ @ohai._require_plugin("linux::filesystem")
228
+ end
229
+ end
230
+
195
231
  describe "when gathering filesystem uuid data from blkid" do
196
232
  before(:each) do
197
233
  @stdin = mock("STDIN", { :close => true })
@@ -227,6 +263,44 @@ describe Ohai::System, "Linux filesystem plugin" do
227
263
  end
228
264
  end
229
265
 
266
+ describe "when gathering filesystem uuid data from lsblk" do
267
+ before(:each) do
268
+ File.stub!(:exists?).with('/bin/lsblk').and_return(true)
269
+ @stdin = mock("STDIN", { :close => true })
270
+ @pid = 10
271
+ @stderr = mock("STDERR")
272
+ @stdout = mock("STDOUT")
273
+ @status = 0
274
+
275
+ @stdout.stub!(:each).
276
+ and_yield("/dev/sdb1 bd1197e0-6997-1f3a-e27e-7801388308b5").
277
+ and_yield("/dev/sdb2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa").
278
+ and_yield("/dev/sda1 bd1197e0-6997-1f3a-e27e-7801388308b5").
279
+ and_yield("/dev/sda2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa").
280
+ and_yield("/dev/md0 37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32").
281
+ and_yield("/dev/md1 YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK").
282
+ and_yield("/dev/mapper/sys.vg-root.lv 7742d14b-80a3-4e97-9a32-478be9ea9aea").
283
+ and_yield("/dev/mapper/sys.vg-swap.lv 9bc2e515-8ddc-41c3-9f63-4eaebde9ce96").
284
+ and_yield("/dev/mapper/sys.vg-tmp.lv 74cf7eb9-428f-479e-9a4a-9943401e81e5").
285
+ and_yield("/dev/mapper/sys.vg-usr.lv 26ec33c5-d00b-4f88-a550-492def013bbc").
286
+ and_yield("/dev/mapper/sys.vg-var.lv 6b559c35-7847-4ae2-b512-c99012d3f5b3").
287
+ and_yield("/dev/mapper/sys.vg-home.lv d6efda02-1b73-453c-8c74-7d8dee78fa5e")
288
+ end
289
+
290
+ it "should run lsblk -r -o NAME,UUID -n" do
291
+ @ohai.should_receive(:popen4).with("lsblk -r -o NAME,UUID -n").
292
+ and_return(true)
293
+ @ohai._require_plugin("linux::filesystem")
294
+ end
295
+
296
+ it "should set kb_size to value from lsblk -r -o NAME,UUID -n" do
297
+ @ohai.stub!(:popen4).with("lsblk -r -o NAME,UUID -n").
298
+ and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
299
+ @ohai._require_plugin("linux::filesystem")
300
+ @ohai[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
301
+ end
302
+ end
303
+
230
304
  describe "when gathering filesystem label data from blkid" do
231
305
  before(:each) do
232
306
  @stdin = mock("STDIN", { :close => true })
@@ -260,28 +334,73 @@ describe Ohai::System, "Linux filesystem plugin" do
260
334
  end
261
335
  end
262
336
 
337
+ describe "when gathering filesystem label data from lsblk" do
338
+ before(:each) do
339
+ File.stub!(:exists?).with('/bin/lsblk').and_return(true)
340
+ @stdin = mock("STDIN", { :close => true })
341
+ @pid = 10
342
+ @stderr = mock("STDERR")
343
+ @stdout = mock("STDOUT")
344
+ @status = 0
345
+
346
+ @stdout.stub!(:each).
347
+ and_yield("/dev/sda1 fuego:0").
348
+ and_yield("/dev/sda2 fuego:1").
349
+ and_yield("/dev/sdb1 fuego:0").
350
+ and_yield("/dev/sdb2 fuego:1").
351
+ and_yield("/dev/md0 /boot").
352
+ and_yield("/dev/mapper/sys.vg-root.lv /").
353
+ and_yield("/dev/mapper/sys.vg-tmp.lv /tmp").
354
+ and_yield("/dev/mapper/sys.vg-usr.lv /usr").
355
+ and_yield("/dev/mapper/sys.vg-var.lv /var").
356
+ and_yield("/dev/mapper/sys.vg-home.lv /home")
357
+ end
358
+
359
+ it "should run lsblk -r -o NAME,LABEL -n" do
360
+ @ohai.should_receive(:popen4).with("lsblk -r -o NAME,LABEL -n").
361
+ and_return(true)
362
+ @ohai._require_plugin("linux::filesystem")
363
+ end
364
+
365
+ it "should set kb_size to value from lsblk -r -o NAME,LABEL -n" do
366
+ @ohai.stub!(:popen4).with("lsblk -r -o NAME,LABEL -n").
367
+ and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
368
+ @ohai._require_plugin("linux::filesystem")
369
+ @ohai[:filesystem]["/dev/md0"][:label].should be == "/boot"
370
+ end
371
+ end
372
+
373
+
263
374
  describe "when gathering data from /proc/mounts" do
264
375
  before(:each) do
265
376
  File.stub!(:exists?).with("/proc/mounts").and_return(true)
266
377
  @mock_file = mock("/proc/mounts")
267
378
  @mock_file.stub!(:read_nonblock).and_return(@mock_file)
268
- @mock_file.stub!(:each_line).
269
- and_yield("rootfs / rootfs rw 0 0").
270
- and_yield("none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0").
271
- and_yield("none /proc proc rw,nosuid,nodev,noexec,relatime 0 0").
272
- and_yield("none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0").
273
- and_yield("none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0").
274
- and_yield("/dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0").
275
- and_yield("tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0").
276
- and_yield("tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0").
277
- and_yield("/dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0").
278
- and_yield("/dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0").
279
- and_yield("/dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0").
280
- and_yield("/dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0").
281
- and_yield("/dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0").
282
- and_yield("/dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0").
283
- and_yield("fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0").
284
- and_yield("binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0")
379
+ @mounts = <<-MOUNTS
380
+ rootfs / rootfs rw 0 0
381
+ none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
382
+ none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
383
+ none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0
384
+ none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
385
+ /dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0
386
+ tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
387
+ tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0
388
+ /dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0
389
+ /dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0
390
+ /dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0
391
+ /dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0
392
+ /dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0
393
+ /dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0
394
+ fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
395
+ binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
396
+ MOUNTS
397
+ @counter = 0
398
+ @mock_file.stub(:read_nonblock) do
399
+ @counter += 1
400
+ raise EOFError if @counter == 2
401
+ @mounts
402
+ end
403
+ @mock_file.stub(:close)
285
404
  File.stub!(:open).with("/proc/mounts").and_return(@mock_file)
286
405
  end
287
406
 
@@ -300,5 +419,4 @@ describe Ohai::System, "Linux filesystem plugin" do
300
419
  @ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime", "attr2", "noquota" ]
301
420
  end
302
421
  end
303
-
304
422
  end
@@ -45,8 +45,8 @@ def do_stubs
45
45
  @ohai.stub!(:popen4).with("ip -f inet6 neigh show").and_yield(nil, @stdin_ipneighbor_inet6, @ipneighbor_lines_inet6, nil)
46
46
  @ohai.stub!(:popen4).with("ip addr").and_yield(nil, @stdin_ipaddr, @ipaddr_lines, nil)
47
47
  @ohai.stub!(:popen4).with("ip -d -s link").and_yield(nil, @stdin_iplink, @iplink_lines, nil)
48
- @ohai.stub!(:popen4).with("ip -f inet route show").and_yield(nil, @stdin_ip_route, @ip_route_lines, nil)
49
- @ohai.stub!(:popen4).with("ip -f inet6 route show").and_yield(nil, @stdin_ip_route_inet6, @ip_route_inet6_lines, nil)
48
+ @ohai.stub!(:popen4).with("ip -o -f inet route show").and_yield(nil, @stdin_ip_route, @ip_route_lines, nil)
49
+ @ohai.stub!(:popen4).with("ip -o -f inet6 route show").and_yield(nil, @stdin_ip_route_inet6, @ip_route_inet6_lines, nil)
50
50
  end
51
51
 
52
52
  describe Ohai::System, "Linux Network Plugin" do
@@ -256,6 +256,7 @@ NEIGHBOR_SHOW
256
256
  192.168.212.0/24 dev foo:veth0@eth0 proto kernel src 192.168.212.2
257
257
  172.16.151.0/24 dev eth0 proto kernel src 172.16.151.100
258
258
  192.168.0.0/24 dev eth0 proto kernel src 192.168.0.2
259
+ 10.5.4.0/24 \\ nexthop via 10.5.4.1 dev eth0 weight 1\\ nexthop via 10.5.4.2 dev eth0 weight 1
259
260
  default via 10.116.201.1 dev eth0
260
261
  IP_ROUTE_SCOPE
261
262
 
@@ -584,6 +585,8 @@ ROUTE_N
584
585
  it "adds routes" do
585
586
  @ohai._require_plugin("linux::network")
586
587
  @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.116.201.0/24", :proto => "kernel", :family =>"inet" )
588
+ @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.1")
589
+ @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "10.5.4.0/24", :family =>"inet", :via => "10.5.4.2")
587
590
  @ohai['network']['interfaces']['foo:veth0@eth0']['routes'].should include Mash.new( :destination => "192.168.212.0/24", :proto => "kernel", :src => "192.168.212.2", :family =>"inet" )
588
591
  @ohai['network']['interfaces']['eth0']['routes'].should include Mash.new( :destination => "fe80::/64", :metric => "256", :proto => "kernel", :family => "inet6" )
589
592
  @ohai['network']['interfaces']['eth0.11']['routes'].should include Mash.new( :destination => "1111:2222:3333:4444::/64", :metric => "1024", :family => "inet6" )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.24.0.rc.0
4
+ version: 6.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -430,9 +430,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
430
430
  version: '0'
431
431
  required_rubygems_version: !ruby/object:Gem::Requirement
432
432
  requirements:
433
- - - ">"
433
+ - - ">="
434
434
  - !ruby/object:Gem::Version
435
- version: 1.3.1
435
+ version: '0'
436
436
  requirements: []
437
437
  rubyforge_project:
438
438
  rubygems_version: 2.2.2