0001-feature-3782-extend-to-return-disk-and-snapshot-info.patch

original patch from the forum post - Anton Todorov, 09/12/2015 09:04 AM

Download (2.79 KB)

View differences:

src/vmm_mad/remotes/poll_xen_kvm.rb
332 332
            protocol = ele.attributes['protocol'] rescue nil
333 333
            name = ele.attributes['name'] rescue nil
334 334

  
335
            # get dev attribute (for block devices)
336
            dev = ele.attributes['dev'] rescue nil
337

  
335 338
            if protocol == "rbd"
336 339
                # Ceph
337 340
                auth = ele.parent.elements["auth"].attributes["username"] rescue nil
......
357 360
                    data[:snapshot_size] << { :id => snap_id, :disk_id => disk_id, :size => snapshot_size.round}
358 361

  
359 362
                end
363
            elsif !dev.nil?
364
                # Block device
365
                disk_id = dev.split(".")[-1]
366

  
367
                dev_xml = `one_disk_info "#{dev}"`
368
                next if !$? || !$?.success?
369

  
370
                dev_doc = REXML::Document.new( dev_xml )
371
                disk_size = dev_doc.elements["disk/size"].text.to_f/1024/1024
372

  
373
                data[:disk_size] << { :id => disk_id, :size => disk_size.round }
374

  
375
                dev_doc.elements.each("disk/snapshot") do |snap|
376

  
377
                    snap_id = snap.elements["id"].text.to_i
378

  
379
                    snapshot_size = snap.elements["size"].text.to_f/1024/1024
380

  
381
                    data[:snapshot_size] << { :id => snap_id, :disk_id => disk_id, :size => snapshot_size.round }
382

  
383
                end
360 384
            else
361 385
                # Regular Disk
362 386
                text = `qemu-img info --output=json #{file}`
363
-