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
    }
    

    }



522
523
524
525
526
527
528
529
530
# File 'lib/mb/errors.rb', line 522

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>)


508
509
510
# File 'lib/mb/errors.rb', line 508

def groups
  @groups
end

#host_errorsHash (readonly)

Returns:

  • (Hash)


510
511
512
# File 'lib/mb/errors.rb', line 510

def host_errors
  @host_errors
end

Instance Method Details

#messageObject



532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/mb/errors.rb', line 532

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