diff options
author | Tim Smith <tsmith84@gmail.com> | 2019-08-02 00:57:04 -0400 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2019-08-02 01:11:02 -0400 |
commit | 1de0a29f50718d7bdc34c32236c9bc2b02363aa6 (patch) | |
tree | 9cc201f578c3805d548e18533bcd0926d875a66b /spec | |
parent | bcb3ec6aa27938459c0f331124045dd860ecae84 (diff) | |
download | ohai-1de0a29f50718d7bdc34c32236c9bc2b02363aa6.tar.gz |
Simplify the Openstack plugin by not polling DMI datasimplify_openstack
Since we rely on the Virtualization plugin now there's no reason to also poll the DMI plugin data. That's a waste of time since we'll have already matched if virtualization came back Openstack. I didn't move the manufacturer = Openstack detection since that seems wrong on all modern Openstack installs which identify product field: https://cloudinit.readthedocs.io/en/latest/topics/datasources/openstack.html
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/plugins/openstack_spec.rb | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb index b7208633..f8c0dafd 100644 --- a/spec/unit/plugins/openstack_spec.rb +++ b/spec/unit/plugins/openstack_spec.rb @@ -25,51 +25,32 @@ describe Ohai::System, "plugin openstack" do before(:each) do allow(plugin).to receive(:hint?).with("openstack").and_return(false) - plugin[:dmi] = nil + plugin[:virtualization] = { system: {} } end - context "when there is no relevant hint or dmi data" do + context "when there is no relevant hint or virtualization data" do it "does not set any openstack data" do plugin.run expect(plugin[:openstack]).to be_nil end end - context "when DMI data is Openstack" do + context "when virtualization data is Openstack" do context "and the metadata service is not available" do before do allow(plugin).to receive(:can_socket_connect?) .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout) .and_return(false) - plugin[:dmi] = dmi_data + plugin[:virtualization] = { system: { guest: "openstack" } } plugin.run end - context "with normal openstack metadata" do - let(:dmi_data) do - { system: { all_records: [ { Manufacturer: "OpenStack Foundation" } ] } } - end - - it "sets openstack attribute" do - expect(plugin[:openstack][:provider]).to eq("openstack") - end - - it "doesn't set metadata attributes" do - expect(plugin[:openstack][:instance_id]).to be_nil - end + it "sets openstack attribute" do + expect(plugin[:openstack][:provider]).to eq("openstack") end - context "with Red Hat openstack metadata" do - let(:dmi_data) do - { system: { manufacturer: "Red Hat", product_name: "OpenStack Compute" } } - end - - it "sets openstack attribute" do - expect(plugin[:openstack][:provider]).to eq("openstack") - end - it "doesn't set metadata attributes" do - expect(plugin[:openstack][:instance_id]).to be_nil - end + it "doesn't set metadata attributes" do + expect(plugin[:openstack][:instance_id]).to be_nil end end end @@ -80,7 +61,7 @@ describe Ohai::System, "plugin openstack" do allow(plugin).to receive(:can_socket_connect?) .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout) .and_return(false) - plugin[:dmi] = { system: { all_records: [ { Manufacturer: "OpenStack Foundation" } ] } } + plugin[:virtualization] = { system: { guest: "openstack" } } plugin.run expect(plugin[:openstack][:provider]).to eq("dreamhost") end |