The streamAPI class that encapsulates work with libvirt's streams was
fundamentaly broken:
- each call to one of the methods created a new stream and
performed the call
- some methods called virStream methods with different numbers
of arguments
- there was no way to extract the actual libvirt stream object
---
lib/streamAPI.py | 52 ++++++++++++++++++++++++++--------------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/lib/streamAPI.py b/lib/streamAPI.py
index bc7d217..69e183e 100644
--- a/lib/streamAPI.py
+++ b/lib/streamAPI.py
@@ -38,76 +38,76 @@ append_path(result.group(0))
import exception
class StreamAPI(object):
- def __init__(self, connection):
- self.conn = connection
+ def __init__(self, conn, flags = 0):
+ try:
+ self.stream = conn.newStream(flags)
+ except libvirt.libvirtError, e:
+ message = e.get_error_message()
+ code = e.get_error_code()
+ raise exception.LibvirtAPI(message, code)
+
+ def getStream(self):
+ return self.stream
- def abort(self, flag = 0):
+ def abort(self):
try:
- stream_obj = newStream(flag)
- return stream_obj.abort()
+ return self.stream.abort()
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def connect(self, flag = 0):
+ def connect(self):
try:
- stream_obj = newStream(flag)
- return stream_obj.connect()
+ return self.stream.connect()
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def finish(self, flag = 0):
+ def finish(self):
try:
- stream_obj = newStream(flag)
- return stream_obj.finish()
+ return self.stream.finish()
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def recv(self, flag = 0, data, nbytes):
+ def recv(self, nbytes):
try:
- stream_obj = newStream(flag)
- return stream_obj.recv(data, nbytes)
+ return self.stream.recv(nbytes)
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def send(self, flag = 0, data, nbytes):
+ def send(self, data):
try:
- stream_obj = newStream(flag)
- return stream_obj.send(data, nbytes)
+ return self.stream.send(data)
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def eventAddCallback(self, flag = 0, cb, opaque):
+ def eventAddCallback(self, cb, opaque):
try:
- stream_obj = newStream(flag)
- return stream_obj.eventAddCallback(cb, opaque)
+ return self.stream.eventAddCallback(cb, opaque)
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def eventRemoveCallback(self, flag = 0):
+ def eventRemoveCallback(self):
try:
- stream_obj = newStream(flag)
- return stream_obj.eventRemoveCallback()
+ return self.stream.eventRemoveCallback()
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
raise exception.LibvirtAPI(message, code)
- def eventUpdateCallback(self, flag = 0, events)
+ def eventUpdateCallback(self, events):
try:
- stream_obj = newStream(flag)
- return stream_obj.eventUpdateCallback(events)
+ return self.stream.eventUpdateCallback(events)
except libvirt.libvirtError, e:
message = e.get_error_message()
code = e.get_error_code()
--
1.7.3.4