1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-13 12:58:17 +03:00

Delete import slave from onedb

This commit is contained in:
Javi Fontan 2017-07-13 12:59:44 +02:00
parent 2c1ac615ea
commit 8aba93124a
4 changed files with 0 additions and 1687 deletions

View File

@ -1162,7 +1162,6 @@ MARKETPLACE_DRIVER_S3_SCRIPTS="src/market_mad/remotes/s3/import \
#-------------------------------------------------------------------------------
ONEDB_FILES="src/onedb/fsck.rb \
src/onedb/import_slave.rb \
src/onedb/onedb.rb \
src/onedb/onedb_backend.rb \
src/onedb/vcenter_one54.rb \

File diff suppressed because it is too large Load Diff

View File

@ -400,25 +400,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
###########################################################################
# Import slave
###########################################################################
import_slave_desc = <<-EOT.unindent
Imports an existing federation slave into the federation master database
EOT
command :"import-slave", import_slave_desc, :options=>[FORCE,BACKUP,
SLAVE_SERVER,SLAVE_PORT,SLAVE_USERNAME,SLAVE_PASSWORD,
SLAVE_DBNAME,SLAVE_BACKUP] do
begin
helper = OneDB.new(options)
helper.import_slave(options)
rescue Exception => e
[-1, e.message]
end
end
###########################################################################
# Migrate vcenter 54
###########################################################################

View File

@ -311,150 +311,6 @@ class OneDB
end
end
def import_slave(ops)
if ops[:backend] == :sqlite
raise "Master DB must be MySQL"
end
passwd = ops[:slave_passwd]
if !passwd
passwd = get_password("Slave MySQL Password: ")
end
slave_backend = BackEndMySQL.new(
:server => ops[:slave_server],
:port => ops[:slave_port],
:user => ops[:slave_user],
:passwd => passwd,
:db_name => ops[:slave_db_name]
)
db_version = @backend.read_db_version
slave_db_version = slave_backend.read_db_version
if ops[:verbose]
puts "Master database information:"
pretty_print_db_version(db_version)
puts ""
puts ""
puts "Slave database information:"
pretty_print_db_version(slave_db_version)
puts ""
end
file = "#{RUBY_LIB_LOCATION}/onedb/import_slave.rb"
if File.exists? file
one_not_running()
load(file)
@backend.extend OneDBImportSlave
@backend.check_db_version(db_version, slave_db_version)
puts <<-EOT
Before running this tool, it is required to create a new Zone in the
Master OpenNebula.
Please enter the Zone ID that you created to represent the new Slave OpenNebula:
EOT
input = ""
while ( input.to_i.to_s != input ) do
print "Zone ID: "
input = gets.chomp.strip
end
zone_id = input.to_i
puts
puts <<-EOT
The import process will move the users from the slave OpeNenbula to the master
OpenNebula. In case of conflict, it can merge users with the same name.
For example:
+----------+-------------++------------+---------------+
| Master | Slave || With merge | Without merge |
+----------+-------------++------------+---------------+
| 5, alice | 2, alice || 5, alice | 5, alice |
| 6, bob | 5, bob || 6, bob | 6, bob |
| | || | 7, alice-1 |
| | || | 8, bob-1 |
+----------+-------------++------------+---------------+
In any case, the ownership of existing resources and group membership
is preserved.
EOT
input = ""
while !( ["Y", "N"].include?(input) ) do
print "Do you want to merge USERS (Y/N): "
input = gets.chomp.upcase
end
merge_users = input == "Y"
puts
input = ""
while !( ["Y", "N"].include?(input) ) do
print "Do you want to merge GROUPS (Y/N): "
input = gets.chomp.upcase
end
merge_groups = input == "Y"
puts
input = ""
while !( ["Y", "N"].include?(input) ) do
print "Do you want to merge VDCS (Y/N): "
input = gets.chomp.upcase
end
merge_vdcs = input == "Y"
ops[:backup] = @backend.bck_file if ops[:backup].nil?
ops[:"slave-backup"] = slave_backend.bck_file if ops[:"slave-backup"].nil?
# Import will be executed, make DB backup
backup(ops[:backup], ops)
backup(ops[:"slave-backup"], ops, slave_backend)
begin
puts " > Running slave import" if ops[:verbose]
result = @backend.import_slave(slave_backend, merge_users,
merge_groups, merge_vdcs, zone_id)
if !result
raise "Error running slave import"
end
puts " > Done" if ops[:verbose]
puts "" if ops[:verbose]
return 0
rescue Exception => e
puts
puts e.message
puts e.backtrace.join("\n")
puts
puts "Error running slave import"
puts "The databases will be restored"
ops[:force] = true
restore(ops[:backup], ops)
restore(ops[:"slave-backup"], ops, slave_backend)
return -1
end
else
raise "No slave import file found in #{RUBY_LIB_LOCATION}/onedb/import_slave.rb"
end
end
def patch(file, ops)
ret = @backend.read_db_version