Class: ProxES::NodesStatusCheck
- Inherits:
-
StatusCheck
- Object
- Sequel::Model
- StatusCheck
- ProxES::NodesStatusCheck
show all
- Defined in:
- lib/proxes/models/status_checks/nodes_status_check.rb
Constant Summary
Constants inherited
from StatusCheck
StatusCheck::SOURCE_CALLS
Instance Method Summary
collapse
Methods inherited from StatusCheck
#passed?, #policy_class, #source_result, source_result, #validate
#client, #conn, #ssl_store
Instance Method Details
#check ⇒ Object
25
26
27
28
29
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 25
def check
return true if required_value.blank?
required_value.to_i == value
end
|
#check_node(node) ⇒ Object
13
14
15
16
17
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 13
def check_node(node)
node['roles']&.include?(node_type) ||
node['attributes'] && node.dig('attributes', node_type) != 'false' ||
node.dig('settings', 'node') && node.dig('settings', 'node', node_type) != 'false'
end
|
#children ⇒ Object
19
20
21
22
23
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 19
def children
@children ||= source_result['nodes']['nodes'].map do |_id, node|
[node['name'], 1] if check_node(node)
end.compact.to_h
end
|
31
32
33
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 31
def formatted(val = nil)
(val || value).to_i == 1 ? '1 Node' : "#{val || value} Nodes"
end
|
#node_type ⇒ Object
5
6
7
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 5
def node_type
raise 'Unimplemented'
end
|
#value ⇒ Object
9
10
11
|
# File 'lib/proxes/models/status_checks/nodes_status_check.rb', line 9
def value
children.count
end
|