<commit_before>JunosNC::Facts::Keeper.define( :chassis ) do |ndev, facts|
  
  inv_info = ndev.rpc.get_chassis_inventory
  chassis = inv_info.xpath('chassis')
  
  facts[:hardwaremodel] = chassis.xpath('description').text
  facts[:serialnumber] = chassis.xpath('serial-number').text           
end

JunosNC::Facts::Keeper.define( :master ) do |ndev, facts|
  uses :routingengines
end

JunosNC::Facts::Keeper.define( :routingengines ) do |ndev, facts|

  re_facts = ['mastership-state','status','model','up-time','last-reboot-reason']
  re_info = ndev.rpc.get_route_engine_information
  re_info.xpath('//route-engine').each do |re|
    slot_id = re.xpath('slot').text || "0"
    slot = ("RE" + slot_id).to_sym
    facts[slot] = Hash[ re_facts.collect{ |ele| [ ele.tr('-','_').to_sym, re.xpath(ele).text ] } ]
    facts[:master] = slot_id if facts[slot][:mastership_state] == 'master'
  end
  
end

        
<commit_msg>updates<commit_after>JunosNC::Facts::Keeper.define( :chassis ) do |ndev, facts|
  
  inv_info = ndev.rpc.get_chassis_inventory
  chassis = inv_info.xpath('chassis')
  
  facts[:hardwaremodel] = chassis.xpath('description').text
  facts[:serialnumber] = chassis.xpath('serial-number').text           
end

JunosNC::Facts::Keeper.define( :master ) do |ndev, facts|
  uses :routingengines
end

JunosNC::Facts::Keeper.define( :routingengines ) do |ndev, facts|

  re_facts = ['mastership-state','status','model','up-time','last-reboot-reason']
  re_info = ndev.rpc.get_route_engine_information
  re_info.xpath('//route-engine').each do |re|
    slot_id = re.xpath('slot').text || "0"
    slot = ("RE" + slot_id).to_sym
    facts[slot] = Hash[ re_facts.collect{ |ele| [ ele.tr('-','_').to_sym, re.xpath(ele).text ] } ]
    if facts[slot][:mastership_state].empty?
      facts[slot].delete :mastership_state
    else 
      facts[:master] = slot_id if facts[slot][:mastership_state] == 'master'
    end
  end
  
end

        

{'fraction_non_alphanumeric': 0.17079463364293085, 'fraction_numerical': 0.0010319917440660474, 'mean_word_length': 4.212365591397849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5258870', 'n_tokens_mistral': 750, 'n_tokens_neox': 716, 'n_words': 112}