Class: Crowbar::Client::Command::Upgrade::Database

Inherits:
Base
  • Object
show all
Includes:
Mixin::Database, Mixin::UpgradeError
Defined in:
lib/crowbar/client/command/upgrade/database.rb

Overview

Implementation for the upgrade Database command

Constant Summary

Constants included from Mixin::Database

Mixin::Database::REGEX_DATABASE, Mixin::Database::REGEX_HOSTNAME, Mixin::Database::REGEX_IPV4, Mixin::Database::REGEX_PASSWORD, Mixin::Database::REGEX_PORT, Mixin::Database::REGEX_USERNAME

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Crowbar::Client::Command::Base

Instance Method Details

#args_with_optionsObject



30
31
32
33
34
35
36
37
38
# 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

#executeObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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

#requestObject



40
41
42
43
44
# File 'lib/crowbar/client/command/upgrade/database.rb', line 40

def request
  @request ||= Request::Upgrade::Database.new(
    args_with_options
  )
end