Arborist::CLI::

Summary

module
Extended With
Arborist::CLI::Subcommand

Command to fetch down/acked/disabled nodes for quick display.

Constants

Public Instance Methods

anchor
format_acked( nodes, sort_key )

Prepare an array of acked/disabled nodes.

# File lib/arborist/command/summary.rb, line 122
def format_acked( nodes, sort_key )
        header = [
                highlight_string( 'identifier' ),
                highlight_string( 'type' ),
                highlight_string( 'when' ),
                highlight_string( 'who' ),
                highlight_string( 'message' )
        ]

        rows = nodes.sort_by{|n| n[sort_key] }.each_with_object([]) do |node, acc|
                acc << [
                        hl.disabled( node['identifier'] ),
                        node[ 'type' ],
                        Time.parse( node[ 'status_changed' ] ).as_delta,
                        node[ 'ack' ][ 'sender' ],
                        node[ 'ack' ][ 'message' ]
                ]
        end
        return header, rows
end
anchor
format_down( nodes, sort_key )

Prepare an array of down nodes.

# File lib/arborist/command/summary.rb, line 145
def format_down( nodes, sort_key )
        return nodes.sort_by{|n| n[sort_key] }.each_with_object([]) do |node, acc|
                errors = node[ 'errors' ].map{|err| "%s: %s" % [ err.first, err.last ]}
                acc << [
                        hl.down( node['identifier'] ),
                        node[ 'type' ],
                        Time.parse( node[ 'status_changed' ] ).as_delta,
                        errors.join( "\n" )
                ]
        end
end
anchor
format_warn( nodes, sort_key )

Prepare an array of nodes in a warning state.

# File lib/arborist/command/summary.rb, line 159
def format_warn( nodes, sort_key )
        return nodes.sort_by{|n| n[sort_key] }.each_with_object([]) do |node, acc|
                warnings = node[ 'warnings' ].map{|err| "%s: %s" % [ err.first, err.last ]}
                acc << [
                        hl.warn( node['identifier'] ),
                        node[ 'type' ],
                        Time.parse( node[ 'status_changed' ] ).as_delta,
                        warnings.join( "\n" )
                ]
        end
end
anchor
get_status( nodes, status )

Since we fetch all nodes instead of doing separate API searches, quickly return nodes of a given status.

# File lib/arborist/command/summary.rb, line 72
def get_status( nodes, status )
        return nodes.select{|n| n['status'] == status}
end
anchor
output_problems( disabled, acked, down, quieted, warning, sort )

Output all problems.

# File lib/arborist/command/summary.rb, line 79
def output_problems( disabled, acked, down, quieted, warning, sort )
        unless disabled.size.zero?
                prompt.say hl.headline( "Disabled Nodes" )
                display_table( *format_acked(disabled, sort) )
                puts
        end
        unless acked.size.zero?
                prompt.say hl.headline( "Acknowledged Outages" )
                display_table( *format_acked(acked, sort) )
                puts
        end
        unless warning.size.zero?
                prompt.say hl.headline( "Warnings" )
                header = [
                        highlight_string( 'identifier' ),
                        highlight_string( 'type' ),
                        highlight_string( 'when' ),
                        highlight_string( 'warnings' )
                ]

                display_table( header, format_warn(warning, sort) )
                puts
        end
        unless down.size.zero?
                prompt.say hl.headline( "Current Outages" )
                header = [
                        highlight_string( 'identifier' ),
                        highlight_string( 'type' ),
                        highlight_string( 'when' ),
                        highlight_string( 'errors' )
                ]

                display_table( header, format_down(down, sort) )
                prompt.say "%d nodes have been %s as a result of the above problems." % [
                        quieted.size,
                        hl.quieted( 'quieted' )
                ]
                puts
        end
end