ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -21,11 +21,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
|
22
22
|
describe Ohai::System, "Linux cpu plugin" do
|
23
23
|
before(:each) do
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@mock_file.stub!(:each).
|
24
|
+
@plugin = get_plugin("linux/cpu")
|
25
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
26
|
+
@double_file = double("/proc/cpuinfo")
|
27
|
+
@double_file.stub(:each).
|
29
28
|
and_yield("processor : 0").
|
30
29
|
and_yield("vendor_id : GenuineIntel").
|
31
30
|
and_yield("cpu family : 6").
|
@@ -45,84 +44,84 @@ describe Ohai::System, "Linux cpu plugin" do
|
|
45
44
|
and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov").
|
46
45
|
and_yield("bogomips : 2575.86").
|
47
46
|
and_yield("clflush size : 32")
|
48
|
-
File.stub
|
47
|
+
File.stub(:open).with("/proc/cpuinfo").and_return(@double_file)
|
49
48
|
end
|
50
49
|
|
51
50
|
it "should set cpu[:total] to 1" do
|
52
|
-
@
|
53
|
-
@
|
51
|
+
@plugin.run
|
52
|
+
@plugin[:cpu][:total].should == 1
|
54
53
|
end
|
55
54
|
|
56
55
|
it "should set cpu[:real] to 0" do
|
57
|
-
@
|
58
|
-
@
|
56
|
+
@plugin.run
|
57
|
+
@plugin[:cpu][:real].should == 0
|
59
58
|
end
|
60
59
|
|
61
60
|
it "should have a cpu 0" do
|
62
|
-
@
|
63
|
-
@
|
61
|
+
@plugin.run
|
62
|
+
@plugin[:cpu].should have_key("0")
|
64
63
|
end
|
65
64
|
|
66
65
|
it "should have a vendor_id for cpu 0" do
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
66
|
+
@plugin.run
|
67
|
+
@plugin[:cpu]["0"].should have_key("vendor_id")
|
68
|
+
@plugin[:cpu]["0"]["vendor_id"].should eql("GenuineIntel")
|
70
69
|
end
|
71
70
|
|
72
71
|
it "should have a family for cpu 0" do
|
73
|
-
@
|
74
|
-
@
|
75
|
-
@
|
72
|
+
@plugin.run
|
73
|
+
@plugin[:cpu]["0"].should have_key("family")
|
74
|
+
@plugin[:cpu]["0"]["family"].should eql("6")
|
76
75
|
end
|
77
76
|
|
78
77
|
it "should have a model for cpu 0" do
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@
|
78
|
+
@plugin.run
|
79
|
+
@plugin[:cpu]["0"].should have_key("model")
|
80
|
+
@plugin[:cpu]["0"]["model"].should eql("23")
|
82
81
|
end
|
83
82
|
|
84
83
|
it "should have a stepping for cpu 0" do
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@
|
84
|
+
@plugin.run
|
85
|
+
@plugin[:cpu]["0"].should have_key("stepping")
|
86
|
+
@plugin[:cpu]["0"]["stepping"].should eql("6")
|
88
87
|
end
|
89
88
|
|
90
89
|
it "should not have a phyiscal_id for cpu 0" do
|
91
|
-
@
|
92
|
-
@
|
90
|
+
@plugin.run
|
91
|
+
@plugin[:cpu]["0"].should_not have_key("physical_id")
|
93
92
|
end
|
94
93
|
|
95
94
|
it "should not have a core_id for cpu 0" do
|
96
|
-
@
|
97
|
-
@
|
95
|
+
@plugin.run
|
96
|
+
@plugin[:cpu]["0"].should_not have_key("core_id")
|
98
97
|
end
|
99
98
|
|
100
99
|
it "should not have a cores for cpu 0" do
|
101
|
-
@
|
102
|
-
@
|
100
|
+
@plugin.run
|
101
|
+
@plugin[:cpu]["0"].should_not have_key("cores")
|
103
102
|
end
|
104
103
|
|
105
104
|
it "should have a model name for cpu 0" do
|
106
|
-
@
|
107
|
-
@
|
108
|
-
@
|
105
|
+
@plugin.run
|
106
|
+
@plugin[:cpu]["0"].should have_key("model_name")
|
107
|
+
@plugin[:cpu]["0"]["model_name"].should eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
|
109
108
|
end
|
110
109
|
|
111
110
|
it "should have a mhz for cpu 0" do
|
112
|
-
@
|
113
|
-
@
|
114
|
-
@
|
111
|
+
@plugin.run
|
112
|
+
@plugin[:cpu]["0"].should have_key("mhz")
|
113
|
+
@plugin[:cpu]["0"]["mhz"].should eql("1968.770")
|
115
114
|
end
|
116
115
|
|
117
116
|
it "should have a cache_size for cpu 0" do
|
118
|
-
@
|
119
|
-
@
|
120
|
-
@
|
117
|
+
@plugin.run
|
118
|
+
@plugin[:cpu]["0"].should have_key("cache_size")
|
119
|
+
@plugin[:cpu]["0"]["cache_size"].should eql("64 KB")
|
121
120
|
end
|
122
121
|
|
123
122
|
it "should have flags for cpu 0" do
|
124
|
-
@
|
125
|
-
@
|
126
|
-
@
|
123
|
+
@plugin.run
|
124
|
+
@plugin[:cpu]["0"].should have_key("flags")
|
125
|
+
@plugin[:cpu]["0"]["flags"].should == %w{fpu pse tsc msr mce cx8 sep mtrr pge cmov}
|
127
126
|
end
|
128
|
-
end
|
127
|
+
end
|
@@ -20,418 +20,237 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux filesystem plugin" do
|
22
22
|
before(:each) do
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@ohai.stub!(:require_plugin).and_return(true)
|
26
|
-
@ohai.extend(SimpleFromFile)
|
23
|
+
@plugin = get_plugin("linux/filesystem")
|
24
|
+
@plugin.stub(:collect_os).and_return(:linux)
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
@plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
|
27
|
+
@plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
28
|
+
@plugin.stub(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
|
29
|
+
@plugin.stub(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
|
30
|
+
@plugin.stub(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
|
32
31
|
|
33
|
-
|
34
|
-
:command => "df -P",
|
35
|
-
:timeout => 120,
|
36
|
-
:no_status_check => true
|
37
|
-
}
|
38
|
-
@mount_cmd = {
|
39
|
-
:command => "mount",
|
40
|
-
:timeout => 120,
|
41
|
-
}
|
42
|
-
|
43
|
-
@ohai.stub!(:run_command).with(@df_cmd).and_return([0,stdout,stderr])
|
44
|
-
@ohai.stub!(:run_command).with(@mount_cmd).and_return([0,stdout,stderr])
|
45
|
-
File.stub!(:exists?).with("/bin/lsblk").and_return(false)
|
46
|
-
@ohai.stub!(:popen4).with("blkid -s TYPE").and_return(false)
|
47
|
-
@ohai.stub!(:popen4).with("blkid -s UUID").and_return(false)
|
48
|
-
@ohai.stub!(:popen4).with("blkid -s LABEL").and_return(false)
|
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
|
-
|
54
|
-
File.stub!(:exists?).with("/proc/mounts").and_return(false)
|
55
|
-
|
56
|
-
%w{sdb1 sdb2 sda1 sda2 md0 md1 md2}.each do |name|
|
57
|
-
File.stub!(:exist?).with("/dev/#{name}").and_return(true)
|
58
|
-
end
|
59
|
-
%w{
|
60
|
-
sys.vg-root.lv
|
61
|
-
sys.vg-swap.lv
|
62
|
-
sys.vg-tmp.lv
|
63
|
-
sys.vg-usr.lv
|
64
|
-
sys.vg-var.lv
|
65
|
-
sys.vg-home.lv
|
66
|
-
}.each do |name|
|
67
|
-
File.stub!(:exist?).with("/dev/#{name}").and_return(false)
|
68
|
-
File.stub!(:exist?).with("/dev/mapper/#{name}").and_return(true)
|
69
|
-
end
|
32
|
+
File.stub(:exists?).with("/proc/mounts").and_return(false)
|
70
33
|
end
|
71
34
|
|
72
35
|
describe "when gathering filesystem usage data from df" do
|
73
36
|
before(:each) do
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
and_yield("/dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp").
|
89
|
-
and_yield("/dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr").
|
90
|
-
and_yield("/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var").
|
91
|
-
and_yield("/dev/md0 960492 36388 875312 4% /boot")
|
37
|
+
@stdout = <<-DF
|
38
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
39
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
40
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
41
|
+
udev 2025576 228 2025348 1% /dev
|
42
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
43
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
44
|
+
/dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
|
45
|
+
/dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
|
46
|
+
/dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
|
47
|
+
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
|
48
|
+
/dev/md0 960492 36388 875312 4% /boot
|
49
|
+
DF
|
50
|
+
@plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
|
92
51
|
end
|
93
52
|
|
94
53
|
it "should run df -P" do
|
95
|
-
@
|
96
|
-
@
|
54
|
+
@plugin.should_receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
|
55
|
+
@plugin.run
|
97
56
|
end
|
98
57
|
|
99
58
|
it "should set kb_size to value from df -P" do
|
100
|
-
@
|
101
|
-
@
|
102
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size].should be == "97605057"
|
59
|
+
@plugin.run
|
60
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size].should be == "97605057"
|
103
61
|
end
|
104
62
|
|
105
63
|
it "should set kb_used to value from df -P" do
|
106
|
-
@
|
107
|
-
@
|
108
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used].should be == "53563253"
|
64
|
+
@plugin.run
|
65
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used].should be == "53563253"
|
109
66
|
end
|
110
67
|
|
111
68
|
it "should set kb_available to value from df -P" do
|
112
|
-
@
|
113
|
-
@
|
114
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available].should be == "44041805"
|
69
|
+
@plugin.run
|
70
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available].should be == "44041805"
|
115
71
|
end
|
116
72
|
|
117
73
|
it "should set percent_used to value from df -P" do
|
118
|
-
@
|
119
|
-
@
|
120
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used].should be == "56%"
|
74
|
+
@plugin.run
|
75
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used].should be == "56%"
|
121
76
|
end
|
122
77
|
|
123
78
|
it "should set mount to value from df -P" do
|
124
|
-
@
|
125
|
-
@
|
126
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
|
79
|
+
@plugin.run
|
80
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
|
127
81
|
end
|
128
82
|
end
|
129
83
|
|
130
84
|
describe "when gathering mounted filesystem data from mount" do
|
131
85
|
before(:each) do
|
132
|
-
@
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
and_yield("/dev/mapper/sys.vg-var.lv on /var type ext4 (rw,noatime)").
|
151
|
-
and_yield("/dev/md0 on /boot type ext3 (rw,noatime,errors=remount-ro)").
|
152
|
-
and_yield("fusectl on /sys/fs/fuse/connections type fusectl (rw)").
|
153
|
-
and_yield("binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)")
|
86
|
+
@stdout = <<-MOUNT
|
87
|
+
/dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro)
|
88
|
+
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
|
89
|
+
proc on /proc type proc (rw,noexec,nosuid,nodev)
|
90
|
+
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
|
91
|
+
udev on /dev type tmpfs (rw,mode=0755)
|
92
|
+
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
|
93
|
+
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
|
94
|
+
/dev/mapper/sys.vg-home.lv on /home type xfs (rw,noatime)
|
95
|
+
/dev/mapper/sys.vg-special.lv on /special type xfs (ro,noatime)
|
96
|
+
/dev/mapper/sys.vg-tmp.lv on /tmp type ext4 (rw,noatime)
|
97
|
+
/dev/mapper/sys.vg-usr.lv on /usr type ext4 (rw,noatime)
|
98
|
+
/dev/mapper/sys.vg-var.lv on /var type ext4 (rw,noatime)
|
99
|
+
/dev/md0 on /boot type ext3 (rw,noatime,errors=remount-ro)
|
100
|
+
fusectl on /sys/fs/fuse/connections type fusectl (rw)
|
101
|
+
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
|
102
|
+
MOUNT
|
103
|
+
@plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
|
154
104
|
end
|
155
105
|
|
156
106
|
it "should run mount" do
|
157
|
-
@
|
158
|
-
@
|
107
|
+
@plugin.should_receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
|
108
|
+
@plugin.run
|
159
109
|
end
|
160
110
|
|
161
111
|
it "should set mount to value from mount" do
|
162
|
-
@
|
163
|
-
@
|
164
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
|
112
|
+
@plugin.run
|
113
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
|
165
114
|
end
|
166
115
|
|
167
116
|
it "should set fs_type to value from mount" do
|
168
|
-
@
|
169
|
-
@
|
170
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs"
|
117
|
+
@plugin.run
|
118
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs"
|
171
119
|
end
|
172
120
|
|
173
121
|
it "should set mount_options to an array of values from mount" do
|
174
|
-
@
|
175
|
-
@
|
176
|
-
@ohai[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime" ]
|
122
|
+
@plugin.run
|
123
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime" ]
|
177
124
|
end
|
178
125
|
end
|
179
126
|
|
180
127
|
describe "when gathering filesystem type data from blkid" do
|
181
128
|
before(:each) do
|
182
|
-
@
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
and_yield("/dev/mapper/sys.vg-tmp.lv: TYPE=\"ext4\" ").
|
198
|
-
and_yield("/dev/mapper/sys.vg-usr.lv: TYPE=\"ext4\" ").
|
199
|
-
and_yield("/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\" ").
|
200
|
-
and_yield("/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\" ")
|
129
|
+
@stdout = <<-BLKID_TYPE
|
130
|
+
dev/sdb1: TYPE=\"linux_raid_member\"
|
131
|
+
/dev/sdb2: TYPE=\"linux_raid_member\"
|
132
|
+
/dev/sda1: TYPE=\"linux_raid_member\"
|
133
|
+
/dev/sda2: TYPE=\"linux_raid_member\"
|
134
|
+
/dev/md0: TYPE=\"ext3\"
|
135
|
+
/dev/md1: TYPE=\"LVM2_member\"
|
136
|
+
/dev/mapper/sys.vg-root.lv: TYPE=\"ext4\"
|
137
|
+
/dev/mapper/sys.vg-swap.lv: TYPE=\"swap\"
|
138
|
+
/dev/mapper/sys.vg-tmp.lv: TYPE=\"ext4\"
|
139
|
+
/dev/mapper/sys.vg-usr.lv: TYPE=\"ext4\"
|
140
|
+
/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\"
|
141
|
+
/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\"
|
142
|
+
BLKID_TYPE
|
143
|
+
@plugin.stub(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
|
201
144
|
end
|
202
145
|
|
203
146
|
it "should run blkid -s TYPE" do
|
204
|
-
@
|
205
|
-
@
|
147
|
+
@plugin.should_receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
|
148
|
+
@plugin.run
|
206
149
|
end
|
207
150
|
|
208
151
|
it "should set kb_size to value from blkid -s TYPE" do
|
209
|
-
@
|
210
|
-
@
|
211
|
-
@ohai[:filesystem]["/dev/md1"][:fs_type].should be == "LVM2_member"
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
describe "when gathering filesystem type data from lsblk" do
|
216
|
-
before(:each) do
|
217
|
-
File.stub!(:exists?).with('/bin/lsblk').and_return(true)
|
218
|
-
@stdin = mock("STDIN", { :close => true })
|
219
|
-
@pid = 10
|
220
|
-
@stderr = mock("STDERR")
|
221
|
-
@stdout = mock("STDOUT")
|
222
|
-
@status = 0
|
223
|
-
|
224
|
-
@stdout.stub!(:each).
|
225
|
-
and_yield("sdb1 linux_raid_member").
|
226
|
-
and_yield("sdb2 linux_raid_member").
|
227
|
-
and_yield("sda1 linux_raid_member").
|
228
|
-
and_yield("sda2 linux_raid_member").
|
229
|
-
and_yield("md0 ext3").
|
230
|
-
and_yield("md1 LVM2_member").
|
231
|
-
and_yield("sys.vg-root.lv ext4").
|
232
|
-
and_yield("sys.vg-swap.lv swap").
|
233
|
-
and_yield("sys.vg-tmp.lv ext4").
|
234
|
-
and_yield("sys.vg-usr.lv ext4").
|
235
|
-
and_yield("sys.vg-var.lv ext4").
|
236
|
-
and_yield("sys.vg-home.lv xfs")
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should run lsblk -r -o NAME,FSTYPE -n" do
|
240
|
-
@ohai.should_receive(:popen4).with("lsblk -r -o NAME,FSTYPE -n").
|
241
|
-
and_return(true)
|
242
|
-
@ohai._require_plugin("linux::filesystem")
|
152
|
+
@plugin.run
|
153
|
+
@plugin[:filesystem]["/dev/md1"][:fs_type].should be == "LVM2_member"
|
243
154
|
end
|
244
155
|
end
|
245
156
|
|
246
157
|
describe "when gathering filesystem uuid data from blkid" do
|
247
158
|
before(:each) do
|
248
|
-
@
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
and_yield("/dev/mapper/sys.vg-tmp.lv: UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" ").
|
264
|
-
and_yield("/dev/mapper/sys.vg-usr.lv: UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" ").
|
265
|
-
and_yield("/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" ").
|
266
|
-
and_yield("/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" ")
|
159
|
+
@stdout = <<-BLKID_UUID
|
160
|
+
/dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\"
|
161
|
+
/dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\"
|
162
|
+
/dev/sda1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\"
|
163
|
+
/dev/sda2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\"
|
164
|
+
/dev/md0: UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\"
|
165
|
+
/dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\"
|
166
|
+
/dev/mapper/sys.vg-root.lv: UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\"
|
167
|
+
/dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\"
|
168
|
+
/dev/mapper/sys.vg-tmp.lv: UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\"
|
169
|
+
/dev/mapper/sys.vg-usr.lv: UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\"
|
170
|
+
/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\"
|
171
|
+
/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\"
|
172
|
+
BLKID_UUID
|
173
|
+
@plugin.stub(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
267
174
|
end
|
268
175
|
|
269
176
|
it "should run blkid -s UUID" do
|
270
|
-
@
|
271
|
-
@
|
177
|
+
@plugin.should_receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
178
|
+
@plugin.run
|
272
179
|
end
|
273
180
|
|
274
181
|
it "should set kb_size to value from blkid -s UUID" do
|
275
|
-
@
|
276
|
-
@
|
277
|
-
@ohai[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
describe "when gathering filesystem uuid data from lsblk" do
|
282
|
-
before(:each) do
|
283
|
-
File.stub!(:exists?).with('/bin/lsblk').and_return(true)
|
284
|
-
@stdin = mock("STDIN", { :close => true })
|
285
|
-
@pid = 10
|
286
|
-
@stderr = mock("STDERR")
|
287
|
-
@stdout = mock("STDOUT")
|
288
|
-
@status = 0
|
289
|
-
|
290
|
-
@stdout.stub!(:each).
|
291
|
-
and_yield("sdb1 bd1197e0-6997-1f3a-e27e-7801388308b5").
|
292
|
-
and_yield("sdb2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa").
|
293
|
-
and_yield("sda1 bd1197e0-6997-1f3a-e27e-7801388308b5").
|
294
|
-
and_yield("sda2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa").
|
295
|
-
and_yield("md0 37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32").
|
296
|
-
and_yield("md1 YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK").
|
297
|
-
and_yield("sys.vg-root.lv 7742d14b-80a3-4e97-9a32-478be9ea9aea").
|
298
|
-
and_yield("sys.vg-swap.lv 9bc2e515-8ddc-41c3-9f63-4eaebde9ce96").
|
299
|
-
and_yield("sys.vg-tmp.lv 74cf7eb9-428f-479e-9a4a-9943401e81e5").
|
300
|
-
and_yield("sys.vg-usr.lv 26ec33c5-d00b-4f88-a550-492def013bbc").
|
301
|
-
and_yield("sys.vg-var.lv 6b559c35-7847-4ae2-b512-c99012d3f5b3").
|
302
|
-
and_yield("sys.vg-home.lv d6efda02-1b73-453c-8c74-7d8dee78fa5e")
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should run lsblk -r -o NAME,UUID -n" do
|
306
|
-
@ohai.should_receive(:popen4).with("lsblk -r -o NAME,UUID -n").
|
307
|
-
and_return(true)
|
308
|
-
@ohai._require_plugin("linux::filesystem")
|
309
|
-
end
|
310
|
-
|
311
|
-
it "should set kb_size to value from lsblk -r -o NAME,UUID -n" do
|
312
|
-
@ohai.stub!(:popen4).with("lsblk -r -o NAME,UUID -n").
|
313
|
-
and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
314
|
-
@ohai._require_plugin("linux::filesystem")
|
315
|
-
@ohai[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
|
182
|
+
@plugin.run
|
183
|
+
@plugin[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
|
316
184
|
end
|
317
185
|
end
|
318
186
|
|
319
187
|
describe "when gathering filesystem label data from blkid" do
|
320
188
|
before(:each) do
|
321
|
-
@
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
and_yield("/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" ").
|
335
|
-
and_yield("/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" ").
|
336
|
-
and_yield("/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" ").
|
337
|
-
and_yield("/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" ")
|
189
|
+
@stdout = <<-BLKID_LABEL
|
190
|
+
/dev/sda1: LABEL=\"fuego:0\"
|
191
|
+
/dev/sda2: LABEL=\"fuego:1\"
|
192
|
+
/dev/sdb1: LABEL=\"fuego:0\"
|
193
|
+
/dev/sdb2: LABEL=\"fuego:1\"
|
194
|
+
/dev/md0: LABEL=\"/boot\"
|
195
|
+
/dev/mapper/sys.vg-root.lv: LABEL=\"/\"
|
196
|
+
/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\"
|
197
|
+
/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\"
|
198
|
+
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\"
|
199
|
+
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\"
|
200
|
+
BLKID_LABEL
|
201
|
+
@plugin.stub(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
338
202
|
end
|
339
203
|
|
340
204
|
it "should run blkid -s LABEL" do
|
341
|
-
@
|
342
|
-
@
|
205
|
+
@plugin.should_receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
206
|
+
@plugin.run
|
343
207
|
end
|
344
208
|
|
345
209
|
it "should set kb_size to value from blkid -s LABEL" do
|
346
|
-
@
|
347
|
-
@
|
348
|
-
@ohai[:filesystem]["/dev/md0"][:label].should be == "/boot"
|
210
|
+
@plugin.run
|
211
|
+
@plugin[:filesystem]["/dev/md0"][:label].should be == "/boot"
|
349
212
|
end
|
350
213
|
end
|
351
214
|
|
352
|
-
describe "when gathering filesystem label data from lsblk" do
|
353
|
-
before(:each) do
|
354
|
-
File.stub!(:exists?).with('/bin/lsblk').and_return(true)
|
355
|
-
@stdin = mock("STDIN", { :close => true })
|
356
|
-
@pid = 10
|
357
|
-
@stderr = mock("STDERR")
|
358
|
-
@stdout = mock("STDOUT")
|
359
|
-
@status = 0
|
360
|
-
|
361
|
-
@stdout.stub!(:each).
|
362
|
-
and_yield("sda1 fuego:0").
|
363
|
-
and_yield("sda2 fuego:1").
|
364
|
-
and_yield("sdb1 fuego:0").
|
365
|
-
and_yield("sdb2 fuego:1").
|
366
|
-
and_yield("md0 /boot").
|
367
|
-
and_yield("sys.vg-root.lv /").
|
368
|
-
and_yield("sys.vg-tmp.lv /tmp").
|
369
|
-
and_yield("sys.vg-usr.lv /usr").
|
370
|
-
and_yield("sys.vg-var.lv /var").
|
371
|
-
and_yield("sys.vg-home.lv /home")
|
372
|
-
end
|
373
|
-
|
374
|
-
it "should run lsblk -r -o NAME,LABEL -n" do
|
375
|
-
@ohai.should_receive(:popen4).with("lsblk -r -o NAME,LABEL -n").
|
376
|
-
and_return(true)
|
377
|
-
@ohai._require_plugin("linux::filesystem")
|
378
|
-
end
|
379
|
-
|
380
|
-
it "should set kb_size to value from lsblk -r -o NAME,LABEL -n" do
|
381
|
-
@ohai.stub!(:popen4).with("lsblk -r -o NAME,LABEL -n").
|
382
|
-
and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
383
|
-
@ohai._require_plugin("linux::filesystem")
|
384
|
-
@ohai[:filesystem]["/dev/md0"][:label].should be == "/boot"
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
|
389
215
|
describe "when gathering data from /proc/mounts" do
|
390
216
|
before(:each) do
|
391
|
-
File.stub
|
392
|
-
@
|
393
|
-
@
|
394
|
-
@
|
395
|
-
rootfs / rootfs rw 0 0
|
396
|
-
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
|
397
|
-
none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
|
398
|
-
none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0
|
399
|
-
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
|
400
|
-
/dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0
|
401
|
-
tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
|
402
|
-
tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0
|
403
|
-
/dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0
|
404
|
-
/dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0
|
405
|
-
/dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0
|
406
|
-
/dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0
|
407
|
-
/dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0
|
408
|
-
/dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0
|
409
|
-
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
|
410
|
-
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
|
411
|
-
|
412
|
-
@counter = 0
|
413
|
-
@mock_file.stub(:read_nonblock) do
|
414
|
-
@counter += 1
|
415
|
-
raise EOFError if @counter == 2
|
416
|
-
@mounts
|
417
|
-
end
|
418
|
-
@mock_file.stub(:close)
|
419
|
-
File.stub!(:open).with("/proc/mounts").and_return(@mock_file)
|
217
|
+
File.stub(:exists?).with("/proc/mounts").and_return(true)
|
218
|
+
@double_file = double("/proc/mounts")
|
219
|
+
@double_file.stub(:read_nonblock).and_return(@double_file)
|
220
|
+
@double_file.stub(:each_line).
|
221
|
+
and_yield("rootfs / rootfs rw 0 0").
|
222
|
+
and_yield("none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0").
|
223
|
+
and_yield("none /proc proc rw,nosuid,nodev,noexec,relatime 0 0").
|
224
|
+
and_yield("none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0").
|
225
|
+
and_yield("none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0").
|
226
|
+
and_yield("/dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0").
|
227
|
+
and_yield("tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0").
|
228
|
+
and_yield("tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0").
|
229
|
+
and_yield("/dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0").
|
230
|
+
and_yield("/dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0").
|
231
|
+
and_yield("/dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0").
|
232
|
+
and_yield("/dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0").
|
233
|
+
and_yield("/dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0").
|
234
|
+
and_yield("/dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0").
|
235
|
+
and_yield("fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0").
|
236
|
+
and_yield("binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0")
|
237
|
+
File.stub(:open).with("/proc/mounts").and_return(@double_file)
|
420
238
|
end
|
421
239
|
|
422
240
|
it "should set mount to value from /proc/mounts" do
|
423
|
-
@
|
424
|
-
@
|
241
|
+
@plugin.run
|
242
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
|
425
243
|
end
|
426
244
|
|
427
245
|
it "should set fs_type to value from /proc/mounts" do
|
428
|
-
@
|
429
|
-
@
|
246
|
+
@plugin.run
|
247
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs"
|
430
248
|
end
|
431
249
|
|
432
250
|
it "should set mount_options to an array of values from /proc/mounts" do
|
433
|
-
@
|
434
|
-
@
|
251
|
+
@plugin.run
|
252
|
+
@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime", "attr2", "noquota" ]
|
435
253
|
end
|
436
254
|
end
|
255
|
+
|
437
256
|
end
|