<commit_before>def package_arch
  if node['os'] == 'windows' && node['consul']['version'] < '0.6.0'
    '386'
  else
    node['kernel']['machine'] == 'x86_64' ? 'amd64' : '386'
  end
end

def notify_service_restart?
  if node['consul']['notify_restart'] && !node['consul']['disable_service']
    true
  else
    false
  end
end

def consul_sha256sum(version)
  sha256sums = {
    'windows' => {
      '386' => {
        '0.5.2' => '2e866812de16f1a6138a0fd1eebc76143f1314826e3b52597a55ac510ae94be6',
        '0.6.0' => '8379afd07668933c120880bba8228277e380abb14e07a6c45b94562ac19b37bd',
        '0.6.3' => '55733a730c5055d0ed1dc2656b2b6a27b21c7c361a907919cfae90aab2dff870'
      },
      'amd64' => {
        '0.6.0' => '182beea0d8d346a9bfd70679621a5542aeeeea1f35be81fa3d3aeec2479bac3d',
        '0.6.3' => '04cd1fdc9cd3a27ffc64e312e40142db7af0d240608f8080ec6d238294b20652'
      }
    },
    'linux' => {
      '386' => {
        '0.5.2' => '29306ce398109f954ceeea3af79878be4fb0d949f8af3a27c95ccef2101e8f60',
        '0.6.0' => 'f58f3f03a8b48d89bb8be94a6d1767393ad2a410c920b064066e01c7fa24f06c',
        '0.6.3' => '2afb65383ab913344daaa9af827c1e8576c7cae16e93798048122929b6e4cc92'
      },
      'amd64' => {
        '0.5.2' => '171cf4074bfca3b1e46112105738985783f19c47f4408377241b868affa9d445',
        '0.6.0' => '307fa26ae32cb8732aed2b3320ed8daf02c28b50d952cbaae8faf67c79f78847',
        '0.6.3' => 'b0532c61fec4a4f6d130c893fd8954ec007a6ad93effbe283a39224ed237e250'
      }
    }
  }
  sha256sum = sha256sums[node['os']][package_arch][version]
  fail "sha256sum is missing for consul package version #{version}" unless sha256sum
  sha256sum
end

def webui_sha256sum(version)
  sha256sums = {
    '0.5.2' => 'ad883aa52e1c0136ab1492bbcedad1210235f26d59719fb6de3ef6464f1ff3b1',
    '0.6.0' => '73c5e7ee50bb4a2efe56331d330e6d7dbf46335599c028344ccc4031c0c32eb0',
    '0.6.3' => '93bbb300cacfe8de90fb3bd5ede7d37ae6ce014898edc520b9c96a676b2bbb72'
  }
  sha256sum = sha256sums[version]
  fail "sha256sum is missing for consul web ui package version #{version}" unless sha256sum
  sha256sum
end<commit_msg>Added helpers for join and join-wan ip-addresses<commit_after>def package_arch
  if node['os'] == 'windows' && node['consul']['version'] < '0.6.0'
    '386'
  else
    node['kernel']['machine'] == 'x86_64' ? 'amd64' : '386'
  end
end

def notify_service_restart?
  if node['consul']['notify_restart'] && !node['consul']['disable_service']
    true
  else
    false
  end
end

def consul_sha256sum(version)
  sha256sums = {
    'windows' => {
      '386' => {
        '0.5.2' => '2e866812de16f1a6138a0fd1eebc76143f1314826e3b52597a55ac510ae94be6',
        '0.6.0' => '8379afd07668933c120880bba8228277e380abb14e07a6c45b94562ac19b37bd',
        '0.6.3' => '<KEY>'
      },
      'amd64' => {
        '0.6.0' => '182beea0d8d346a9bfd70679621a5542aeeeea1f35be81fa3d3aeec2479bac3d',
        '0.6.3' => '04cd1fdc9cd3a27ffc64e312e40142db7af0d240608f8080ec6d238294b20652'
      }
    },
    'linux' => {
      '386' => {
        '0.5.2' => '29306ce398109f954ceeea3af79878be4fb0d949f8af3a27c95ccef2101e8f60',
        '0.6.0' => 'f58f3f03a8b48d89bb8be94a6d1767393ad2a410c920b064066e01c7fa24f06c',
        '0.6.3' => '2afb65383ab913344daaa9af827c1e8576c7cae16e93798048122929b6e4cc92'
      },
      'amd64' => {
        '0.5.2' => '171cf4074bfca3b1e46112105738985783f19c47f4408377241b868affa9d445',
        '0.6.0' => '307fa26ae32cb8732aed2b3320ed8daf02c28b50d952cbaae8faf67c79f78847',
        '0.6.3' => 'b0532c61fec4a4f6d130c893fd8954ec007a6ad93effbe283a39224ed237e250'
      }
    }
  }
  sha256sum = sha256sums[node['os']][package_arch][version]
  fail "sha256sum is missing for consul package version #{version}" unless sha256sum
  sha256sum
end

def webui_sha256sum(version)
  sha256sums = {
    '0.5.2' => 'ad883aa52e1c0136ab1492bbcedad1210235f26d59719fb6de3ef6464f1ff3b1',
    '0.6.0' => '73c5e7ee50bb4a2efe56331d330e6d7dbf46335599c028344ccc4031c0c32eb0',
    '0.6.3' => '93bbb300cacfe8de90fb3bd5ede7d37ae6ce014898edc520b9c96a676b2bbb72'
  }
  sha256sum = sha256sums[version]
  fail "sha256sum is missing for consul web ui package version #{version}" unless sha256sum
  sha256sum
end


module ConsulJoinHelper
  # Function to assist in getting an array of consul server ip addresses in a specific consul dc. Useful to fill the join addresses for a member
  def get_consul_server_ips(excludeself = false,datacenter = node['consul']['config']['datacenter'])
    arrIp = Array.new
    if Chef::Config[:solo]
          Chef::Log.warn('This recipe uses search. Chef Solo does not support search.')
        else
      search(:node, "consul_config_server:true AND consul_config_datacenter:\""+datacenter+"\"", 
      :filter_result => { 'ip' => [ 'ipaddress' ] }
      ).each do |result|
        unless (excludeself && (result['ip'] == node['ipaddress']))
            arrIp.push(result['ip'])
        end
        end
    end
    return arrIp.uniq.sort!
  end

  # Function to assist in getting an array of consul server ip addresses in an array of consul dc's. Useful to fill the join-wan addresses for servers.
  def get_consul_dc_ips(datacenters = [])
    arrIp = Array.new
    datacenters.each do | dc|
      arrIp+=get_consul_server_ips(false,dc)
    end
    return arrIp.uniq.sort!
  end
end
{'fraction_non_alphanumeric': 0.12130961392884179, 'fraction_numerical': 0.24261922785768358, 'mean_word_length': 4.018993352326686, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 46, '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': '7180080', 'n_tokens_mistral': 2953, 'n_tokens_neox': 2348, 'n_words': 306}