commit 998c20c74b99edd8689ae81f6d9f731f36bc6439 Author: W. David Ashley w.david.ashley@gmail.com Date: Fri Jul 10 10:04:31 2015 -0500
Domains chapter - corrected example 32
en-US/extras/Domains-Example-32.py | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) --- diff --git a/en-US/extras/Domains-Example-32.py b/en-US/extras/Domains-Example-32.py index a02abfd..223d351 100644 --- a/en-US/extras/Domains-Example-32.py +++ b/en-US/extras/Domains-Example-32.py @@ -2,6 +2,7 @@ from __future__ import print_function import sys import libvirt +from xml.etree import ElementTree
domName = 'Fedora22-x86_64-1'
@@ -10,23 +11,22 @@ if conn == None: print('Failed to open connection to qemu:///system', file=sys.stderr) exit(1)
-dom = conn.lookupByID(6) +dom = conn.lookupByID(5) if dom == None: print('Failed to find the domain '+domName, file=sys.stderr) exit(1)
tree = ElementTree.fromstring(dom.XMLDesc()) iface = tree.find('devices/interface/target').get('dev') -rx_bytes, rx_packets, rx_err, rx_drop, tx_bytes, tx_packets, tx_err, - tx_drop = dom.interfaceStats(iface) -print('read bytes: '+rx_bytes) -print('read packets: 'rx_packets) -print('read errors: '+rx_err) -print('read drops: '+rx_drop) -print('write bytes: '+tx_bytes) -print('write packets: 'rt_packets) -print('write errors: '+tx_err) -print('write drops: '+tx_drop) +stats = dom.interfaceStats(iface) +print('read bytes: '+str(stats[0])) +print('read packets: '+str(stats[1])) +print('read errors: '+str(stats[2])) +print('read drops: '+str(stats[3])) +print('write bytes: '+str(stats[4])) +print('write packets: '+str(stats[5])) +print('write errors: '+str(stats[6])) +print('write drops: '+str(stats[7]))
conn.close() exit(0)
docs-commits@lists.fedoraproject.org