diff options
-rw-r--r-- | lib/ohai/plugins/linux/hostname.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/linux/hostname_spec.rb | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/ohai/plugins/linux/hostname.rb b/lib/ohai/plugins/linux/hostname.rb index fe77b3bf..c3f2dc21 100644 --- a/lib/ohai/plugins/linux/hostname.rb +++ b/lib/ohai/plugins/linux/hostname.rb @@ -20,9 +20,11 @@ Ohai.plugin do provides "hostname", "fqdn" collect_data do - hostname from("hostname -s") + so = shell_out("hostname -s") + hostname so.stdout.split($/)[0] begin - fqdn from("hostname --fqdn") + so = shell_out("hostname --fqdn") + fqdn so.stdout.split($/)[0] rescue Ohai::Log.debug("hostname -f returned an error, probably no domain is set") end diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index b11b104b..5ec0fb6e 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -23,8 +23,8 @@ describe Ohai::System, "Linux hostname plugin" do before(:each) do @plugin = get_plugin("linux/hostname") @plugin[:os] = "linux" - @plugin.stub(:from).with("hostname -s").and_return("katie") - @plugin.stub(:from).with("hostname --fqdn").and_return("katie.bethell") + @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", "")) + @plugin.stub(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", "")) end it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie") @@ -33,7 +33,7 @@ describe Ohai::System, "Linux hostname plugin" do describe "when domain name is unset" do before(:each) do - @plugin.should_receive(:from).with("hostname --fqdn").and_raise("Ohai::Exception::Exec") + @plugin.should_receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec") end it "should not raise an error" do |