Sha256: 9280f26518c1b096414fc086bb629561132466beb2837199d9237252a0e7690c

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

require File.expand_path('../../helpers/process', __FILE__)

class XMLOutput
  attr_accessor :tmp_file
  attr_accessor :db_helper

  def initialize(puppetdb_helper)
    @tmp_file = '/tmp/puppetdb-resource.xml'
    @db_helper = puppetdb_helper
  end

  def parse
    nodes = @db_helper.get_nodes
    facts = @db_helper.get_facts
    helper = Helpers::Process.new

    rundeck_data = Array.new
    rundeck_data << "<project>\n"

    nodes.each{|n|
      host = n['name']

      rundeck_data << "<node name=\"#{host}\""

      rundeck_data = helper.add_facts(facts, host, rundeck_data)

      rundeck_data << "/>\n"
    }

    rundeck_data << "</project>"
    xml = rundeck_data.join(" ")

    File.open(@tmp_file, 'w') { |file| file.write(xml) }

    return xml
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppetdb_rundeck-0.2.3 lib/model/xml.rb
puppetdb_rundeck-0.2.2 lib/model/xml.rb