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.
Files changed (259) hide show
  1. data/lib/ohai.rb +1 -1
  2. data/lib/ohai/application.rb +5 -12
  3. data/lib/ohai/common/dmi.rb +126 -0
  4. data/lib/ohai/config.rb +9 -9
  5. data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
  6. data/lib/ohai/dsl/plugin.rb +186 -0
  7. data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
  8. data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
  9. data/lib/ohai/exception.rb +11 -2
  10. data/lib/ohai/hints.rb +48 -0
  11. data/lib/ohai/loader.rb +205 -0
  12. data/lib/ohai/mixin/command.rb +14 -18
  13. data/lib/ohai/mixin/constant_helper.rb +53 -0
  14. data/lib/ohai/mixin/gce_metadata.rb +0 -2
  15. data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
  16. data/lib/ohai/mixin/os.rb +59 -0
  17. data/lib/ohai/mixin/seconds_to_human.rb +48 -0
  18. data/lib/ohai/plugins/aix/cpu.rb +26 -22
  19. data/lib/ohai/plugins/aix/filesystem.rb +47 -48
  20. data/lib/ohai/plugins/aix/kernel.rb +11 -7
  21. data/lib/ohai/plugins/aix/memory.rb +8 -4
  22. data/lib/ohai/plugins/aix/network.rb +73 -82
  23. data/lib/ohai/plugins/aix/platform.rb +9 -6
  24. data/lib/ohai/plugins/aix/uptime.rb +14 -12
  25. data/lib/ohai/plugins/azure.rb +33 -11
  26. data/lib/ohai/plugins/c.rb +103 -78
  27. data/lib/ohai/plugins/chef.rb +20 -8
  28. data/lib/ohai/plugins/cloud.rb +234 -230
  29. data/lib/ohai/plugins/command.rb +6 -2
  30. data/lib/ohai/plugins/darwin/cpu.rb +10 -4
  31. data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
  32. data/lib/ohai/plugins/darwin/network.rb +157 -154
  33. data/lib/ohai/plugins/darwin/platform.rb +18 -16
  34. data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
  35. data/lib/ohai/plugins/dmi.rb +102 -102
  36. data/lib/ohai/plugins/ec2.rb +30 -28
  37. data/lib/ohai/plugins/erlang.rb +19 -16
  38. data/lib/ohai/plugins/eucalyptus.rb +37 -36
  39. data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
  40. data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
  41. data/lib/ohai/plugins/freebsd/memory.rb +35 -25
  42. data/lib/ohai/plugins/freebsd/network.rb +94 -89
  43. data/lib/ohai/plugins/freebsd/platform.rb +10 -4
  44. data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
  45. data/lib/ohai/plugins/gce.rb +30 -36
  46. data/lib/ohai/plugins/groovy.rb +14 -11
  47. data/lib/ohai/plugins/hostname.rb +132 -10
  48. data/lib/ohai/plugins/ip_scopes.rb +31 -16
  49. data/lib/ohai/plugins/java.rb +45 -21
  50. data/lib/ohai/plugins/kernel.rb +186 -19
  51. data/lib/ohai/plugins/keys.rb +6 -2
  52. data/lib/ohai/plugins/languages.rb +6 -2
  53. data/lib/ohai/plugins/linode.rb +38 -30
  54. data/lib/ohai/plugins/linux/block_device.rb +19 -15
  55. data/lib/ohai/plugins/linux/cpu.rb +42 -38
  56. data/lib/ohai/plugins/linux/filesystem.rb +70 -130
  57. data/lib/ohai/plugins/linux/lsb.rb +35 -35
  58. data/lib/ohai/plugins/linux/memory.rb +65 -61
  59. data/lib/ohai/plugins/linux/network.rb +343 -362
  60. data/lib/ohai/plugins/linux/platform.rb +90 -88
  61. data/lib/ohai/plugins/linux/virtualization.rb +95 -90
  62. data/lib/ohai/plugins/lua.rb +14 -10
  63. data/lib/ohai/plugins/mono.rb +17 -13
  64. data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
  65. data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
  66. data/lib/ohai/plugins/netbsd/memory.rb +59 -59
  67. data/lib/ohai/plugins/netbsd/network.rb +92 -88
  68. data/lib/ohai/plugins/netbsd/platform.rb +10 -3
  69. data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
  70. data/lib/ohai/plugins/network.rb +131 -130
  71. data/lib/ohai/plugins/network_listeners.rb +26 -22
  72. data/lib/ohai/plugins/nodejs.rb +14 -10
  73. data/lib/ohai/plugins/ohai.rb +11 -6
  74. data/lib/ohai/plugins/ohai_time.rb +6 -2
  75. data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
  76. data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
  77. data/lib/ohai/plugins/openbsd/memory.rb +59 -59
  78. data/lib/ohai/plugins/openbsd/network.rb +92 -88
  79. data/lib/ohai/plugins/openbsd/platform.rb +10 -4
  80. data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
  81. data/lib/ohai/plugins/openstack.rb +23 -21
  82. data/lib/ohai/plugins/os.rb +8 -32
  83. data/lib/ohai/plugins/passwd.rb +27 -22
  84. data/lib/ohai/plugins/perl.rb +21 -16
  85. data/lib/ohai/plugins/php.rb +15 -12
  86. data/lib/ohai/plugins/platform.rb +9 -9
  87. data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
  88. data/lib/ohai/plugins/python.rb +16 -12
  89. data/lib/ohai/plugins/rackspace.rb +82 -77
  90. data/lib/ohai/plugins/root_group.rb +13 -9
  91. data/lib/ohai/plugins/ruby.rb +50 -48
  92. data/lib/ohai/plugins/sigar/cpu.rb +21 -17
  93. data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
  94. data/lib/ohai/plugins/sigar/memory.rb +17 -14
  95. data/lib/ohai/plugins/sigar/network.rb +133 -67
  96. data/lib/ohai/plugins/sigar/network_route.rb +33 -28
  97. data/lib/ohai/plugins/sigar/platform.rb +10 -6
  98. data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
  99. data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
  100. data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
  101. data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
  102. data/lib/ohai/plugins/solaris2/network.rb +91 -86
  103. data/lib/ohai/plugins/solaris2/platform.rb +40 -36
  104. data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
  105. data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
  106. data/lib/ohai/plugins/ssh_host_key.rb +49 -45
  107. data/lib/ohai/plugins/uptime.rb +87 -25
  108. data/lib/ohai/plugins/virtualization.rb +59 -55
  109. data/lib/ohai/plugins/windows/cpu.rb +44 -40
  110. data/lib/ohai/plugins/windows/filesystem.rb +28 -22
  111. data/lib/ohai/plugins/windows/network.rb +88 -79
  112. data/lib/ohai/plugins/windows/platform.rb +10 -3
  113. data/lib/ohai/provides_map.rb +184 -0
  114. data/lib/ohai/runner.rb +109 -0
  115. data/lib/ohai/system.rb +103 -184
  116. data/lib/ohai/version.rb +4 -3
  117. data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
  118. data/spec/data/plugins/___lib___libc.so.6.output +135 -0
  119. data/spec/data/plugins/cc.output +135 -0
  120. data/spec/data/plugins/cl.output +135 -0
  121. data/spec/data/plugins/devenv.com.output +135 -0
  122. data/spec/data/plugins/env.output +71 -0
  123. data/spec/data/plugins/erl.output +144 -0
  124. data/spec/data/plugins/gcc.output +135 -0
  125. data/spec/data/plugins/groovy.output +159 -0
  126. data/spec/data/plugins/java.output +143 -0
  127. data/spec/data/plugins/lua.output +143 -0
  128. data/spec/data/plugins/messages.rb +8 -0
  129. data/spec/data/plugins/node.output +143 -0
  130. data/spec/data/plugins/perl.output +143 -0
  131. data/spec/data/plugins/php.output +143 -0
  132. data/spec/data/plugins/python.output +143 -0
  133. data/spec/data/plugins/uname.output +71 -0
  134. data/spec/data/plugins/v6message.rb +2 -0
  135. data/spec/data/plugins/v7message.rb +7 -0
  136. data/spec/data/plugins/what.output +135 -0
  137. data/spec/data/plugins/xlc.output +135 -0
  138. data/spec/spec_helper.rb +52 -18
  139. data/spec/support/integration_helper.rb +44 -0
  140. data/spec/unit/dsl/plugin_spec.rb +298 -0
  141. data/spec/unit/hints_spec.rb +65 -0
  142. data/spec/unit/loader_spec.rb +226 -0
  143. data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
  144. data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
  145. data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
  146. data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
  147. data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
  148. data/spec/unit/plugins/aix/network_spec.rb +66 -45
  149. data/spec/unit/plugins/aix/platform_spec.rb +11 -10
  150. data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
  151. data/spec/unit/plugins/azure_spec.rb +20 -21
  152. data/spec/unit/plugins/c_spec.rb +88 -87
  153. data/spec/unit/plugins/chef_spec.rb +5 -6
  154. data/spec/unit/plugins/cloud_spec.rb +81 -82
  155. data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
  156. data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
  157. data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
  158. data/spec/unit/plugins/darwin/network_spec.rb +375 -378
  159. data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
  160. data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
  161. data/spec/unit/plugins/dmi_spec.rb +7 -12
  162. data/spec/unit/plugins/ec2_spec.rb +70 -59
  163. data/spec/unit/plugins/erlang_spec.rb +18 -20
  164. data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
  165. data/spec/unit/plugins/fail_spec.rb +276 -23
  166. data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
  167. data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
  168. data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
  169. data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
  170. data/spec/unit/plugins/gce_spec.rb +19 -25
  171. data/spec/unit/plugins/groovy_spec.rb +10 -16
  172. data/spec/unit/plugins/hostname_spec.rb +45 -20
  173. data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
  174. data/spec/unit/plugins/java_spec.rb +145 -99
  175. data/spec/unit/plugins/kernel_spec.rb +51 -15
  176. data/spec/unit/plugins/linode_spec.rb +31 -29
  177. data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
  178. data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
  179. data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
  180. data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
  181. data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
  182. data/spec/unit/plugins/linux/network_spec.rb +196 -238
  183. data/spec/unit/plugins/linux/platform_spec.rb +186 -205
  184. data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
  185. data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
  186. data/spec/unit/plugins/lua_spec.rb +12 -15
  187. data/spec/unit/plugins/mono_spec.rb +10 -15
  188. data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
  189. data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
  190. data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
  191. data/spec/unit/plugins/network_spec.rb +358 -235
  192. data/spec/unit/plugins/nodejs_spec.rb +13 -15
  193. data/spec/unit/plugins/ohai_spec.rb +3 -4
  194. data/spec/unit/plugins/ohai_time_spec.rb +8 -9
  195. data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
  196. data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
  197. data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
  198. data/spec/unit/plugins/openstack_spec.rb +214 -0
  199. data/spec/unit/plugins/os_spec.rb +13 -16
  200. data/spec/unit/plugins/passwd_spec.rb +12 -13
  201. data/spec/unit/plugins/perl_spec.rb +20 -44
  202. data/spec/unit/plugins/php_spec.rb +20 -15
  203. data/spec/unit/plugins/platform_spec.rb +24 -29
  204. data/spec/unit/plugins/python_spec.rb +13 -17
  205. data/spec/unit/plugins/rackspace_spec.rb +90 -57
  206. data/spec/unit/plugins/root_group_spec.rb +17 -19
  207. data/spec/unit/plugins/ruby_spec.rb +15 -16
  208. data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
  209. data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
  210. data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
  211. data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
  212. data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
  213. data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
  214. data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
  215. data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
  216. data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
  217. data/spec/unit/provides_map_spec.rb +208 -0
  218. data/spec/unit/runner_spec.rb +488 -0
  219. data/spec/unit/system_spec.rb +639 -104
  220. metadata +151 -87
  221. checksums.yaml +0 -7
  222. data/lib/ohai/mixin/from_file.rb +0 -36
  223. data/lib/ohai/plugins/aix/ps.rb +0 -23
  224. data/lib/ohai/plugins/darwin/kernel.rb +0 -37
  225. data/lib/ohai/plugins/darwin/ps.rb +0 -23
  226. data/lib/ohai/plugins/darwin/uptime.rb +0 -32
  227. data/lib/ohai/plugins/dmi_common.rb +0 -121
  228. data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
  229. data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
  230. data/lib/ohai/plugins/freebsd/ps.rb +0 -24
  231. data/lib/ohai/plugins/hpux/cpu.rb +0 -19
  232. data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
  233. data/lib/ohai/plugins/hpux/hostname.rb +0 -19
  234. data/lib/ohai/plugins/hpux/memory.rb +0 -19
  235. data/lib/ohai/plugins/hpux/network.rb +0 -19
  236. data/lib/ohai/plugins/hpux/platform.rb +0 -19
  237. data/lib/ohai/plugins/hpux/ps.rb +0 -23
  238. data/lib/ohai/plugins/hpux/uptime.rb +0 -19
  239. data/lib/ohai/plugins/linux/hostname.rb +0 -40
  240. data/lib/ohai/plugins/linux/ps.rb +0 -23
  241. data/lib/ohai/plugins/linux/uptime.rb +0 -28
  242. data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
  243. data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
  244. data/lib/ohai/plugins/netbsd/ps.rb +0 -24
  245. data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
  246. data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
  247. data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
  248. data/lib/ohai/plugins/openbsd/ps.rb +0 -24
  249. data/lib/ohai/plugins/sigar/hostname.rb +0 -28
  250. data/lib/ohai/plugins/sigar/uptime.rb +0 -27
  251. data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
  252. data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
  253. data/lib/ohai/plugins/solaris2/ps.rb +0 -23
  254. data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
  255. data/lib/ohai/plugins/windows/hostname.rb +0 -33
  256. data/lib/ohai/plugins/windows/kernel.rb +0 -58
  257. data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
  258. data/lib/ohai/plugins/windows/uptime.rb +0 -23
  259. data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -16,8 +16,14 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "platform", "platform_version"
20
-
21
- platform from("uname -s").downcase
22
- platform_version from("uname -r")
19
+ Ohai.plugin(:Platform) do
20
+ provides "platform", "platform_version", "platform_family"
23
21
 
22
+ collect_data(:openbsd) do
23
+ so = shell_out("uname -s")
24
+ platform so.stdout.split($/)[0].downcase
25
+ so = shell_out("uname -r")
26
+ platform_version so.stdout.split($/)[0]
27
+ platform_family "openbsd"
28
+ end
29
+ end
@@ -16,51 +16,53 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "virtualization"
19
+ Ohai.plugin(:Virtualization) do
20
+ provides "virtualization"
20
21
 
21
- virtualization Mash.new
22
+ collect_data(:openbsd) do
23
+ virtualization Mash.new
22
24
 
23
- # KVM Host support for FreeBSD is in development
24
- # http://feanor.sssup.it/~fabio/freebsd/lkvm/
25
+ # KVM Host support for FreeBSD is in development
26
+ # http://feanor.sssup.it/~fabio/freebsd/lkvm/
25
27
 
26
- # Detect KVM/QEMU from cpu, report as KVM
27
- # hw.model: QEMU Virtual CPU version 0.9.1
28
- if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
29
- virtualization[:system] = "kvm"
30
- virtualization[:role] = "guest"
31
- end
28
+ # Detect KVM/QEMU from cpu, report as KVM
29
+ # hw.model: QEMU Virtual CPU version 0.9.1
30
+ so = shell_out("sysctl -n hw.model")
31
+ if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
32
+ virtualization[:system] = "kvm"
33
+ virtualization[:role] = "guest"
34
+ end
32
35
 
33
- # http://www.dmo.ca/blog/detecting-virtualization-on-linux
34
- if File.exists?("/usr/local/sbin/dmidecode")
35
- popen4("dmidecode") do |pid, stdin, stdout, stderr|
36
- stdin.close
37
- found_virt_manufacturer = nil
38
- found_virt_product = nil
39
- stdout.each do |line|
40
- case line
41
- when /Manufacturer: Microsoft/
42
- found_virt_manufacturer = "microsoft"
43
- when /Product Name: Virtual Machine/
44
- found_virt_product = "microsoft"
45
- when /Version: 5.0/
46
- if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
47
- virtualization[:system] = "virtualpc"
48
- virtualization[:role] = "guest"
49
- end
50
- when /Version: VS2005R2/
51
- if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
52
- virtualization[:system] = "virtualserver"
53
- virtualization[:role] = "guest"
54
- end
55
- when /Manufacturer: VMware/
56
- found_virt_manufacturer = "vmware"
57
- when /Product Name: VMware Virtual Platform/
58
- if found_virt_manufacturer == "vmware"
59
- virtualization[:system] = "vmware"
60
- virtualization[:role] = "guest"
36
+ # http://www.dmo.ca/blog/detecting-virtualization-on-linux
37
+ if File.exists?("/usr/local/sbin/dmidecode")
38
+ so = shell_out("dmidecode")
39
+ found_virt_manufacturer = nil
40
+ found_virt_product = nil
41
+ so.stdout.lines do |line|
42
+ case line
43
+ when /Manufacturer: Microsoft/
44
+ found_virt_manufacturer = "microsoft"
45
+ when /Product Name: Virtual Machine/
46
+ found_virt_product = "microsoft"
47
+ when /Version: 5.0/
48
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
49
+ virtualization[:system] = "virtualpc"
50
+ virtualization[:role] = "guest"
51
+ end
52
+ when /Version: VS2005R2/
53
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
54
+ virtualization[:system] = "virtualserver"
55
+ virtualization[:role] = "guest"
56
+ end
57
+ when /Manufacturer: VMware/
58
+ found_virt_manufacturer = "vmware"
59
+ when /Product Name: VMware Virtual Platform/
60
+ if found_virt_manufacturer == "vmware"
61
+ virtualization[:system] = "vmware"
62
+ virtualization[:role] = "guest"
63
+ end
61
64
  end
62
65
  end
63
66
  end
64
67
  end
65
68
  end
66
-
@@ -15,32 +15,34 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- provides "openstack"
19
-
20
18
  require 'ohai/mixin/ec2_metadata'
21
19
 
22
- extend Ohai::Mixin::Ec2Metadata
20
+ Ohai.plugin(:Openstack) do
21
+ provides "openstack"
22
+
23
+ include Ohai::Mixin::Ec2Metadata
24
+
25
+ collect_data do
26
+ # Adds openstack Mash
27
+ if hint?('openstack') || hint?('hp')
28
+ Ohai::Log.debug("ohai openstack")
29
+
30
+ if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)
31
+ openstack Mash.new
32
+ Ohai::Log.debug("connecting to the OpenStack metadata service")
33
+ fetch_metadata.each {|k, v| openstack[k] = v }
23
34
 
24
- # does it matter that it's not hitting latest?
25
- #Ec2Metadata::EC2_METADATA_URL = "/latest/meta-data"
35
+ if hint?('hp')
36
+ openstack['provider'] = 'hp'
37
+ else
38
+ openstack['provider'] = 'openstack'
39
+ end
26
40
 
27
- # Adds openstack Mash
28
- if hint?('openstack') || hint?('hp')
29
- Ohai::Log.debug("ohai openstack")
30
- openstack Mash.new
31
- #for now, use the metadata service
32
- if can_metadata_connect?(EC2_METADATA_ADDR,80)
33
- Ohai::Log.debug("connecting to the OpenStack metadata service")
34
- self.fetch_metadata.each {|k, v| openstack[k] = v }
35
- case
36
- when hint?('hp')
37
- openstack['provider'] = 'hp'
41
+ else
42
+ Ohai::Log.debug("unable to connect to the OpenStack metadata service")
43
+ end
38
44
  else
39
- openstack['provider'] = 'openstack'
45
+ Ohai::Log.debug("NOT ohai openstack")
40
46
  end
41
- else
42
- Ohai::Log.debug("unable to connect to the OpenStack metadata service")
43
47
  end
44
- else
45
- Ohai::Log.debug("NOT ohai openstack")
46
48
  end
@@ -16,38 +16,14 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "os", "os_version"
19
+ require 'ohai/mixin/os'
20
20
 
21
- require 'rbconfig'
21
+ Ohai.plugin(:OS) do
22
+ provides "os", "os_version"
23
+ depends 'kernel'
22
24
 
23
- require_plugin 'kernel'
24
-
25
- case ::RbConfig::CONFIG['host_os']
26
- when /aix(.+)$/
27
- os "aix"
28
- when /darwin(.+)$/
29
- os "darwin"
30
- when /hpux(.+)$/
31
- os "hpux"
32
- when /linux/
33
- os "linux"
34
- when /freebsd(.+)$/
35
- os "freebsd"
36
- when /openbsd(.+)$/
37
- os "openbsd"
38
- when /netbsd(.*)$/
39
- os "netbsd"
40
- when /solaris2/
41
- os "solaris2"
42
- when /mswin|mingw32|windows/
43
- # After long discussion in IRC the "powers that be" have come to a concensus
44
- # that there is no other Windows platforms exist that were not based on the
45
- # Windows_NT kernel, so we herby decree that "windows" will refer to all
46
- # platforms built upon the Windows_NT kernel and have access to win32 or win64
47
- # subsystems.
48
- os "windows"
49
- else
50
- os ::RbConfig::CONFIG['host_os']
25
+ collect_data do
26
+ os collect_os
27
+ os_version kernel[:release]
28
+ end
51
29
  end
52
-
53
- os_version kernel[:release]
@@ -1,32 +1,37 @@
1
- provides 'etc', 'current_user'
2
1
 
3
2
  require 'etc'
4
3
 
5
- def fix_encoding(str)
6
- str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)
7
- str
8
- end
4
+ Ohai.plugin(:Passwd) do
5
+ provides 'etc', 'current_user'
9
6
 
10
- unless etc
11
- etc Mash.new
7
+ def fix_encoding(str)
8
+ str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)
9
+ str
10
+ end
12
11
 
13
- etc[:passwd] = Mash.new
14
- etc[:group] = Mash.new
12
+ collect_data do
13
+ unless etc
14
+ etc Mash.new
15
15
 
16
- Etc.passwd do |entry|
17
- user_passwd_entry = Mash.new(:dir => entry.dir, :gid => entry.gid, :uid => entry.uid, :shell => entry.shell, :gecos => entry.gecos)
18
- user_passwd_entry.each_value {|v| fix_encoding(v)}
19
- etc[:passwd][fix_encoding(entry.name)] = user_passwd_entry
20
- end
16
+ etc[:passwd] = Mash.new
17
+ etc[:group] = Mash.new
21
18
 
22
- Etc.group do |entry|
23
- group_entry = Mash.new(:gid => entry.gid,
24
- :members => entry.mem.map {|u| fix_encoding(u)})
19
+ Etc.passwd do |entry|
20
+ user_passwd_entry = Mash.new(:dir => entry.dir, :gid => entry.gid, :uid => entry.uid, :shell => entry.shell, :gecos => entry.gecos)
21
+ user_passwd_entry.each_value {|v| fix_encoding(v)}
22
+ etc[:passwd][fix_encoding(entry.name)] = user_passwd_entry
23
+ end
25
24
 
26
- etc[:group][fix_encoding(entry.name)] = group_entry
27
- end
28
- end
25
+ Etc.group do |entry|
26
+ group_entry = Mash.new(:gid => entry.gid,
27
+ :members => entry.mem.map {|u| fix_encoding(u)})
28
+
29
+ etc[:group][fix_encoding(entry.name)] = group_entry
30
+ end
31
+ end
29
32
 
30
- unless current_user
31
- current_user fix_encoding(Etc.getlogin)
33
+ unless current_user
34
+ current_user fix_encoding(Etc.getlogin)
35
+ end
36
+ end
32
37
  end
@@ -16,24 +16,29 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "languages/perl"
19
+ Ohai.plugin(:Perl) do
20
+ provides "languages/perl"
20
21
 
21
- require_plugin "languages"
22
- output = nil
22
+ depends "languages"
23
23
 
24
- perl = Mash.new
25
- status, stdout, stderr = run_command(:no_status_check => true, :command => "perl -V:version -V:archname")
26
- if status == 0
27
- stdout.each_line do |line|
28
- case line
29
- when /^version=\'(.+)\';$/
30
- perl[:version] = $1
31
- when /^archname=\'(.+)\';$/
32
- perl[:archname] = $1
24
+ collect_data do
25
+ output = nil
26
+
27
+ perl = Mash.new
28
+ so = shell_out("perl -V:version -V:archname")
29
+ if so.exitstatus == 0
30
+ so.stdout.split(/\r?\n/).each do |line|
31
+ case line
32
+ when /^version=\'(.+)\';$/
33
+ perl[:version] = $1
34
+ when /^archname=\'(.+)\';$/
35
+ perl[:archname] = $1
36
+ end
37
+ end
33
38
  end
34
- end
35
- end
36
39
 
37
- if status == 0
38
- languages[:perl] = perl
40
+ if so.exitstatus == 0
41
+ languages[:perl] = perl
42
+ end
43
+ end
39
44
  end
@@ -16,21 +16,24 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "languages/php"
19
+ Ohai.plugin(:PHP) do
20
+ provides "languages/php"
20
21
 
21
- require_plugin "languages"
22
+ depends "languages"
22
23
 
23
- output = nil
24
+ collect_data do
25
+ output = nil
24
26
 
25
- php = Mash.new
27
+ php = Mash.new
26
28
 
27
- status, stdout, stderr = run_command(:no_status_check => true, :command => "php -v")
28
- if status == 0
29
- output = stdout.split
30
- if output.length >= 6
31
- php[:version] = output[1]
32
- php[:builddate] = "%s %s %s" % [output[4],output[5],output[6]]
29
+ so = shell_out("php -v")
30
+ if so.exitstatus == 0
31
+ output = /PHP (\S+).+built: ([^)]+)/.match(so.stdout)
32
+ if output
33
+ php[:version] = output[1]
34
+ php[:builddate] = output[2]
35
+ end
36
+ languages[:php] = php if php[:version]
37
+ end
33
38
  end
34
- languages[:php] = php if php[:version]
35
39
  end
36
-
@@ -16,13 +16,13 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "platform", "platform_version", "platform_family"
20
-
21
- require_plugin "#{os}::platform"
22
-
23
- platform os unless attribute?("platform")
24
-
25
- platform_version os_version unless attribute?("platform_version")
26
-
27
- platform_family platform unless attribute?("platform_family")
19
+ Ohai.plugin(:Platform) do
20
+ provides "platform", "platform_version", "platform_family"
21
+ depends "os", "os_version"
28
22
 
23
+ collect_data(:default) do
24
+ platform os unless attribute?("platform")
25
+ platform_version os_version unless attribute?("platform_version")
26
+ platform_family platform unless attribute?("platform_family")
27
+ end
28
+ end
@@ -1,6 +1,8 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Author:: Bryan McLellan (<btm@loftninjas.org>)
3
4
  # Copyright:: Copyright (c) 2008 Opscode, Inc.
5
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
6
  # License:: Apache License, Version 2.0
5
7
  #
6
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,23 +13,22 @@
11
13
  #
12
14
  # Unless required by applicable law or agreed to in writing, software
13
15
  # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
+ # implied.
15
18
  # See the License for the specific language governing permissions and
16
19
  # limitations under the License.
17
20
  #
18
21
 
19
- provides "kernel"
22
+ Ohai.plugin(:PS) do
23
+ provides "command/ps"
24
+ depends "command"
20
25
 
21
- kernel[:os] = from("uname -o")
26
+ collect_data(:aix, :darwin, :hpux, :linux, :solaris2) do
27
+ command[:ps] = 'ps -ef'
28
+ end
22
29
 
23
- kext = Mash.new
24
- popen4("env lsmod") do |pid, stdin, stdout, stderr|
25
- stdin.close
26
- stdout.each do |line|
27
- if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
28
- kext[$1] = { :size => $2, :refcount => $3 }
29
- end
30
+ collect_data(:freebsd, :netbsd, :openbsd) do
31
+ # ps -e requires procfs
32
+ command[:ps] = 'ps -ax'
30
33
  end
31
34
  end
32
-
33
- kernel[:modules] = kext
@@ -16,22 +16,26 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- provides "languages/python"
19
+ Ohai.plugin(:Python) do
20
+ provides "languages/python"
20
21
 
21
- require_plugin "languages"
22
+ depends "languages"
22
23
 
23
- output = nil
24
+ collect_data do
25
+ output = nil
24
26
 
25
- python = Mash.new
27
+ python = Mash.new
26
28
 
27
- status, stdout, stderr = run_command(:no_status_check => true, :command => "python -c \"import sys; print sys.version\"")
29
+ so = shell_out("python -c \"import sys; print sys.version\"")
28
30
 
29
- if status == 0
30
- output = stdout.split
31
- python[:version] = output[0]
32
- if output.length >= 6
33
- python[:builddate] = "%s %s %s %s" % [output[2],output[3],output[4],output[5].gsub!(/\)/,'')]
34
- end
31
+ if so.exitstatus == 0
32
+ output = so.stdout.split
33
+ python[:version] = output[0]
34
+ if output.length >= 6
35
+ python[:builddate] = "%s %s %s %s" % [output[2],output[3],output[4],output[5].gsub!(/\)/,'')]
36
+ end
35
37
 
36
- languages[:python] = python if python[:version] and python[:builddate]
38
+ languages[:python] = python if python[:version] and python[:builddate]
39
+ end
40
+ end
37
41
  end