diff options
author | Daniel Paul Searles <daniel@flowboard.com> | 2014-06-23 15:56:15 -0700 |
---|---|---|
committer | Daniel Paul Searles <daniel@flowboard.com> | 2014-06-23 16:35:51 -0700 |
commit | ea92ea9b6ee007c8d6cdc2b3768a024b2e3fbf09 (patch) | |
tree | d8cc95fe89b1de7823165e29e4d346c4e148b946 | |
parent | c0f76a272900e032c9fdadbf11503b57dd26f18f (diff) | |
download | ohai-ea92ea9b6ee007c8d6cdc2b3768a024b2e3fbf09.tar.gz |
[OHAI-518] remove *.static.cloud-ips.com
Fixes issues with Pull Request #215
- fixes tests
- moves `require "resolve"` to top of file
-rw-r--r-- | lib/ohai/plugins/rackspace.rb | 5 | ||||
-rw-r--r-- | spec/unit/plugins/rackspace_spec.rb | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb index 2fb98348..7926df79 100644 --- a/lib/ohai/plugins/rackspace.rb +++ b/lib/ohai/plugins/rackspace.rb @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +require "resolv" + Ohai.plugin(:Rackspace) do provides "rackspace" @@ -119,7 +121,6 @@ Ohai.plugin(:Rackspace) do end collect_data do - require "resolv" # Adds rackspace Mash if looks_like_rackspace? rackspace Mash.new @@ -132,7 +133,7 @@ Ohai.plugin(:Rackspace) do unless rackspace[:public_ip].nil? rackspace[:public_hostname] = begin Resolv.getname(rackspace[:public_ip]) - rescue SocketError + rescue rackspace[:public_ip] end end diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index 72dc6e28..a955b7a0 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -95,6 +95,12 @@ describe Ohai::System, "plugin rackspace" do @plugin[:rackspace][:public_hostname].should_not be_nil end + it "should resolve hostname if reverse dns is set" do + Resolv.stub(:getname).and_return("1234.resolved.com") + @plugin.run + @plugin[:rackspace][:public_hostname].should == "1234.resolved.com" + end + it "should have correct values for all attributes" do @plugin.run @plugin[:rackspace][:public_ip].should == "1.2.3.4" @@ -103,7 +109,7 @@ describe Ohai::System, "plugin rackspace" do @plugin[:rackspace][:local_ipv4].should == "5.6.7.8" @plugin[:rackspace][:public_ipv6].should == "2a00:1a48:7805:111:e875:efaf:ff08:75" @plugin[:rackspace][:local_hostname].should == 'katie' - @plugin[:rackspace][:public_hostname].should == "1-2-3-4.static.cloud-ips.com" + @plugin[:rackspace][:public_hostname].should == "1.2.3.4" end it "should capture region information" do @@ -128,6 +134,8 @@ OUT File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + File.stub(:exist?).with('/etc/resolv.conf').and_return(true) + File.stub(:read).with('/etc/resolv.conf').and_return('') end describe 'with no public interfaces (empty eth0)' do |