Class: Etailer::MysqlCleanerCloner
Instance Attribute Summary collapse
#enabled, #env, #machine, #options, #run_order
Instance Method Summary
collapse
#enabled?, #scp, #ssh, #vm
Instance Attribute Details
#vm_db_password ⇒ Object
Returns the value of attribute vm_db_password.
3
4
5
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 3
def vm_db_password
@vm_db_password
end
|
#vm_db_user ⇒ Object
Returns the value of attribute vm_db_user.
3
4
5
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 3
def vm_db_user
@vm_db_user
end
|
Instance Method Details
#call ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 29
def call
@scripts.each do |script|
info "Fetching script #{script}..."
basename = script.split("/").last
vm.execute "curl #{script} -o /tmp/#{basename}"
vm.execute "mysql #{mysql_connection_string} < /tmp/#{basename}"
end
end
|
#mysql_connection_string ⇒ Object
25
26
27
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 25
def mysql_connection_string
"-u#{vm_db_user} -p#{vm_db_password}"
end
|
#name ⇒ Object
5
6
7
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 5
def name
"mysqlcleaner"
end
|
#scripts ⇒ Object
9
10
11
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 9
def scripts
@scripts ||= []
end
|
#scripts=(scripts) ⇒ Object
13
14
15
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 13
def scripts=(scripts)
@scripts = Array(scripts).flatten
end
|
#validate(machine, errors) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/vagrant-cloner/cloners/mysql_cleaner.rb', line 17
def validate(machine, errors)
failures = []
failures.push "You have to specify at least one script to run!" if scripts.nil? || scripts.empty?
failures.push "You must specify a VM database user and password!" unless vm_db_user && vm_db_password
errors.merge(name.to_sym => failures) if failures.any?
end
|