Sha256: ebd8ecd7ab108675a2d4b77e43a43adaac3b076fb5a06069e810fbc2cfa6284d

Contents?: true

Size: 1.09 KB

Versions: 22

Compression:

Stored size: 1.09 KB

Contents

<%= 
   all_catalog = nodes.map{ |n| [n['Node'], n] }.to_h
   all_members = agent_members.sort{ |a,b| a['Name'] <=> b['Name'] }
   members_by_state = {}
   all_members.each do |m|
     state = m.status
     members = members_by_state[state] || 0
     members_by_state[state] = members + 1
   end
   # Find all virtual nodes (eg: k8s-sync)
   catalog_external_sources = nodes.select{|n| (n['Meta']||{})['external-source'] }.map{|n| n['Node']}
   in_catalog_but_not_in_members = all_catalog.keys - all_members.map{ |m| m['Name'] }
   not_virtual_not_in_members = in_catalog_but_not_in_members - catalog_external_sources
   JSON.pretty_generate(
    {
      'stats' => {
        'catalog' => all_catalog.count,
        'catalog_virtual' => in_catalog_but_not_in_members.count,
        'members' => all_members.count,
        'members_by_state': members_by_state,
        'catalog_external_sources' => catalog_external_sources,
      },
      'errors': {
        'in_catalog_but_not_in_members' => in_catalog_but_not_in_members,
        'not_virtual_not_in_members'    =>  not_virtual_not_in_members,
      }
   })
%>

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
consul-templaterb-1.26.3 samples/find_nodes_in_catalog_but_not_in_members.json.erb
consul-templaterb-1.26.2 samples/find_nodes_in_catalog_but_not_in_members.json.erb