<commit_before># recipe example setup nim master
# Assume that the 'nim_server' is the hostname of the nim server
# Assume that the level of lpp_source required for installing bos.sysmgmt.nim.master
# has already been allocated by nim server and fs exported.
# > nim -o allocate -a lpp_source=<lpp_source> <new_nim_server>
# > exportfs

nim_server = 'fattony01'
lpp_source = '7143lpp_res'

# mounting /mnt
mount '/mnt' do
  device "#{nim_server}:/export/nim/lpp_source/#{lpp_source}"
  fstype 'nfs'
  action :mount
end

# setup nim master
aix_nim 'Install nim package' do
  device '/mnt'
  action :master_setup
end

# unmount /mnt
mount '/mnt' do
  action :umount
end

# Do not forget to deallocate the resource on the old nim server
# > nim -o deallocate -a lpp_source=<lpp_source> <new_nim_server><commit_msg>New recipe to setup a nim master<commit_after># recipe example setup nim master
# Assume that the 'nim_server' is the hostname of the current nim server
# and the 'new_nim_server' is the hostname of the nim master to setup
nim_server = 'pollux6'
lpp_source = '1626A_72D_lpp'
new_nim_server = 'pollux6c'

nim_script_res_name  = "chef_nim_setup_script_#{new_nim_server}"
nim_script_file_name = "/tmp/#{nim_script_res_name}.sh"
mount_point = "/mnt_chef_master_setup"

cmd = Mixlib::ShellOut.new("lsnim -l #{lpp_source} | grep location | awk '{ print $NF }'")
cmd.run_command
cmd.valid_exit_codes = 0
if cmd.error?
  ;
end
nim_res_path = cmd.stdout.chomp

# Create the script to set the new nim master
file "#{nim_script_file_name}" do
  content "#!/bin/ksh\nexport LANG=C\nmkdir #{mount_point}\nmount #{nim_server}:#{nim_res_path} #{mount_point}\nnim_master_setup -a mk_resource=no -B -a device=#{mount_point}\numount #{mount_point}\nrmdir #{mount_point}\n"
  mode '0777'
  owner 'root'
  action :create
end

# Define the script nim resource
execute 'def_script_res' do
  command "nim -o define -t script -a location=#{nim_script_file_name} -a server=master #{nim_script_res_name}"
  action :run
end

# Allocate the required lpp_source
aix_nim 'Allocate lpp_source' do
  lpp_source "#{lpp_source}"
  targets "#{new_nim_server}"
  action :allocate
end

# Export the resources
execute 'export_res' do
  command "exportfs"
  action :run
end

# Setup the nim master
execute 'setup_master' do
  command "nim -o cust -a script=#{nim_script_res_name} -a async=no #{new_nim_server}"
  action :run
end

# Deallocate the resource on the old nim server
aix_nim 'Deallocate lpp_source' do
  lpp_source "#{lpp_source}"
  targets "#{new_nim_server}"
  action :deallocate
end

# Remove the script resource
execute 'rem_script_res' do
  command "nim -o remove #{nim_script_res_name}"
  action :run
end

# Remove the script file
file "#{nim_script_file_name}" do
  action :delete
end
{'fraction_non_alphanumeric': 0.10021629416005767, 'fraction_numerical': 0.00684931506849315, 'mean_word_length': 5.019522776572668, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '2105111', 'n_tokens_mistral': 1017, 'n_tokens_neox': 1016, 'n_words': 306}