diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-04-10 15:42:45 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-04-15 16:51:50 -0700 |
commit | 41323875c78b865e5a3bb520da8876059a3822fa (patch) | |
tree | beec8d013a851a0e11505038f9f5f60c5467d84b | |
parent | 5788971dc09e36b92c39c8d9f0b0514742868064 (diff) | |
download | ohai-41323875c78b865e5a3bb520da8876059a3822fa.tar.gz |
Make the existing SystemEnclosure plugin depend on the new Windows DMI plugin.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | lib/ohai/plugins/windows/system_enclosure.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/windows/system_enclosure_spec.rb | 45 |
2 files changed, 3 insertions, 50 deletions
diff --git a/lib/ohai/plugins/windows/system_enclosure.rb b/lib/ohai/plugins/windows/system_enclosure.rb index d6ebaf26..edc07d15 100644 --- a/lib/ohai/plugins/windows/system_enclosure.rb +++ b/lib/ohai/plugins/windows/system_enclosure.rb @@ -18,13 +18,11 @@ Ohai.plugin :SystemEnclosure do provides "system_enclosure" + depends "dmi" collect_data(:windows) do - require "wmi-lite/wmi" system_enclosure Mash.new - wmi = WmiLite::Wmi.new - wmi_object = wmi.first_of("Win32_SystemEnclosure").wmi_ole_object - system_enclosure[:manufacturer] = wmi_object.invoke("manufacturer") - system_enclosure[:serialnumber] = wmi_object.invoke("serialnumber") + system_enclosure[:manufacturer] = get_attribute(:dmi, :chassis, :manufacturer) + system_enclosure[:serialnumber] = get_attribute(:dmi, :chassis, :serial_number) end end diff --git a/spec/unit/plugins/windows/system_enclosure_spec.rb b/spec/unit/plugins/windows/system_enclosure_spec.rb deleted file mode 100644 index 0e1bbc93..00000000 --- a/spec/unit/plugins/windows/system_enclosure_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# 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. -# - -require "spec_helper" - -describe Ohai::System, "System Enclosure", :windows_only do - before do - require "wmi-lite/wmi" - @plugin = get_plugin("windows/system_enclosure") - manufacturer = double("WIN32OLE", name: "manufacturer", value: "My Fake Manufacturer") - serialnumber = double("WIN32OLE", name: "serialnumber", value: "1234123412341234") - property_map = [ manufacturer, serialnumber ] - - wmi_ole_object = double( "WIN32OLE", properties_: property_map) - allow(wmi_ole_object).to receive(:invoke).with(manufacturer.name).and_return(manufacturer.value) - allow(wmi_ole_object).to receive(:invoke).with(serialnumber.name).and_return(serialnumber.value) - wmi_object = WmiLite::Wmi::Instance.new(wmi_ole_object) - expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with(("Win32_SystemEnclosure")).and_return(wmi_object) - end - - it "returns the manufacturer" do - @plugin.run - expect(@plugin["system_enclosure"]["manufacturer"]).to eql("My Fake Manufacturer") - end - - it "returns a serial number" do - @plugin.run - expect(@plugin["system_enclosure"]["serialnumber"]).to eql("1234123412341234") - end -end |