<commit_before># this recipe bootstraps a simple osd, with help from single_mon

# TODO manage actual disks, handle multiple OSDs per node, etc

include_recipe "ceph::osd"
include_recipe "ceph::conf"

gem_package "open4"

ruby_block 'bootstrap a single (fake) osd' do
  block do
    require 'tempfile'
    require 'open4'

    def subprocess(*args)
      Open4::spawn(args, :stdout=>STDERR, :stderr=>STDERR)
    end

    def get_bootstrap_osd_key()
      if is_crowbar?
        nodes = search(:node, "recipes:ceph\\:\\:single_mon AND ceph_config_environment:#{node[:ceph][:config][:environment]} AND ceph_bootstrap_osd_key:*")
      else
        nodes = search(:node, 'recipes:ceph\:\:single_mon AND chef_environment:#{node.chef_environment} AND ceph_bootstrap_osd_key:*')
      end
      raise 'No single_mon found.' if nodes.length < 1
      raise 'Too many single_mons found.' if nodes.length > 1
      node = nodes[0]
      key = node["ceph_bootstrap_osd_key"]
      return key
    end

    def ceph_bootstrap_osd(path)<commit_msg>Fix chef search syntax.<commit_after># this recipe bootstraps a simple osd, with help from single_mon

# TODO manage actual disks, handle multiple OSDs per node, etc

include_recipe "ceph::osd"
include_recipe "ceph::conf"

gem_package "open4"

ruby_block 'bootstrap a single (fake) osd' do
  block do
    require 'tempfile'
    require 'open4'

    def subprocess(*args)
      Open4::spawn(args, :stdout=>STDERR, :stderr=>STDERR)
    end

    def get_bootstrap_osd_key()
      if is_crowbar?
        nodes = search(:node, "recipes:ceph\\:\\:single_mon AND ceph_config_environment:#{node[:ceph][:config][:environment]} AND ceph_bootstrap_osd_key:*")
      else
        nodes = search(:node, "recipes:ceph\\:\\:single_mon AND chef_environment:#{node.chef_environment} AND ceph_bootstrap_osd_key:*")
      end
      raise 'No single_mon found.' if nodes.length < 1
      raise 'Too many single_mons found.' if nodes.length > 1
      node = nodes[0]
      key = node["ceph_bootstrap_osd_key"]
      return key
    end

    def ceph_bootstrap_osd(path)
{'fraction_non_alphanumeric': 0.10902977905859751, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 3.788505747126437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '943644', 'n_tokens_mistral': 711, 'n_tokens_neox': 689, 'n_words': 182}