Class: Dabcup::Operation::Base
- Inherits:
-
Object
- Object
- Dabcup::Operation::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/dabcup/operation/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(database) ⇒ Base
Returns a new instance of Base.
8
9
10
|
# File 'lib/dabcup/operation/base.rb', line 8
def initialize(database)
@database = database
end
|
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
4
5
6
|
# File 'lib/dabcup/operation/base.rb', line 4
def database
@database
end
|
Instance Method Details
#best_dumps_path ⇒ Object
Try to returns the best directory path to dump the database.
22
23
24
25
26
27
28
29
|
# File 'lib/dabcup/operation/base.rb', line 22
def best_dumps_path
if database.via_ssh?
return main_storage.path if same_ssh_as_database?(main_storage)
else
return main_storage.path if main_storage.local?
end
Dir.tmpdir
end
|
#best_local_dumps_path ⇒ Object
Try to returns the best local directory path.
32
33
34
35
|
# File 'lib/dabcup/operation/base.rb', line 32
def best_local_dumps_path
return spare_storage.path if spare_storage.local?
Dir.tmpdir
end
|
#check ⇒ Object
46
47
48
49
50
51
|
# File 'lib/dabcup/operation/base.rb', line 46
def check
return if not database.via_ssh?
if not same_ssh_as_database?(main_storage)
raise Error.new("When dumping via SSH the main storage must be local to the database.")
end
end
|
#remove_local_dump? ⇒ Boolean
37
38
39
|
# File 'lib/dabcup/operation/base.rb', line 37
def remove_local_dump?
!main_storage.local? && (spare_storage && !spare_storage.local?)
end
|
#run ⇒ Object
12
13
14
|
# File 'lib/dabcup/operation/base.rb', line 12
def run
raise NotImplementedError.new("Sorry")
end
|
#same_ssh_as_database?(storage) ⇒ Boolean
41
42
43
44
|
# File 'lib/dabcup/operation/base.rb', line 41
def same_ssh_as_database?(storage)
return false if not storage.driver.is_a?(Dabcup::Storage::Driver::SFTP)
storage.driver.host == database.tunnel.host
end
|
#terminate ⇒ Object
16
17
18
19
|
# File 'lib/dabcup/operation/base.rb', line 16
def terminate
main_storage.disconnect if main_storage
spare_storage.disconnect if spare_storage
end
|