Sha256: c2340b00c7c76c6cac7cc85ef69beea3b9dcb9b69c3942111aae79a615170c36

Contents?: true

Size: 622 Bytes

Versions: 18

Compression:

Stored size: 622 Bytes

Contents

require 'chef/search/query'

# simplified access to databags in the nagios cookbook
class NagiosDataBags
  attr_accessor :bag_list

  def initialize(bag_list = Chef::DataBag.list)
    @bag_list = bag_list
  end

  # Returns an array of data bag items or an empty array
  # Avoids unecessary calls to search by checking against
  # the list of known data bags.
  def get(bag_name)
    results = []
    if @bag_list.include?(bag_name)
      Chef::Search::Query.new.search(bag_name.to_s, '*:*') { |rows| results << rows }
    else
      Chef::Log.info "The #{bag_name} data bag does not exist."
    end
    results
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cloud-mu-2.0.4 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.1.0beta cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.3 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.2 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.1 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.beta3 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.beta2 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.beta1 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha9 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha8 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha7 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha6 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha5 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha4 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha3 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha2 cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-2.0.0.pre.alpha cookbooks/nagios/libraries/data_bag_helper.rb
cloud-mu-1.9.0.pre.beta cookbooks/nagios/libraries/data_bag_helper.rb