Class: Crowbar::Client::Command::Database::Create

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

Overview

Implementation for the database create 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



29
30
31
32
33
34
# File 'lib/crowbar/client/command/database/create.rb', line 29

def args_with_options
  args.easy_merge!(
    db_username: options.db_username,
    db_password: options.db_password
  )
end

#executeObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/crowbar/client/command/database/create.rb', line 42

def execute
  request.process do |request|
    case request.code
    when 200
      say "Successfully created database"
    else
      err request.parsed_response["error"]
    end
  end
end

#requestObject



36
37
38
39
40
# File 'lib/crowbar/client/command/database/create.rb', line 36

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