summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-04-09 10:32:57 -0700
committerGitHub <noreply@github.com>2017-04-09 10:32:57 -0700
commitd880c8a21de79fb3011584b955fb3a8e7cd2f013 (patch)
treeaf04600e7781bc30366abb37f4d0dbe6b985e4da
parent6b99865ac05623653926143a95c3efb7b6dccf8f (diff)
parenteb214de9805ec499145f88b56d4ef1fe4a1b7022 (diff)
downloadohai-d880c8a21de79fb3011584b955fb3a8e7cd2f013.tar.gz
Merge pull request #986 from akitada/fix_openstack
Fix OpenStack plugin to use the HttpHelper mixin
-rw-r--r--lib/ohai/plugins/openstack.rb4
-rw-r--r--spec/unit/plugins/openstack_spec.rb8
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb
index a7818e60..aa8ad1a2 100644
--- a/lib/ohai/plugins/openstack.rb
+++ b/lib/ohai/plugins/openstack.rb
@@ -17,9 +17,11 @@
# limitations under the License.
require "ohai/mixin/ec2_metadata"
+require "ohai/mixin/http_helper"
Ohai.plugin(:Openstack) do
include Ohai::Mixin::Ec2Metadata
+ include Ohai::Mixin::HttpHelper
provides "openstack"
depends "dmi"
@@ -61,7 +63,7 @@ Ohai.plugin(:Openstack) do
openstack[:provider] = openstack_provider
# fetch the metadata if we can do a simple socket connect first
- if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
+ if can_socket_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
fetch_metadata.each do |k, v|
openstack[k] = v
end
diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb
index 8d94ea1f..9dd52aef 100644
--- a/spec/unit/plugins/openstack_spec.rb
+++ b/spec/unit/plugins/openstack_spec.rb
@@ -37,7 +37,7 @@ describe Ohai::System, "plugin openstack" do
context "when DMI data is Openstack" do
context "and the metadata service is not available" do
before do
- allow(plugin).to receive(:can_metadata_connect?).
+ 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" } ] } }
@@ -57,7 +57,7 @@ describe Ohai::System, "plugin openstack" do
context "when running on dreamhost" do
it "sets openstack provider attribute to dreamhost" do
plugin["etc"] = { "passwd" => { "dhc-user" => {} } }
- allow(plugin).to receive(:can_metadata_connect?).
+ 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" } ] } }
@@ -69,7 +69,7 @@ describe Ohai::System, "plugin openstack" do
context "when the hint is present" do
context "and the metadata service is not available" do
before do
- allow(plugin).to receive(:can_metadata_connect?).
+ allow(plugin).to receive(:can_socket_connect?).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80).
and_return(false)
allow(plugin).to receive(:hint?).with("openstack").and_return(true)
@@ -176,7 +176,7 @@ EOM
before do
allow(plugin).to receive(:hint?).with("openstack").and_return(true)
- allow(plugin).to receive(:can_metadata_connect?).
+ allow(plugin).to receive(:can_socket_connect?).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80).
and_return(true)