summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-01-08 15:34:15 -0800
committersersut <serdar@opscode.com>2014-01-08 15:34:15 -0800
commitebabd088673cf3e36d600bd96aeba004077842f1 (patch)
tree5470f10b1579a07fbdf5aa32fba96e4c385d416c
parentc17c663884a1858131bc8f166df90cc405552fc2 (diff)
downloadohai-OC-10958.tar.gz
Remove -f / --file option from OHAI. This option was useful when developing OHAI plugins in OHAI 6 but not anymore in OHAI 7. The way to get a similar functionality is to run:OC-10958
ohai -d . => get all the attributes by running the plugins in the current directory ohai -d . my_attribute_name => only to get the attribute you're developing
-rw-r--r--lib/ohai/application.rb12
-rw-r--r--lib/ohai/mixin/from_file.rb36
-rw-r--r--lib/ohai/system.rb1
-rw-r--r--spec/spec_helper.rb6
-rw-r--r--spec/unit/plugins/freebsd/virtualization_spec.rb1
-rw-r--r--spec/unit/plugins/linux/filesystem_spec.rb1
-rw-r--r--spec/unit/plugins/linux/lsb_spec.rb1
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb1
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb1
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb1
-rw-r--r--spec/unit/plugins/solaris2/virtualization_spec.rb1
-rw-r--r--spec/unit/plugins/ssh_host_keys_spec.rb3
12 files changed, 2 insertions, 63 deletions
diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb
index e1640e8c..477b4a6f 100644
--- a/lib/ohai/application.rb
+++ b/lib/ohai/application.rb
@@ -27,11 +27,6 @@ class Ohai::Application
:long => "--directory DIRECTORY",
:description => "A directory to add to the Ohai search path"
- option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "A file to run Ohai against"
-
option :log_level,
:short => "-l LEVEL",
:long => "--log_level LEVEL",
@@ -92,11 +87,8 @@ class Ohai::Application
def run_application
ohai = Ohai::System.new
- if Ohai::Config[:file]
- ohai.from_file(Ohai::Config[:file])
- else
- ohai.all_plugins(@attributes)
- end
+ ohai.all_plugins(@attributes)
+
if @attributes
@attributes.each do |a|
puts ohai.attributes_print(a)
diff --git a/lib/ohai/mixin/from_file.rb b/lib/ohai/mixin/from_file.rb
deleted file mode 100644
index 93b78aa5..00000000
--- a/lib/ohai/mixin/from_file.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-module Ohai
- module Mixin
- module FromFile
-
- # Loads a given ruby file, and runs instance_eval against it in the context of the current
- # object.
- #
- # Raises an IOError if the file cannot be found, or is not readable.
- def from_file(filename)
- if File.exists?(filename) && File.readable?(filename)
- self.instance_eval(IO.read(filename), filename, 1)
- else
- raise IOError, "Cannot open or read #{filename}!"
- end
- end
- end
- end
-end
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index 609eb888..476586e9 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -21,7 +21,6 @@ require 'ohai/log'
require 'ohai/mash'
require 'ohai/runner'
require 'ohai/dsl'
-require 'ohai/mixin/from_file'
require 'ohai/mixin/command'
require 'ohai/mixin/os'
require 'ohai/mixin/string'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 374fcab2..a3dc8c95 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -108,12 +108,6 @@ def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
end
end
-module SimpleFromFile
- def from_file(filename)
- self.instance_eval(IO.read(filename), filename, 1)
- end
-end
-
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
diff --git a/spec/unit/plugins/freebsd/virtualization_spec.rb b/spec/unit/plugins/freebsd/virtualization_spec.rb
index 1072f051..ccefdd8f 100644
--- a/spec/unit/plugins/freebsd/virtualization_spec.rb
+++ b/spec/unit/plugins/freebsd/virtualization_spec.rb
@@ -23,7 +23,6 @@ describe Ohai::System, "FreeBSD virtualization plugin" do
before(:each) do
@plugin = get_plugin("freebsd/virtualization")
@plugin.stub(:collect_os).and_return(:freebsd)
- @plugin.extend(SimpleFromFile)
@plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
@plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
@plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb
index cdd601b5..5cd480c1 100644
--- a/spec/unit/plugins/linux/filesystem_spec.rb
+++ b/spec/unit/plugins/linux/filesystem_spec.rb
@@ -22,7 +22,6 @@ describe Ohai::System, "Linux filesystem plugin" do
before(:each) do
@plugin = get_plugin("linux/filesystem")
@plugin.stub(:collect_os).and_return(:linux)
- @plugin.extend(SimpleFromFile)
@plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
@plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb
index 6863170f..c2b763ae 100644
--- a/spec/unit/plugins/linux/lsb_spec.rb
+++ b/spec/unit/plugins/linux/lsb_spec.rb
@@ -25,7 +25,6 @@ describe Ohai::System, "Linux lsb plugin" do
before(:each) do
@plugin = get_plugin("linux/lsb")
@plugin.stub(:collect_os).and_return(:linux)
- @plugin.extend(SimpleFromFile)
end
describe "on systems with /etc/lsb-release" do
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 190eec7d..fc9662a7 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -23,7 +23,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux plugin platform" do
before(:each) do
@plugin = get_plugin("linux/platform")
- @plugin.extend(SimpleFromFile)
@plugin.stub(:collect_os).and_return(:linux)
@plugin[:lsb] = Mash.new
File.stub(:exists?).with("/etc/debian_version").and_return(false)
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index 855833c9..4989c544 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -22,7 +22,6 @@ describe Ohai::System, "Linux virtualization platform" do
before(:each) do
@plugin = get_plugin("linux/virtualization")
@plugin.stub(:collect_os).and_return(:linux)
- @plugin.extend(SimpleFromFile)
# default to all requested Files not existing
File.stub(:exists?).with("/proc/xen").and_return(false)
diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb
index d7ce9556..ad0fc680 100644
--- a/spec/unit/plugins/solaris2/platform_spec.rb
+++ b/spec/unit/plugins/solaris2/platform_spec.rb
@@ -21,7 +21,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris plugin platform" do
before(:each) do
@plugin = get_plugin("solaris2/platform")
- @plugin.extend(SimpleFromFile)
@plugin.stub(:collect_os).and_return(:solaris2)
@plugin.stub(:shell_out).with("/sbin/uname -X")
end
diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb
index b2b02511..9e884931 100644
--- a/spec/unit/plugins/solaris2/virtualization_spec.rb
+++ b/spec/unit/plugins/solaris2/virtualization_spec.rb
@@ -28,7 +28,6 @@ PSRINFO_PV
@plugin = get_plugin("solaris2/virtualization")
@plugin.stub(:collect_os).and_return(:solaris2)
- @plugin.extend(SimpleFromFile)
# default to all requested Files not existing
File.stub(:exists?).with("/usr/sbin/psrinfo").and_return(false)
diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb
index 4ead4478..c5279f1a 100644
--- a/spec/unit/plugins/ssh_host_keys_spec.rb
+++ b/spec/unit/plugins/ssh_host_keys_spec.rb
@@ -24,9 +24,6 @@ describe Ohai::System, "ssh_host_key plugin" do
@plugin = get_plugin("ssh_host_key")
@plugin[:keys] = Mash.new
- # Avoid using the real from_file to load the plugin => less stubbing required
- @plugin.extend(SimpleFromFile)
-
File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(true)
File.stub(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
File.stub(:exists?).and_return(true)