mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
M #-: Fix onezone serversync for postgresql (#1143)
This commit is contained in:
parent
0e613cc09c
commit
6553d76c86
@ -77,6 +77,12 @@ class Replicator
|
||||
@l_config_elements = { :raw => @l_config }
|
||||
@l_fed_elements = { :raw => @l_config }
|
||||
|
||||
if OpenNebula.is_error?(@l_config)
|
||||
STDERR.puts 'Unable to read OpenNebula configuration. ' \
|
||||
'Is OpenNebula running?'
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
fetch_db_config(@l_config_elements)
|
||||
fetch_fed_config(@l_fed_elements)
|
||||
|
||||
@ -129,7 +135,7 @@ class Replicator
|
||||
def fetch_db_config(configs)
|
||||
configs.store(:backend, configs[:raw]['/OPENNEBULA_CONFIGURATION/DB/BACKEND'])
|
||||
|
||||
if configs[:backend] == 'mysql'
|
||||
if configs[:backend] == 'mysql' || configs[:backend] == 'postgresql'
|
||||
configs.store(:server, configs[:raw]['/OPENNEBULA_CONFIGURATION/DB/SERVER'])
|
||||
configs.store(:user, configs[:raw]['/OPENNEBULA_CONFIGURATION/DB/USER'])
|
||||
configs.store(:password, configs[:raw]['/OPENNEBULA_CONFIGURATION/DB/PASSWD'])
|
||||
@ -137,7 +143,7 @@ class Replicator
|
||||
configs.store(:port, configs[:raw]['/OPENNEBULA_CONFIGURATION/DB/PORT'])
|
||||
configs[:port] = '3306' if configs[:port] == '0'
|
||||
else
|
||||
STDERR.puts 'No mysql backend configuration found'
|
||||
STDERR.puts 'No mysql or postgresql backend configuration found'
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
@ -305,7 +311,8 @@ class Replicator
|
||||
'this could take a while'
|
||||
|
||||
ssh(
|
||||
"onedb backup -f -u #{@r_config_elements[:user]} " \
|
||||
"onedb backup -f -t #{@r_config_elements[:backend]} " \
|
||||
"-u #{@r_config_elements[:user]} " \
|
||||
"-p #{@r_config_elements[:password]} " \
|
||||
"-d #{@r_config_elements[:dbname]} " \
|
||||
"-P #{@r_config_elements[:port]} /tmp/one_db_dump.sql"
|
||||
@ -320,7 +327,8 @@ class Replicator
|
||||
puts 'Restoring database'
|
||||
|
||||
run_command(
|
||||
"onedb restore -f -u #{@l_config_elements[:user]} " \
|
||||
"onedb restore -f -t #{@l_config_elements[:backend]}" \
|
||||
"-u #{@l_config_elements[:user]} " \
|
||||
"-p #{@l_config_elements[:password]} " \
|
||||
"-d #{@l_config_elements[:dbname]} " \
|
||||
"-P #{@l_config_elements[:port]} " \
|
||||
|
@ -254,7 +254,7 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
|
||||
server = Replicator.new('/var/lib/one/.ssh/id_rsa', args[0])
|
||||
server.process_files(options.key?(:database))
|
||||
server.process_files(options[:db])
|
||||
|
||||
0
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user