class Crowbar::Client::Command::Upgrade::Database

Implementation for the upgrade Database command

Public Instance Methods

args_with_options() click to toggle source
# File lib/crowbar/client/command/upgrade/database.rb, line 30
def args_with_options
  args.easy_merge!(
    username: options.db_username,
    password: options.db_password,
    database: options.database,
    host: options.host,
    port: options.port
  )
end
execute() click to toggle source
# File lib/crowbar/client/command/upgrade/database.rb, line 46
def execute
  validate_params!(args_with_options)

  request.process do |request|
    unless request.code == 200
      err format_error(
        request.parsed_response["error"], "database"
      )
    end

    response = JSON.parse(request.body)

    steps_with_messages.each do |step, message|
      next if response[step.to_s]["success"]
      err "Failed to #{message}"
    end

    say "Successfully initialized Crowbar"
    say "Next step: 'crowbarctl upgrade repocheck nodes'"
  end
end
request() click to toggle source
# File lib/crowbar/client/command/upgrade/database.rb, line 40
def request
  @request ||= Request::Upgrade::Database.new(
    args_with_options
  )
end

Protected Instance Methods

steps_with_messages() click to toggle source
# File lib/crowbar/client/command/upgrade/database.rb, line 70
def steps_with_messages
  {
    database_setup: "Setup the Crowbar database",
    database_migration: "Migrate the Crowbar database",
    crowbar_init: "Initialize Crowbar"
  }
end