mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-01 05:47:01 +03:00
F #6029: Force to re-use current datastore ID
When doing incremental backups it MUST reuse the current datastore ID. This commits forces this setting ignoring the API parameter in this case.
This commit is contained in:
parent
074d19411a
commit
01c490a36d
@ -1573,11 +1573,7 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
OneVMHelper::YEARLY,
|
||||
OneVMHelper::HOURLY,
|
||||
OneVMHelper::END_TIME] do
|
||||
if options[:datastore].nil?
|
||||
STDERR.puts 'Datastore to save the backup is mandatory: '
|
||||
STDERR.puts "\t -d datastore_id | name"
|
||||
exit(-1)
|
||||
end
|
||||
options[:datastore] = -1 if options[:datastore].nil?
|
||||
|
||||
reset = options[:reset] == true
|
||||
|
||||
|
@ -803,7 +803,7 @@ module OpenNebula
|
||||
# @param ds_id [Integer] Id of the datastore to save the backup
|
||||
# @return [Integer, OpenNebula::Error] ID of the resulting BACKUP image
|
||||
# in case of success, Error otherwise.
|
||||
def backup(ds_id, reset = false)
|
||||
def backup(ds_id = -1, reset = false)
|
||||
return @client.call(VM_METHODS[:backup], @pe_id, ds_id, reset)
|
||||
end
|
||||
|
||||
|
@ -3973,14 +3973,20 @@ void VirtualMachineBackup::request_execute(
|
||||
|
||||
Backups::Mode mode;
|
||||
int li_id;
|
||||
int bk_id = -1;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get request parameters
|
||||
// ------------------------------------------------------------------------
|
||||
int vm_id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
int backup_ds_id = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
int backup_ds_id = -1;
|
||||
bool reset = false;
|
||||
|
||||
if ( paramList.size() > 2 )
|
||||
{
|
||||
backup_ds_id = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
}
|
||||
|
||||
if ( paramList.size() > 3 )
|
||||
{
|
||||
reset = xmlrpc_c::value_boolean(paramList.getBoolean(3));
|
||||
@ -3997,6 +4003,8 @@ void VirtualMachineBackup::request_execute(
|
||||
|
||||
mode = vm->backups().mode();
|
||||
li_id = vm->backups().last_increment_id();
|
||||
|
||||
bk_id = vm->backups().incremental_backup_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4006,6 +4014,25 @@ void VirtualMachineBackup::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
// Incremental backups use the current datastore if not resetting the chain
|
||||
if ( mode == Backups::INCREMENT && !reset && li_id != -1 )
|
||||
{
|
||||
ImagePool* ipool = nd.get_ipool();
|
||||
|
||||
if (auto img = ipool->get_ro(bk_id))
|
||||
{
|
||||
backup_ds_id = img->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
att.resp_obj = PoolObjectSQL::IMAGE;
|
||||
att.resp_id = bk_id;
|
||||
|
||||
failure_response(NO_EXISTS, att);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( auto ds = dspool->get_ro(backup_ds_id) )
|
||||
{
|
||||
if (ds->get_type() != Datastore::BACKUP_DS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user