Class: Reptile::Users

Inherits:
Object
  • Object
show all
Defined in:
lib/reptile/users.rb

Overview

The Users class is holds the different sets of parameters for logging into a database, including username, password, etc. There are read_only configs, replication user configs, heartbeat configs, etc, for correctly and safely allowing access to different databases for different reasons.

This also data also is used to create the permissions, allowing the setup of replication to be even easier.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Users

Returns a new instance of Users.



10
11
12
13
14
15
16
# File 'lib/reptile/users.rb', line 10

def initialize(options)
  return if options.nil?
  
  @repl_user = options["replication_user"]
  @ro_user = options["ro_user"]
  @heartbeat_user = options["heartbeat_user"]
end

Class Method Details

.prompt_for_grant_userObject



19
20
21
22
23
24
25
26
27
# File 'lib/reptile/users.rb', line 19

def self.prompt_for_grant_user
  require 'rubygems'
  require 'highline'
  
  asker = HighLine.new
  asker.say("Please enter credentials for a user that has GRANT priviledges.")
  {:username => asker.ask("Enter your username:"), 
   :password => asker.ask("Enter your password:  ") { |q| q.echo = "x" }}
end

Instance Method Details

#heartbeat_userObject

The user settings for a user that reads/writes heartbeats



60
61
62
63
# File 'lib/reptile/users.rb', line 60

def heartbeat_user
  #raise "You need to specify a heartbeat user!" if @heartbeat_user.nil?
  @heartbeat_user || {}
end

#replication_userObject

The user settings for a user that has REPLICATION SLAVE privilidgess



35
36
37
38
39
# File 'lib/reptile/users.rb', line 35

def replication_user
  # TODO: only bail on getting a user if it is acutally used
  #raise "You need to specify a replication user!" if @repl_user.nil?
  @repl_user
end

#ro_userObject

The user settings for a user that has SELECT privilidgess



48
49
50
51
# File 'lib/reptile/users.rb', line 48

def ro_user
  #raise "You need to specify a SELECT user!" if @ro_user.nil?
  @ro_user || {}
end