mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'feature-1490'
This commit is contained in:
commit
5a85478afa
1091
src/onedb/3.8.0_fsck.rb
Normal file
1091
src/onedb/3.8.0_fsck.rb
Normal file
File diff suppressed because it is too large
Load Diff
@ -133,8 +133,8 @@ DBNAME={
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
description <<-EOT.unindent
|
||||
This command enables the user to manage the OpenNebula database. It
|
||||
provides information about the DB version, means to upgrade it to the
|
||||
This command enables the user to manage the OpenNebula database. It
|
||||
provides information about the DB version, means to upgrade it to the
|
||||
latest version, and backup tools.
|
||||
EOT
|
||||
|
||||
@ -164,7 +164,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
# Version
|
||||
###########################################################################
|
||||
version_desc = <<-EOT.unindent
|
||||
Prints the current DB version.
|
||||
Prints the current DB version.
|
||||
Use -v flag to see also OpenNebula version
|
||||
EOT
|
||||
|
||||
@ -227,4 +227,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
[-1, e.message]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
# fsck
|
||||
###########################################################################
|
||||
fsck_desc = <<-EOT.unindent
|
||||
fsck
|
||||
EOT
|
||||
|
||||
command :fsck, fsck_desc, :options=>[FORCE,BACKUP] do
|
||||
begin
|
||||
helper = OneDB.new(options)
|
||||
helper.fsck(options)
|
||||
rescue Exception => e
|
||||
[-1, e.message]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -61,16 +61,16 @@ class OneDB
|
||||
if !File.exists?(bck_file)
|
||||
raise "File #{bck_file} doesn't exist, backup restoration aborted."
|
||||
end
|
||||
|
||||
|
||||
one_not_running
|
||||
|
||||
|
||||
@backend.restore(bck_file, ops[:force])
|
||||
return 0
|
||||
end
|
||||
|
||||
def version(ops)
|
||||
version, timestamp, comment = @backend.read_db_version
|
||||
|
||||
|
||||
if(ops[:verbose])
|
||||
puts "Version: #{version}"
|
||||
|
||||
@ -160,6 +160,56 @@ class OneDB
|
||||
end
|
||||
end
|
||||
|
||||
def fsck(ops)
|
||||
version, timestamp, comment = @backend.read_db_version
|
||||
|
||||
if ops[:verbose]
|
||||
puts "Version read:"
|
||||
puts "#{version} : #{comment}"
|
||||
puts ""
|
||||
end
|
||||
|
||||
file = "#{RUBY_LIB_LOCATION}/onedb/#{version}_fsck.rb"
|
||||
|
||||
if File.exists? file
|
||||
|
||||
one_not_running()
|
||||
|
||||
begin
|
||||
# FSCK will be executed, make DB backup
|
||||
backup(ops[:backup], ops)
|
||||
|
||||
puts " > Running fsck" if ops[:verbose]
|
||||
|
||||
load(file)
|
||||
@backend.extend OneDBFsck
|
||||
result = @backend.fsck
|
||||
|
||||
if !result
|
||||
raise "Error running fsck version #{version}"
|
||||
end
|
||||
|
||||
puts " > Done" if ops[:verbose]
|
||||
puts "" if ops[:verbose]
|
||||
|
||||
return 0
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
|
||||
puts "Error running fsck version #{version}"
|
||||
puts "The database will be restored"
|
||||
|
||||
ops[:force] = true
|
||||
|
||||
restore(ops[:backup], ops)
|
||||
|
||||
return -1
|
||||
end
|
||||
else
|
||||
raise "No fsck found for this version #{version}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def one_not_running()
|
||||
@ -167,4 +217,4 @@ class OneDB
|
||||
raise "First stop OpenNebula. Lock file found: #{LOCK_FILE}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user