1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F #6063: Pass backup_job_id to drivers

This enables to use the same repo for all VMs in the same backup job,
for example to deduplicate all VMs in the backup job.

This commit changes the driver interface for the backup operation as now
the backup job id is passed:

BACKUP host:remote_dir DISK_ID:..:DISK_ID vm_uuid bj_id vm_id ds_id

When the backup job is not defined it will be '-'
This commit is contained in:
Ruben S. Montero 2023-08-30 19:22:45 +02:00
parent addb5edc33
commit 5e37e52e39
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
4 changed files with 38 additions and 9 deletions

View File

@ -58,15 +58,16 @@ require 'securerandom'
require_relative '../../tm/lib/datastore'
require_relative '../../tm/lib/tm_action'
# BACKUP host:remote_dir DISK_ID:..:DISK_ID vm_uuid vm_id ds_id
# BACKUP host:remote_dir DISK_ID:..:DISK_ID vm_uuid bj_id vm_id ds_id
ds_xml = STDIN.read
dir = ARGV[0].split(':')
_disks = ARGV[1].split(':')
_vm_uuid = ARGV[2]
vm_id = ARGV[3]
_ds_id = ARGV[4]
_bj_id = ARGV[3]
vm_id = ARGV[4]
_ds_id = ARGV[5]
vm_host = dir[0]

View File

@ -994,7 +994,16 @@ int ImageManager::stat_image(Template* img_tmpl,
{
img_data << "<IMAGE><PATH>"
<< one_util::xml_escape(res)
<< "</PATH></IMAGE>";
<< "</PATH>";
img_tmpl->get("BACKUP_JOB_ID", res);
if (!res.empty())
{
img_data << "<BACKUP_JOB_ID>" << res << "</BACKUP_JOB_ID>";
}
img_data << "</IMAGE>";
}
break;
}

View File

@ -2262,7 +2262,10 @@ int TransferManager::backup_transfer_commands(
tm_mad_system = "." + tsys;
}*/
bool do_volatile = vm->backups().do_volatile();
Backups& backups = vm->backups();
bool do_volatile = backups.do_volatile();
int job_id = backups.backup_job_id();
// -------------------------------------------------------------------------
// Image Transfer Commands
@ -2283,13 +2286,23 @@ int TransferManager::backup_transfer_commands(
disk_str << disk->get_disk_id() << ":";
}
//BACKUP(.tm_mad_system) tm_mad host:remote_dir DISK_ID:...:DISK_ID deploy_id vmid dsid
//BACKUP(.tm_mad_system) tm_mad host:remote_dir DISK_ID:...:DISK_ID deploy_id bj_id vmid dsid
xfr << "BACKUP" << tm_mad_system
<< " " << vm_tm_mad << " "
<< vm->get_hostname() << ":" << vm->get_system_dir() << " "
<< disk_str.str() << " "
<< vm->get_deploy_id() << " "
<< vm->get_oid() << " "
<< vm->get_deploy_id() << " ";
if ( job_id == -1 )
{
xfr << "- ";
}
else
{
xfr << job_id << " ";
}
xfr << vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;

View File

@ -23,7 +23,7 @@ module TransferManager
# This class includes methods manage backup images
class BackupImage
attr_reader :vm_id, :keep_last
attr_reader :vm_id, :keep_last, :bj_id
# Given a sorted list of qcow2 files,
# return a shell recipe that reconstructs the backing chain in-place.
@ -111,6 +111,8 @@ module TransferManager
# be just a single ID in the VMS array.
@vm_id = @action.elements["#{prefix}/VMS/ID"].text.to_i
@bj_id = @action.elements["#{prefix}/TEMPLATE/BACKUP_JOB_ID"]&.text
@keep_last = @action.elements['/DS_DRIVER_ACTION_DATA/EXTRA_DATA/KEEP_LAST']&.text.to_i
@incr_id = @action.elements['/DS_DRIVER_ACTION_DATA/TEMPLATE/INCREMENT_ID']&.text.to_i
@ -238,6 +240,8 @@ module TransferManager
@base_url = "#{opts[:proto]}://#{opts[:ds_id]}/#{chain}"
@bj_id = opts[:bimage].bj_id
return unless no_ip
NIC_LIST << ['IP', 'IP6', 'IP6_ULA', 'IP6_GLOBAL', 'MAC']
@ -284,6 +288,8 @@ module TransferManager
FROM_BACKUP_DS = "#{@ds_id}"
EOS
tmpl << "BACKUP_JOB_ID = \"#{@bj_id}\"" if @bj_id
bck_disks[disk_id] = { :template => tmpl, :name => name }
end