lib/tayu.rb
## generate xml document body based on retrieved nodes and there facts
generate xml document body based on retrieved nodes and there facts
generate xml document body based on retrieved nodes and there facts
def generate_body
        xmlbody = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">\n<project>\n)
        get_nodes.each do |node|
            facts = get_facts(node)
            tags_config = Tayu.allowed_tags 
            tags_rundeck = Array.new 
            os_family = facts["kernel"] =~ /windows/i ? 'windows' : 'unix'
            tags_config.each do |tag|
                if !facts[tag].nil?
                    tags_rundeck << facts[tag]
                end
            end
            xmlbody << <<-EOH
            <node name="#{xml_escape(facts["fqdn"])}"
                type="Node"
                description="#{xml_escape(facts["fqdn"])}"
                osArch="#{xml_escape(facts["kernel"])}"
                osFamily="#{xml_escape(os_family)}"
                osName="#{xml_escape(facts["operatingsystem"])}"
                tags="#{xml_escape(tags_rundeck.join(','))}"
                osVersion="#{xml_escape(facts["operatingsystemrelease"])}"
                username="#{xml_escape(Tayu.username)}"
                hostname="#{xml_escape(facts["fqdn"])}"/>
    EOH
        end
        xmlbody << "</project>"
        return xmlbody
    end
def generate_body xmlbody = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">\n<project>\n) get_nodes . each do | node | facts = get_facts ( node ) tags_config = Tayu . allowed_tags tags_rundeck = Array . new os_family = facts [ "kernel" ] =~ / windows /i ? 'windows' : 'unix' tags_config . each do | tag | if ! facts [ tag ] . nil? tags_rundeck << facts [ tag ] end end xmlbody << <<-EOH 
            <node name=" #{ xml_escape ( facts [ "fqdn" ] ) } "
                type="Node"
                description=" #{ xml_escape ( facts [ "fqdn" ] ) } "
                osArch=" #{ xml_escape ( facts [ "kernel" ] ) } "
                osFamily=" #{ xml_escape ( os_family ) } "
                osName=" #{ xml_escape ( facts [ "operatingsystem" ] ) } "
                tags=" #{ xml_escape ( tags_rundeck . join ( ',' ) ) } "
                osVersion=" #{ xml_escape ( facts [ "operatingsystemrelease" ] ) } "
                username=" #{ xml_escape ( Tayu . username ) } "
                hostname=" #{ xml_escape ( facts [ "fqdn" ] ) } "/>
     EOH end xmlbody << "</project>" return xmlbody end
generate xml document body based on retrieved nodes and there facts
generate xml document body based on retrieved nodes and there facts
# for each node get the facts  # check if value is empty if not add to array # xml body # close xml body and return results