Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 918 lines (765 sloc) 23.48 kb
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
# oracle_middleware_homes.rb
require 'rexml/document'
require 'facter'


def get_weblogicUser()
  weblogicUser = Facter.value('override_weblogic_user')
  if weblogicUser.nil?
    #puts "weblogic user is oracle"
  else
    #puts "weblogic user is " + weblogicUser
    return weblogicUser
  end
  return "oracle"
end

def get_domainFolder(mdwHome)
  domainFolder = Facter.value('override_weblogic_domain_folder')
  if domainFolder.nil?
    #puts "domain folder is " + mdwHome + "/user_projects"
  else
    #puts "domain folder is " + domainFolder
    return domainFolder
  end
  return mdwHome+"/user_projects"
end


# read middleware home in the oracle home folder
def get_homes()

  os = Facter.value(:operatingsystem)

  if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","SLES"].include?os
    beafile = "/home/"+get_weblogicUser()+"/bea/beahomelist"
  elsif ["Solaris"].include?os
    beafile = "/export/home/"+get_weblogicUser()+"/bea/beahomelist"
  elsif ["windows"].include?os
    beafile = "c:/bea/beahomelist"
  else
    return nil
  end

  if FileTest.exists?(beafile)
    output = File.read(beafile)
    if output.nil?
      return nil
    else
      return output.split(/;/)
    end
  else
    return nil
  end

end

def get_middleware_1212_Home(name)

    elements = []
    name.split(/;/).each_with_index{ |element, index|
      if FileTest.exists?(element+"/wlserver")
        elements.push(element)
      end
    }
    return elements
end

def get_nodemanagers()
  if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","SLES"].include?Facter.value(:operatingsystem)
    output = Facter::Util::Resolution.exec("/bin/ps -eo pid,cmd | /bin/grep -i nodemanager.javahome | /bin/grep -v grep | awk ' {print \"pid:\", substr(\$0,0,5), \"port:\" , substr(\$0,index(\$0,\"-DListenPort\")+13,4) } '")
    if output.nil?
      return nil
    else
      return output.split(/\r?\n/)
    end
  elsif ["Solaris"].include?Facter.value(:operatingsystem)
    output = Facter::Util::Resolution.exec("/usr/ucb/ps wwxa | /bin/grep -i nodemanager.javahome | /bin/grep -v grep | /usr/xpg4/bin/awk ' {print \"pid:\", substr(\$0,0,5), \"port:\" , substr(\$0,index(\$0,\"-DListenPort\")+13,4) } '")
    if output.nil?
      return nil
    else
      return output.split(/\r?\n/)
    end
  end
end

def get_wlsservers()
  if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","SLES"].include?Facter.value(:operatingsystem)
    output = Facter::Util::Resolution.exec("/bin/ps -eo pid,cmd | /bin/grep -i weblogic.server | /bin/grep -v grep | awk ' {print \"pid:\", substr(\$0,0,5), \"name:\" ,substr(\$0,index(\$0,\"weblogic.Name\")+14,12) }'")
    if output.nil?
      return nil
    else
      return output.split(/\r?\n/)
    end
  elsif ["Solaris"].include?Facter.value(:operatingsystem)
    output = Facter::Util::Resolution.exec("/usr/ucb/ps wwxa | /bin/grep -i weblogic.server | /bin/grep -v grep | /usr/xpg4/bin/awk ' {print \"pid:\", substr(\$0,0,5), \"name:\" ,substr(\$0,index(\$0,\"weblogic.Name\")+14,12) }'")
    if output.nil?
      return nil
    else
      return output.split(/\r?\n/)
    end
  end

end

def get_orainst_loc()
  os = Facter.value(:operatingsystem)
  if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","SLES"].include?os
    if FileTest.exists?("/etc/oraInst.loc")
      str = ""
      output = File.read("/etc/oraInst.loc")
      output.split(/\r?\n/).each do |item|
        if item.match(/^inventory_loc/)
          str = item[14,50]
        end
      end
      return str
    else
      return "NotFound"
    end
  elsif ["Solaris"].include?os
    if FileTest.exists?("/var/opt/oraInst.loc")
      str = ""
      output = File.read("/var/opt/oraInst.loc")
      output.split(/\r?\n/).each do |item|
        if item.match(/^inventory_loc/)
          str = item[14,50]
        end
      end
      return str
    else
      return "NotFound"
    end
  elsif ["windows"].include?os
    return "C:/Program Files/Oracle/Inventory"
  end
end

def get_orainst_products(path)
  unless path.nil?
    if FileTest.exists?(path+"/ContentsXML/inventory.xml")
      file = File.read( path+"/ContentsXML/inventory.xml" )
      doc = REXML::Document.new file
      software = ""
      doc.elements.each("/INVENTORY/HOME_LIST/HOME") do |element|
        str = element.attributes["LOC"]
        unless str.nil?
          software += str + ";"
        end
      end
      return software
    else
      return "NotFound"
    end
  else
    return "NotFound"
  end
end



# read weblogic domains in the domains folder of the middleware home
def get_domain(name,i,wlsversion)

  if wlsversion == "1212"
    versionStr = "_1212"
  else
    versionStr = ""
  end
  
  prefix = "ora_mdw#{versionStr}_#{i}"
  
  os = Facter.value(:operatingsystem)

  if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","Solaris","SLES"].include?os

    if FileTest.exists?( get_domainFolder(name)+'/domains')
      output2 = Facter::Util::Resolution.exec('/bin/ls '+ get_domainFolder(name)+'/domains')
      if output2.nil?
        Facter.add("#{prefix}_domain_cnt") do
          setcode do
            0
          end
        end
        return nil
      end
    else
      Facter.add("#{prefix}_domain_cnt") do
        setcode do
          0
        end
      end
      return nil
    end

  elsif ["windows"].include?os
    if FileTest.exists?( get_domainFolder(name)+'/domains')
      output2 = Facter::Util::Resolution.exec('C:\Windows\system32\cmd.exe /c dir /B '+ get_domainFolder(name)+'/domains')
      if output2.nil?
        Facter.add("#{prefix}_domain_cnt") do
          setcode do
            0
          end
        end
        return nil
      end
    else
      Facter.add("#{prefix}_domain_cnt") do
        setcode do
          0
        end
      end
      return nil
    end

  else
    return nil
  end

  l = 0

  output2.split(/\r?\n/).each_with_index do |domain, n|

    if ["CentOS", "RedHat","OracleLinux","Ubuntu","Debian","Solaris","SLES"].include?os
      domainfile = get_domainFolder(name)+'/domains/'+domain+'/config/config.xml'

    elsif ["windows"].include?os
      domainfile = get_domainFolder(name)+'/domains/'+domain+'/config/config.xml'
    end

    if FileTest.exists?(domainfile)

      file = File.read( domainfile)
      doc = REXML::Document.new file
      root = doc.root

      Facter.add("#{prefix}_domain_#{n}") do
        setcode do
          root.elements['name'].text
        end
      end

          
      file = File.read( domainfile)
      doc = REXML::Document.new file
      root = doc.root

      Facter.add("#{prefix}_domain_#{n}") do
        setcode do
          root.elements['name'].text
        end
      end


      if File.directory?(get_domainFolder(name)+'/domains/'+domain+'/soa/autodeploy')
        Facter.add("#{prefix}_domain_#{n}_oim_configured") do
          setcode do
            "true"
          end
        end
      else
        Facter.add("#{prefix}_domain_#{n}_oim_configured") do
          setcode do
            "false"
          end
        end
      end

      k = 0
      root.elements.each("server") do |server|
        Facter.add("#{prefix}_domain_#{n}_server_#{k}") do
          setcode do
            server.elements['name'].text
          end
        end
        
        port = server.elements['listen-port']
        unless port.nil?
          Facter.add("#{prefix}_domain_#{n}_server_#{k}_port") do
            setcode do
               port.text
            end
          end
        end
        machine = server.elements['machine']
        unless machine.nil?
          Facter.add("#{prefix}_domain_#{n}_server_#{k}_machine") do
            setcode do
               machine.text
            end
          end
        end
        k += 1
      end

      servers = ""
      root.elements.each("server") do |svr|
        servers += svr.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_servers") do
         setcode do
           servers
         end
      end

      machines = ""
      root.elements.each("machine") do |mch|
        machines += mch.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_machines") do
         setcode do
           machines
         end
      end
      
      
      server_templates = ""
      root.elements.each("server-template") do |svr_template|
        server_templates += svr_template.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_server_templates") do
         setcode do
           server_templates
         end
      end

      clusters = ""
      root.elements.each("cluster") do |cluster|
        clusters += cluster.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_clusters") do
         setcode do
           clusters
         end
      end

      coherence_clusters = ""
      root.elements.each("coherence-cluster-system-resource") do |coherence|
        coherence_clusters += coherence.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_coherence_clusters") do
         setcode do
           coherence_clusters
         end
      end
            
      bpmTargets = nil
      soaTargets = nil
      osbTargets = nil
      bamTargets = nil

      deployments = ""
      root.elements.each("app-deployment[module-type = 'ear']") do |apps|
        earName = apps.elements['name'].text
        deployments += earName + ";"

        if earName == "BPMComposer"
           bpmTargets = apps.elements['target'].text
        end
        if earName == "soa-infra"
           soaTargets = apps.elements['target'].text
        end
        if earName == "oracle-bam#11.1.1"
           bamTargets = apps.elements['target'].text
        end
        if earName == "ALSB Domain Singleton Marker Application"
           osbTargets = apps.elements['target'].text
        end
      end

      Facter.add("#{prefix}_domain_#{n}_deployments") do
         setcode do
            deployments
         end
      end

      unless bpmTargets.nil?
        Facter.add("#{prefix}_domain_#{n}_bpm") do
          setcode do
            bpmTargets
          end
        end
      else
        Facter.add("#{prefix}_domain_#{n}_bpm") do
          setcode do
            "NotFound"
          end
        end
      end
      unless soaTargets.nil?
        Facter.add("#{prefix}_domain_#{n}_soa") do
          setcode do
            soaTargets
          end
        end
      else
        Facter.add("#{prefix}_domain_#{n}_soa") do
          setcode do
            "NotFound"
          end
        end
      end
      unless bamTargets.nil?
        Facter.add("#{prefix}_domain_#{n}_bam") do
          setcode do
            bamTargets
          end
        end
      else
        Facter.add("#{prefix}_domain_#{n}_bam") do
          setcode do
            "NotFound"
          end
        end
      end
      unless osbTargets.nil?
        Facter.add("#{prefix}_domain_#{n}_osb") do
          setcode do
            osbTargets
          end
        end
      else
        Facter.add("#{prefix}_domain_#{n}_osb") do
          setcode do
            "NotFound"
          end
        end
      end

      fileAdapterPlan = ""
      fileAdapterPlanEntries = ""
      root.elements.each("app-deployment[name = 'FileAdapter']") do |apps|
        unless apps.elements['plan-dir'].nil?
          fileAdapterPlan += apps.elements['plan-dir'].text + "/" + apps.elements['plan-path'].text
          subfile = File.read( fileAdapterPlan )
          subdoc = REXML::Document.new subfile

          planroot = subdoc.root
          planroot.elements["variable-definition"].elements.each("variable") do |eis|
            entry = eis.elements["value"].text
            if entry.include? "eis"
              fileAdapterPlanEntries += eis.elements["value"].text + ";"
            end
          end

        end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_fileadapter_plan") do
         setcode do
            fileAdapterPlan
         end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_fileadapter_entries") do
         setcode do
            fileAdapterPlanEntries
         end
      end


      dbAdapterPlan = ""
      dbAdapterPlanEntries = ""
      root.elements.each("app-deployment[name = 'DbAdapter']") do |apps|
        unless apps.elements['plan-dir'].nil?
          dbAdapterPlan += apps.elements['plan-dir'].text + "/" + apps.elements['plan-path'].text

          subfile = File.read( dbAdapterPlan )
          subdoc = REXML::Document.new subfile

          planroot = subdoc.root
          planroot.elements["variable-definition"].elements.each("variable") do |eis|
            entry = eis.elements["value"].text
            if entry.include? "eis"
              dbAdapterPlanEntries += eis.elements["value"].text + ";"
            end
          end


        end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_dbadapter_plan") do
         setcode do
            dbAdapterPlan
         end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_dbadapter_entries") do
         setcode do
            dbAdapterPlanEntries
         end
      end



      aqAdapterPlan = ""
      aqAdapterPlanEntries = ""
      root.elements.each("app-deployment[name = 'AqAdapter']") do |apps|
        unless apps.elements['plan-dir'].nil?
          aqAdapterPlan = apps.elements['plan-dir'].text + "/" + apps.elements['plan-path'].text

          subfile = File.read( aqAdapterPlan )
          subdoc = REXML::Document.new subfile

          planroot = subdoc.root
          planroot.elements["variable-definition"].elements.each("variable") do |eis|
            entry = eis.elements["value"].text
            if entry.include? "eis"
              aqAdapterPlanEntries += eis.elements["value"].text + ";"
            end
          end
        end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_aqadapter_plan") do
         setcode do
            aqAdapterPlan
         end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_aqadapter_entries") do
         setcode do
            aqAdapterPlanEntries
         end
      end


      jmsAdapterPlan = ""
      jmsAdapterPlanEntries = ""
      root.elements.each("app-deployment[name = 'JmsAdapter']") do |apps|
        unless apps.elements['plan-dir'].nil?
          jmsAdapterPlan += apps.elements['plan-dir'].text + "/" + apps.elements['plan-path'].text

          subfile = File.read( jmsAdapterPlan )
          subdoc = REXML::Document.new subfile

          planroot = subdoc.root
          planroot.elements["variable-definition"].elements.each("variable") do |eis|
            entry = eis.elements["value"].text
            if entry.include? "eis"
              jmsAdapterPlanEntries += eis.elements["value"].text + ";"
            end
          end

        end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_jmsadapter_plan") do
         setcode do
            jmsAdapterPlan
         end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_jmsadapter_entries") do
         setcode do
            jmsAdapterPlanEntries
         end
      end



      ftpAdapterPlan = ""
      ftpAdapterPlanEntries = ""
      root.elements.each("app-deployment[name = 'FtpAdapter']") do |apps|
        unless apps.elements['plan-dir'].nil?
          ftpAdapterPlan += apps.elements['plan-dir'].text + "/" + apps.elements['plan-path'].text

          subfile = File.read( ftpAdapterPlan )
          subdoc = REXML::Document.new subfile

          planroot = subdoc.root
          planroot.elements["variable-definition"].elements.each("variable") do |eis|
            entry = eis.elements["value"].text
            if entry.include? "eis"
              ftpAdapterPlanEntries += eis.elements["value"].text + ";"
            end
          end


        end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_ftpadapter_plan") do
         setcode do
            ftpAdapterPlan
         end
      end

      Facter.add("#{prefix}_domain_#{n}_eis_ftpadapter_entries") do
         setcode do
            ftpAdapterPlanEntries
         end
      end



      libraries = ""
      root.elements.each("library") do |libs|
        libraries += libs.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_libraries") do
         setcode do
            libraries
         end
      end

      filestores = ""
      root.elements.each("file-store") do |file|
        filestores += file.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_filestores") do
         setcode do
            filestores
         end
      end

      jdbcstores = ""
      root.elements.each("jdbc-store") do |jdbc|
        jdbcstores += jdbc.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_jdbcstores") do
         setcode do
            jdbcstores
         end
      end

      safagents = ""
      root.elements.each("saf-agent") do |agent|
        safagents += agent.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_safagents") do
         setcode do
            safagents
         end
      end

      jmsserversstr = ""
      root.elements.each("jms-server") do |jmsservers|
        jmsserversstr += jmsservers.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_jmsservers") do
        setcode do
          jmsserversstr
         end
      end

      k = 0
      jmsmodulestr = ""
      root.elements.each("jms-system-resource") do |jmsresource|
        jmsstr = ""
        jmssubdeployments = ""
        jmsmodulestr += jmsresource.elements['name'].text + ";"

        jmsresource.elements.each("sub-deployment") do |sub|
          jmssubdeployments += sub.elements['name'].text + ";"
        end

        Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_subdeployments") do
          setcode do
            jmssubdeployments
          end
        end

        unless jmsresource.elements['descriptor-file-name'].nil?
          fileJms = jmsresource.elements['descriptor-file-name'].text
        else
          fileJms = "jms/"+jmsresource.elements['name'].text.downcase + "-jms.xml"
        end
 
        subfile = File.read( get_domainFolder(name)+'/domains/'+domain+"/config/" + fileJms )
        subdoc = REXML::Document.new subfile

        jmsroot = subdoc.root

        jmsmoduleQuotaStr = ""
        jmsroot.elements.each("quota") do |qu|
          jmsmoduleQuotaStr += qu.attributes["name"] + ";"
        end

        Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_quotas") do
          setcode do
            jmsmoduleQuotaStr
          end
        end

        jmsmoduleForeingServerStr = ""
        jmsroot.elements.each("foreign-server") do |fs|
          fsName = fs.attributes["name"]
          jmsmoduleForeingServerStr += fsName + ";"

          jmsmoduleForeignServerObjectsStr = ""
          fs.elements.each("foreign-destination") do |cf|
            jmsmoduleForeignServerObjectsStr += cf.attributes["name"] + ";"
          end
          fs.elements.each("foreign-connection-factory") do |dest|
            jmsmoduleForeignServerObjectsStr += dest.attributes["name"] + ";"
          end

          Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_foreign_server_#{fsName}_objects") do
            setcode do
              jmsmoduleForeignServerObjectsStr
            end
          end

          #puts "#{prefix}_domain_#{n}_jmsmodule_#{k}_foreign_server_#{fsName}_objects"
          #puts "values "+jmsmoduleForeignServerObjectsStr
        end

        Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_foreign_servers") do
          setcode do
            jmsmoduleForeingServerStr
          end
        end
        #puts "#{prefix}_domain_#{n}_jmsmodule_#{k}_foreign_servers"
        #puts "values "+jmsmoduleForeingServerStr
        

        jmsroot.elements.each("connection-factory") do |cfs|
          jmsstr += cfs.attributes["name"] + ";"
        end

        jmsroot.elements.each("queue") do |queues|
          jmsstr += queues.attributes["name"] + ";"
        end
        jmsroot.elements.each("uniform-distributed-queue") do |dist_queues|
          jmsstr += dist_queues.attributes["name"] + ";"
        end
        
        jmsroot.elements.each("topic") do |topics|
          jmsstr += topics.attributes["name"] + ";"
        end
        jmsroot.elements.each("uniform-distributed-topic") do |dist_topics|
          jmsstr += dist_topics.attributes["name"] + ";"
        end

        
        Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_name") do
          setcode do
            jmsresource.elements['name'].text
          end
        end

        Facter.add("#{prefix}_domain_#{n}_jmsmodule_#{k}_objects") do
          setcode do
            jmsstr
          end
        end
        k += 1
      end
      Facter.add("#{prefix}_domain_#{n}_jmsmodules") do
        setcode do
          jmsmodulestr
        end
      end
      Facter.add("#{prefix}_domain_#{n}_jmsmodule_cnt") do
        setcode do
          k
        end
      end

      jdbcstr = ""
      root.elements.each("jdbc-system-resource") do |jdbcresource|
        jdbcstr += jdbcresource.elements['name'].text + ";"
      end

      Facter.add("#{prefix}_domain_#{n}_jdbc") do
        setcode do
          jdbcstr
        end
      end


      l += 1
    end

  end

  Facter.add("#{prefix}_domain_cnt") do
    setcode do
      l
    end
  end
 
end



mdw11gHomes = get_homes
inventory = get_orainst_loc
inventory2 = get_orainst_products(inventory)
mdw12gHomes = get_middleware_1212_Home(inventory2)

# report all oracle homes / domains
unless mdw11gHomes.nil?
  mdw11gHomes.each_with_index do |mdw, i|
    Facter.add("ora_mdw_#{i}") do
      setcode do
        mdw
      end
    end
    get_domain(mdw, i,"1111")
  end
end


# all homes on 1 row
unless mdw11gHomes.nil?
  str = ""
  mdw11gHomes.each do |item|
    str += item + ";"
  end
  Facter.add("ora_mdw_homes") do
    setcode do
      str
    end
  end
end

# all homes on 1 row
unless mdw12gHomes.nil?
  str = ""
  mdw12gHomes.each do |item|
    str += item + ";"
  end
  Facter.add("ora_mdw_1212_homes") do
    setcode do
      str
    end
  end
end

# report all oracle homes / domains
unless mdw12gHomes.nil?
  mdw12gHomes.each_with_index do |mdw, i|
    Facter.add("ora_mdw_1212_#{i}") do
      setcode do
        mdw
      end
    end
    get_domain(mdw, i,"1212")
  end
end


# all nodemanager
unless get_nodemanagers.nil?
  get_nodemanagers.each_with_index do |node, a|
    Facter.add("ora_node_mgr_#{a}") do
      setcode do
        node
      end
    end
  end
end

# report all weblogic servers
unless get_wlsservers.nil?
  get_wlsservers.each_with_index do |wls, i|
    Facter.add("ora_wls_#{i}") do
      setcode do
        wls
      end
    end
  end
end

# all home counter
Facter.add("ora_mdw_cnt") do

  count = 0
  unless mdw11gHomes.nil?
    count = mdw11gHomes.count
  end

  setcode do
    count
  end
end

# all 12c home counter
Facter.add("ora_mdw_1212_cnt") do
  count = 0
  unless mdw12gHomes.nil?
    count = mdw12gHomes.count
  end

  setcode do
    count
  end
end


# get orainst loc data
Facter.add("ora_inst_loc_data") do
  setcode do
    inventory
  end
end

# get orainst products
Facter.add("ora_inst_products") do
  setcode do
    inventory2
  end
end


Something went wrong with that request. Please try again.