summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-07-09 10:19:17 -0700
committerGitHub <noreply@github.com>2018-07-09 10:19:17 -0700
commitb37d988f1dcb52bcc76f4e6a29f4e7cb9b21f841 (patch)
tree70b787658f733a4a9a32e071eb11fea9432320af
parentd9658da197dd4ad32043aec2e56b1b24a870d2e5 (diff)
parentede8809874b19e19b813b8df166a2942eb016400 (diff)
downloadohai-b37d988f1dcb52bcc76f4e6a29f4e7cb9b21f841.tar.gz
Merge pull request #1216 from chef/backport_me
Detect Redhat Openstack clusters
-rw-r--r--lib/ohai/plugins/openstack.rb3
-rw-r--r--spec/unit/plugins/openstack_spec.rb29
2 files changed, 27 insertions, 5 deletions
diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb
index 7d1c528c..42dcbbf5 100644
--- a/lib/ohai/plugins/openstack.rb
+++ b/lib/ohai/plugins/openstack.rb
@@ -32,6 +32,9 @@ Ohai.plugin(:Openstack) do
if get_attribute(:dmi, :system, :all_records, 0, :Manufacturer) =~ /OpenStack/
Ohai::Log.debug("Plugin Openstack: has_openstack_dmi? == true")
true
+ elsif get_attribute(:dmi, :system, :product_name) == "OpenStack Compute"
+ logger.trace("Plugin Openstack: has_openstack_dmi? == true")
+ true
else
Ohai::Log.debug("Plugin Openstack: has_openstack_dmi? == false")
false
diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb
index 843f864c..b8533a22 100644
--- a/spec/unit/plugins/openstack_spec.rb
+++ b/spec/unit/plugins/openstack_spec.rb
@@ -40,16 +40,35 @@ describe Ohai::System, "plugin openstack" do
allow(plugin).to receive(:can_socket_connect?).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80).
and_return(false)
- plugin[:dmi] = { :system => { :all_records => [ { :Manufacturer => "OpenStack Foundation" } ] } }
+ plugin[:dmi] = dmi_data
plugin.run
end
- it "sets openstack attribute" do
- expect(plugin[:openstack][:provider]).to eq("openstack")
+ 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
end
+ context "with Red Hat openstack metadata" do
+ let(:dmi_data) do
+ { :system => { :manufacturer => "Red Hat", :product_name => "OpenStack Compute" } }
+ end
- it "doesn't set metadata attributes" do
- expect(plugin[:openstack][:instance_id]).to be_nil
+ 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
end
end
end