mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-14 19:24:10 +03:00
feature #3782: fix monitoring of persistent images
This commit is contained in:
parent
3a89a0d107
commit
d840ce3eb3
@ -1118,6 +1118,15 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
file << "\t" << default_raw << endl;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Metadata used by drivers
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "\t<metadata>" << endl;
|
||||
file << "\t\t<system_datastore>" << vm->get_remote_system_dir() <<
|
||||
"</system_datastore>" << endl;
|
||||
file << "\t</metadata>" << endl;
|
||||
|
||||
file << "</domain>" << endl;
|
||||
|
||||
file.close();
|
||||
|
@ -318,6 +318,8 @@ module KVM
|
||||
|
||||
doc = REXML::Document.new(xml)
|
||||
size = 0
|
||||
systemds = doc.elements['domain/metadata/system_datastore'] rescue nil
|
||||
systemds = systemds.text.gsub(/\/+/, '/') if systemds
|
||||
|
||||
data = {
|
||||
:disk_size => [],
|
||||
@ -358,6 +360,24 @@ module KVM
|
||||
|
||||
end
|
||||
else
|
||||
# Search the disk in system datastore when the source
|
||||
# is a persistent image with snapshots
|
||||
if !file.match(/.*disk\.\d+$/) && systemds
|
||||
source = file.gsub(%r{/+}, '/')
|
||||
|
||||
disks = Dir["#{systemds}/disk.*"]
|
||||
|
||||
disks.each do |disk|
|
||||
next if !File.symlink?(disk)
|
||||
link = File.readlink(disk).gsub(%r{/+}, '/')
|
||||
|
||||
if link == source
|
||||
file = disk
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Regular Disk
|
||||
text = `qemu-img info --output=json #{file}`
|
||||
next if !$? || !$?.success?
|
||||
|
Loading…
x
Reference in New Issue
Block a user