Sha256: f2289b54282030882d151aaf03e68f26a144536e8a68ae68cef047ec45f492ab

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

require 'onceover/controlrepo'

class Onceover
  class Node
    @@all = []


    attr_accessor :name
    attr_accessor :beaker_node
    attr_accessor :fact_set
    attr_accessor :trusted_set

    def initialize(name)
      @name = name
      @beaker_node = nil

      # If we can't find the factset it will fail, so just catch that error and ignore it
      begin
        facts_file_index = Onceover::Controlrepo.facts_files.index {|facts_file|
          File.basename(facts_file, '.json') == name
        }
        @fact_set = Onceover::Controlrepo.facts[facts_file_index]
        @trusted_set = Onceover::Controlrepo.trusted_facts[facts_file_index]
      rescue TypeError
        @fact_set = nil
        @trusted_set = nil
      end

      @@all << self

    end

    def self.find(node_name)
      @@all.each do |node|
        if node_name.is_a?(Onceover::Node)
          if node = node_name
            return node
          end
        elsif node.name == node_name
          return node
        end
      end
      logger.warn "Node #{node_name} not found"
      nil
    end

    def self.all
      @@all
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
onceover-3.13.2 lib/onceover/node.rb
onceover-3.13.1 lib/onceover/node.rb
onceover-3.13.0 lib/onceover/node.rb
onceover-3.12.5 lib/onceover/node.rb
onceover-3.12.4 lib/onceover/node.rb
onceover-3.12.3 lib/onceover/node.rb
onceover-3.12.2 lib/onceover/node.rb
onceover-3.12.1 lib/onceover/node.rb
onceover-3.12.0 lib/onceover/node.rb
onceover-3.11.1 lib/onceover/node.rb
onceover-3.11.0 lib/onceover/node.rb
onceover-3.10.2 lib/onceover/node.rb
onceover-3.10.1 lib/onceover/node.rb
onceover-3.10.0 lib/onceover/node.rb
onceover-3.9.0 lib/onceover/node.rb
onceover-3.8.0 lib/onceover/node.rb
onceover-3.7.0 lib/onceover/node.rb
onceover-3.6.2 lib/onceover/node.rb
onceover-3.6.1 lib/onceover/node.rb
onceover-3.6.0 lib/onceover/node.rb