Class: Serverspec::Type::HadoopConfig
- Defined in:
- lib/serverspec/type/hadoop_config.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(name = nil, options = {}) ⇒ HadoopConfig
constructor
A new instance of HadoopConfig.
- #value ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name = nil, options = {}) ⇒ HadoopConfig
Returns a new instance of HadoopConfig.
3 4 5 6 7 8 9 10 11 |
# File 'lib/serverspec/type/hadoop_config.rb', line 3 def initialize(name=nil, ={}) super begin require 'nokogiri' rescue LoadError fail "nokogiri is not available. Try installing it." end end |
Instance Method Details
#value ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/serverspec/type/hadoop_config.rb', line 13 def value @runner.run_command("find /etc/hadoop/conf/ -type f -name \"*.xml\" ").stdout.split(/\n/).each do |file| @doc = ::Nokogiri::XML( @runner.get_file_content("#{file}").stdout.strip ) @doc.xpath('/configuration/property').each do |property| case property.xpath('name').text when /#{@name}/ ret = property.xpath('value').text val = ret.to_s return val end end end end |