Revision cc827fb5

View differences:

src/vmm_mad/kvm/one_vmm_kvm.rb
39 39

  
40 40
require 'pp'
41 41
require "VirtualMachineDriver"
42
require 'rexml/document'
42 43

  
43 44
# ---------------------------------------------------------------------------- #
44 45
# The main class for the LibVirt driver                                        #
......
57 58
        :save     => "virsh --connect #{LIBVIRT_URI} save",
58 59
        :restore  => "virsh --connect #{LIBVIRT_URI} restore",
59 60
        :migrate  => "virsh --connect #{LIBVIRT_URI} migrate --live",
60
        :poll     => "virsh --connect #{LIBVIRT_URI} dominfo"
61
        :poll     => "virsh --connect #{LIBVIRT_URI} dominfo",
62
        :netstats => "virsh --connect #{LIBVIRT_URI} domifstat",
63
        :dumpxml  => "virsh --connect #{LIBVIRT_URI} dumpxml" 
61 64
    }
62 65

  
63 66
    # ------------------------------------------------------------------------ #
......
144 147
        exe  = SSHCommand.run("#{LIBVIRT[:poll]} #{deploy_id}", host,
145 148
                              log_method(id))
146 149

  
150
        exe2  = SSHCommand.run("#{LIBVIRT[:dumpxml]} #{deploy_id}", host,
151
                               log_method(id))
152

  
153
        doc = REXML::Document.new(exe2.stdout)
154
        interfaces = []
155

  
156
        doc.elements.each('domain/devices/interface/target') do |ele|
157
           interfaces << ele.attributes["dev"]
158
        end
159

  
160
        exe3  = SSHCommand.run("#{LIBVIRT[:netstats]} #{deploy_id} #{interfaces}", host,
161
                               log_method(id))
162

  
147 163
        if exe.code != 0
148 164
            result = :failure
149 165
            info   = "-"
......
182 198
            end
183 199
        }
184 200

  
201
        exe3.stdout.each_line do |line|
202
            columns=line.split(" ").collect {|c| c.strip }
203
            case columns[1]
204
                when 'rx_bytes'
205
                    info << " #{POLL_ATTRIBUTE[:netrx]}="  << (columns[2].to_i).to_s
206
                when 'tx_bytes'
207
                    info << " #{POLL_ATTRIBUTE[:nettx]}="  << (columns[2].to_i).to_s
208
            end
209
        end
210

  
185 211
        send_message(ACTION[:poll], RESULT[:success], id, info)
186 212
    end
187 213
end

Also available in: Unified diff