File: hadoop_config.rb

package info (click to toggle)
ruby-serverspec 2.43.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 984 kB
  • sloc: ruby: 4,847; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Serverspec::Type
  class HadoopConfig < Base
    def initialize(name=nil, options={})
      super

      begin
        require 'nokogiri'
      rescue LoadError
        fail "nokogiri is not available. Try installing it."
      end
    end

    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
  end
end