Exception: MotherBrain::GroupBootstrapError

Inherits:
BootstrapError show all
Defined in:
lib/mb/errors.rb

Constant Summary

Constants inherited from MBError

MBError::DEFAULT_EXIT_CODE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MBError

#error_code, error_code, exit_code, #exit_code, #to_hash, #to_json, #to_s

Constructor Details

#initialize(host_errors) ⇒ GroupBootstrapError

Returns a new instance of GroupBootstrapError.

Parameters:

  • host_errors (Hash)

    “cloud-3.riotgames.com” => {

    groups: ["database_slave::default"],
    result: {
      status: :ok
      message: ""
      bootstrap_type: :partial
    }
    

    }



505
506
507
508
509
510
511
512
513
# File 'lib/mb/errors.rb', line 505

def initialize(host_errors)
  @groups      = Set.new
  @host_errors = Hash.new

  host_errors.each do |host, host_info|
    @host_errors[host] = host_info
    host_info[:groups].each { |group| @groups.add(group) }
  end
end

Instance Attribute Details

#groupsArray<String> (readonly)

Returns:

  • (Array<String>)


491
492
493
# File 'lib/mb/errors.rb', line 491

def groups
  @groups
end

#host_errorsHash (readonly)

Returns:

  • (Hash)


493
494
495
# File 'lib/mb/errors.rb', line 493

def host_errors
  @host_errors
end

Instance Method Details

#messageObject



515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/mb/errors.rb', line 515

def message
  err = ""
  groups.each do |group|
    err << "failure bootstrapping group #{group}\n"
    host_errors.each do |host, host_info|
      if host_info[:groups].include?(group)
        err << "  * #{host} #{host_info[:result]}\n"
      end
    end
    err << "\n"
  end
  err
end