mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-18 06:03:39 +03:00
parent
06b4644f9b
commit
1a320ba8e0
@ -637,6 +637,14 @@ public:
|
||||
return _increments;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add VM disk ID to list of backed up disks
|
||||
*/
|
||||
void add_backup_disk(int id)
|
||||
{
|
||||
_backup_disk_ids.add(id);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -753,6 +761,8 @@ private:
|
||||
*/
|
||||
BackupIncrements _increments;
|
||||
|
||||
ObjectCollection _backup_disk_ids;
|
||||
|
||||
/**
|
||||
* ID of the snapshot being processed (if any)
|
||||
*/
|
||||
|
@ -822,6 +822,13 @@ public:
|
||||
*/
|
||||
bool backup_increment(bool do_volatile);
|
||||
|
||||
/**
|
||||
* Returns list of disk IDs, ready for backup
|
||||
*
|
||||
* @param do_volatile consider volatile disks
|
||||
*/
|
||||
void backup_disk_ids(bool do_volatile, std::vector<int>& ids);
|
||||
|
||||
protected:
|
||||
|
||||
VirtualMachineAttribute * attribute_factory(VectorAttribute * va,
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://opennebula.org/XMLSchema" elementFormDefault="qualified" targetNamespace="http://opennebula.org/XMLSchema">
|
||||
<xs:include schemaLocation="shared.xsd"/>
|
||||
<xs:element name="IMAGE">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
@ -65,27 +66,9 @@
|
||||
<xs:element name="TARGET_SNAPSHOT" type="xs:integer"/>
|
||||
<xs:element name="DATASTORE_ID" type="xs:integer"/>
|
||||
<xs:element name="DATASTORE" type="xs:string"/>
|
||||
<xs:element name="VMS">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="CLONES">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="APP_CLONES">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="VMS" type="IDS"/>
|
||||
<xs:element name="CLONES" type="IDS"/>
|
||||
<xs:element name="APP_CLONES" type="IDS"/>
|
||||
<xs:element name="TEMPLATE">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
@ -135,6 +118,7 @@
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="BACKUP_DISK_IDS" type="IDS" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
@ -61,6 +61,7 @@ Image::Image(int _uid,
|
||||
img_clone_collection("CLONES"),
|
||||
app_clone_collection("APP_CLONES"),
|
||||
snapshots(-1, Snapshots::DENY),
|
||||
_backup_disk_ids("BACKUP_DISK_IDS"),
|
||||
target_snapshot(-1)
|
||||
{
|
||||
if (_image_template)
|
||||
@ -397,6 +398,7 @@ string& Image::to_xml(string& xml) const
|
||||
string template_xml;
|
||||
string perms_xml;
|
||||
string increments_xml;
|
||||
string backup_disk_ids;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
@ -432,7 +434,8 @@ string& Image::to_xml(string& xml) const
|
||||
app_clone_collection.to_xml(app_clone_collection_xml) <<
|
||||
obj_template->to_xml(template_xml) <<
|
||||
snapshots.to_xml(snapshots_xml) <<
|
||||
_increments.to_xml(increments_xml) <<
|
||||
_increments.to_xml(increments_xml) <<
|
||||
_backup_disk_ids.to_xml(backup_disk_ids) <<
|
||||
"</IMAGE>";
|
||||
|
||||
xml = oss.str();
|
||||
@ -514,6 +517,7 @@ int Image::from_xml(const string& xml)
|
||||
rc += vm_collection.from_xml(this, "/IMAGE/");
|
||||
rc += img_clone_collection.from_xml(this, "/IMAGE/");
|
||||
rc += app_clone_collection.from_xml(this, "/IMAGE/");
|
||||
_backup_disk_ids.from_xml(this, "/IMAGE/"); // For backward compatibility this attribute is not mandatory
|
||||
|
||||
ObjectXML::get_nodes("/IMAGE/SNAPSHOTS", content);
|
||||
|
||||
|
@ -2931,6 +2931,20 @@ void LifeCycleManager::trigger_backup_success(int vid)
|
||||
backups.add(image_id);
|
||||
|
||||
backups.remove_last(delete_ids);
|
||||
|
||||
if (auto image = ipool->get(image_id))
|
||||
{
|
||||
vector<int> backup_disk_ids;
|
||||
|
||||
vm->get_disks().backup_disk_ids(backups.do_volatile(), backup_disk_ids);
|
||||
|
||||
for (auto id : backup_disk_ids)
|
||||
{
|
||||
image->add_backup_disk(id);
|
||||
}
|
||||
|
||||
ipool->update(image.get());
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
@ -2353,27 +2353,15 @@ int TransferManager::backup_transfer_commands(
|
||||
// -------------------------------------------------------------------------
|
||||
// Image Transfer Commands
|
||||
// -------------------------------------------------------------------------
|
||||
ostringstream disk_str;
|
||||
std::vector<int> disk_ids;
|
||||
|
||||
for (auto disk : disks)
|
||||
{
|
||||
string type = disk->vector_value("TYPE");
|
||||
|
||||
one_util::toupper(type);
|
||||
|
||||
if ((type == "SWAP") || ((type == "FS") && !do_volatile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
disk_str << disk->get_disk_id() << ":";
|
||||
}
|
||||
disks.backup_disk_ids(do_volatile, disk_ids);
|
||||
|
||||
//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() << " "
|
||||
<< one_util::join(disk_ids, ':') << " "
|
||||
<< vm->get_deploy_id() << " ";
|
||||
|
||||
if ( job_id == -1 )
|
||||
|
@ -1576,6 +1576,25 @@ bool VirtualMachineDisks::backup_increment(bool do_volatile)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachineDisks::backup_disk_ids(bool do_volatile, std::vector<int>& ids)
|
||||
{
|
||||
for (const auto disk : *this)
|
||||
{
|
||||
string type = disk->vector_value("TYPE");
|
||||
|
||||
one_util::toupper(type);
|
||||
|
||||
if ((type == "SWAP") || ((type == "FS") && !do_volatile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ids.push_back(disk->get_disk_id());
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user