summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Nordsieck <theo@opscode.com>2013-09-10 11:33:25 -0700
committerTheodore Nordsieck <theo@opscode.com>2013-09-11 16:13:25 -0700
commit7b34d7e41f4efd8dc5554da1c3d5069d56288cf6 (patch)
tree8d4be4d66e05b59d7dff55b8926f39534d11e419
parent54d7135f55277637f813dee4985a1ba1a3226be3 (diff)
downloadohai-7b34d7e41f4efd8dc5554da1c3d5069d56288cf6.tar.gz
Converted plugins/linux/hostname to Mixlib::ShellOut.
-rw-r--r--lib/ohai/plugins/linux/hostname.rb6
-rw-r--r--spec/unit/plugins/linux/hostname_spec.rb6
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