diff options
author | Stuart Preston <stuart@chef.io> | 2018-07-04 14:13:58 +0100 |
---|---|---|
committer | Stuart Preston <stuart@chef.io> | 2018-07-04 14:13:58 +0100 |
commit | 7d4341c69b3481fb104f525a055ac6ebc521d67e (patch) | |
tree | fb04392511a3990ca816683538437ae4f8fb2c1f | |
parent | cb90ed45d4e8afa4e5899222a78b201e1d967a53 (diff) | |
download | ohai-7d4341c69b3481fb104f525a055ac6ebc521d67e.tar.gz |
Adding system_enclosure plugin for Windows
Signed-off-by: Stuart Preston <stuart@chef.io>
-rw-r--r-- | lib/ohai/plugins/windows/system_enclosure.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/ohai/plugins/windows/system_enclosure.rb b/lib/ohai/plugins/windows/system_enclosure.rb new file mode 100644 index 00000000..8d29daae --- /dev/null +++ b/lib/ohai/plugins/windows/system_enclosure.rb @@ -0,0 +1,32 @@ +# +# Author:: Stuart Preston (<stuart@chef.io>) +# Copyright:: Copyright (c) 2018, Chef Software Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Ohai.plugin :SystemEnclosure do + provides "system_enclosure" + + collect_data(:windows) do + system_enclosure(Mash.new) + so = shell_out('powershell.exe -Command "get-ciminstance win32_systemenclosure"') + if so.exitstatus == 0 + so.stdout.strip.each_line do |line| + kv = line.split(/:/, 2).map(&:strip) + system_enclosure[kv[0].downcase] = kv[1] if kv.length == 2 + end + end + end +end |